GPUProgram::GPUProgram(void) { cgSetErrorCallback(handleCgError); context = cgCreateContext(); if (!cgIsContext(context)){ fprintf(stderr, "Cg Error: cannot create context!\n"); exit(1); } _chooseProfiles(); }
void cgtk::load_fragment_program(CGprogram &f_program,char *shader_path, char *program_name) { assert(cgIsContext(context)); f_program = cgCreateProgramFromFile(context, CG_SOURCE, shader_path, fragmentProfile,program_name, NULL); if (!cgIsProgramCompiled(f_program)) cgCompileProgram(f_program); cgGLEnableProfile(fragmentProfile); cgGLLoadProgram(f_program); cgGLDisableProfile(fragmentProfile); }
void CGShader::init(const char *filename, const char *funcname, const char **options) { char* gpopt[3]={0,"-profileopts Vertices=16",0}; assert(cgIsContext(*m_pCgContext)); //if (*m_pCGProfile == cgGLGetLatestProfile(CG_GL_GEOMETRY)){ // options = &gpopt[0]; //} m_program = cgCreateProgramFromFile(*m_pCgContext, CG_SOURCE, filename, *m_pCGProfile, funcname, (const char**)gpopt); if (!cgIsProgramCompiled(m_program)) cgCompileProgram(m_program); cgGLLoadProgram(m_program); }
void cgtk::load_vertex_program(CGprogram &v_program,char *shader_path, char *program_name) { assert(cgIsContext(context)); v_program = cgCreateProgramFromFile(context, CG_SOURCE,shader_path, vertexProfile,program_name, NULL); if (!cgIsProgramCompiled(v_program)) cgCompileProgram(v_program); cgGLEnableProfile(vertexProfile); cgGLLoadProgram(v_program); cgGLDisableProfile(vertexProfile); }