PDA

View Full Version : CG and texture matrix



Bruno
04-21-2007, 02:12 PM
Hello,

I'm having a hard time understanding this in CG.
I had this line in GLSL,



projCoord = gl_TextureMatrix[0] * realPos;and converting it to CG, it should be something like this :



output.projCoord = mul( texture_matrix, realPos ) ;My question is, how do i send my texture matrix from inside the C++ code, into the shader code ??
I was tryng something like this :



float Tex_MAT[16];
glActiveTextureARB(GL_TEXTURE0_ARB);
glGetFloatv(GL_TEXTURE_MATRIX, Tex_MAT);
cgGLSetStateMatrixParameter(shadow.texture_matrix, CG_GL_TEXTURE_MATRIX,Tex_MAT);But obvioulst, i can't do this..,
Can anyone help ?

thanks,
Bruno

Komat
04-21-2007, 07:57 PM
You are mixing two approaches.

First approach is to retrieve the matrix as array of floats using the glGetFloat and set the uniform from that array using the glGLSetMatrixParameter* call.

The second approach is use the
cgGLSetStateMatrixParameter(shadow.texture_matrix, CG_GL_TEXTURE_MATRIX,CG_GL_MATRIX_IDENTITY)
which will do the glGetFloat for you.