
// CG setup
#ifdef DO_CG_CRAP
	CGcontext cgContext = cgCreateContext();
	assert(cgContext);
	
	CGprofile cgVertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
	CGprofile cgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
	assert(cgVertexProfile != CG_PROFILE_UNKNOWN);
	
	cgGLSetOptimalOptions(cgVertexProfile);
	cgGLSetOptimalOptions(cgFragmentProfile);
	
	CGprogram cgUISprite = cgCreateProgramFromFile(cgContext, CG_SOURCE, "uisprite.cg", cgVertexProfile, "main", 0);
	if(!cgUISprite) {
		cout << "Vertex Shader error: " << cgGetErrorString(cgGetError()) << endl;
		exit(1);
	}
	
	CGprogram cgUISpriteFrag = cgCreateProgramFromFile(cgContext, CG_SOURCE, "uisprite.cg", cgFragmentProfile, "fragmain", 0);
	if(!cgUISprite) {
		cout << "Fragment Shader error: " << cgGetErrorString(cgGetError()) << endl;
		exit(1);
	}
	
	cgGLLoadProgram(cgUISprite);
	cgGLLoadProgram(cgUISpriteFrag);
	
	CGparameter position, color, wave, modelViewMatrix;
	position = cgGetNamedParameter(cgUISprite, "IN.position");
	color = cgGetNamedParameter(cgUISprite, "IN.color");
	wave = cgGetNamedParameter(cgUISprite, "IN.wave");
	modelViewMatrix = cgGetNamedParameter(cgUISprite, "modelViewProj");
#endif
	


// CG main loop		
#ifdef DO_CG_CRAP
		cgGLSetStateMatrixParameter(modelViewMatrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);

		cgGLEnableProfile(cgVertexProfile);
		cgGLEnableProfile(cgFragmentProfile);
		cgGLBindProgram(cgUISprite);
		
		cgGLSetParameter4f(color, 1, 0, 0, 0.5);
#endif


#ifdef DO_CG_CRAP		
		cgGLDisableProfile(cgVertexProfile);
		cgGLDisableProfile(cgFragmentProfile);
#endif		



// CG cleanup
#ifdef DO_CG_CRAP
	cgDestroyContext(cgContext);

#endif
