/******************************************** ** cg_init.h ** ** --------- ** ** ** ** A very basic loader for Cg programs. ** ** The header for using cg_init.c ** ** ** ** Chris Wyman (3/1/2006) ** ********************************************/ #include #include /*******************************************************************************************/ /* Assign each shader (both vertex & fragment) a unique number (0 <= ID < NUM_CG_PROGRAMS) */ /* The purpose of this is to index into an array (of size PROG_MAX) with easily */ /* identifiable names. Also add code in "arb_init.c" to initialize this array! */ /*******************************************************************************************/ #define NUM_CG_PROGRAMS 3 #define CG_TEST_SHADER_V 0 #define CG_TEST_SHADER_F 1 #define CG_TEST_SHADER2_F 2 /*******************************************************************************************/ /* A structure to keep relevant shader info together */ /*******************************************************************************************/ typedef struct __shader { char filename[64]; /* Filename of file containing shader code */ int type; /* GL_VERTEX_PROGRAM_ARB or GL_FRAGMENT_PROGRAM_ARB */ int isInitialized; /* Have we initalized this program (to dbl check validity?) */ GLuint shaderNum; /* A unique GL-assigned shader number */ char *string; /* A string containing ASCII code for the shader */ } shader; /* This is an internal data structure used for storing data about CG shaders. This is a */ /* a hack that I used, because I wanted to keep the programmer-specified strucutre (the */ /* 'shader' structure from above) the same for Cg and ARB assembly shaders. This data */ /* is automatically setup for you. */ typedef struct { CGcontext shaderContext; /* shader context containing all shaders */ CGprofile vertProfile, fragProfile; /* most recent profiles supported by this GPU */ CGprogram programs[NUM_CG_PROGRAMS]; /* the Cg handle/ID for each shader */ CGprofile programType[NUM_CG_PROGRAMS]; /* specifies the profile-type for each shader */ char *programName[NUM_CG_PROGRAMS]; /* the shader file, useful for reloading later */ } CGData;