I can't seem to figure out how to make a CG vertex and pixel shader work together.
I create the shaders like this:
cgContext = cgCreateContext();
cg_vs = cgCreateProgramFromFile(cgContext, CG_SOURCE, "Data/Shaders/default.cg", cgGLGetLatestProfile(CG_GL_VERTEX), "VS", 0);
cgGLLoadProgram(cg_vs);
cg_ps = cgCreateProgramFromFile(cgContext, CG_SOURCE, "Data/Shaders/default.cg", cgGLGetLatestProfile(CG_GL_FRAGMENT), "PS", 0);
cgGLLoadProgram(cg_ps);
position = cgGetNamedParameter(cg_vs, "IN.position");
color = cgGetNamedParameter(cg_vs, "IN.color");
modelViewMatrix = cgGetNamedParameter(cg_vs, "ModelViewProj");
Then I render them like this:
void render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0.0f, 25.0f, -45.0f, 0.0f, 0.0f, 0.0f, 0, 1, 0);
cgGLSetStateMatrixParameter(modelViewMatrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
cgGLBindProgram(cg_vs);
cgGLBindProgram(cg_ps);
cgGLSetParameter4f(color, 0.5f, 1.0f, 0.5f, 1.0f);
glTranslatef(0.0f,0.0f,0.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
SwapBuffers(hDC);
}
I have no idea what I need to do to make them work together. Can someone set me on the right path?
This is your life, and it's ending one minute at a time. - Fight club