i draw a cube using cg,the translation does not take effect .i want to translate it using glTranslate(),however it doesn’t affect the WorldViewProj matrix in the Cg Vertex Shader.Now ,i can not control the position of my cube ,can someone tell me how to correct my code to let the triangle translate?
OpenGL Code
cgGLBindProgram(vertexProgram1);
cgGLEnableProfile(cgProfile);
errcheck();
…
glTranslatef(0,0,-5);
glBegin(GL_QUADS);
glVertex3f(1,0,0);
glVertex3f(2,0,0);
glVertex3f(3,0,0);
glVertex3f(4,0,0);
glEnd();
cg code
uniform float4x4 WorldViewProj : state.matrix.mvp;
;
void main_v(float4 pos:POSITION,
out float4 opos:POSITION,
out float4 color:COLOR,
uniform sampler2D tex
)
{
…
…
opos=mul(WorldViewProj,pos);
}