Invalid enumerant?

Hello all together,

I still have a problem with projected lighting. I want to project a light map from the light’s point of view. Therefore I use my light map in texture unit 1 like a camera and set it up in my application like this:

   glActiveTexture(GL_TEXTURE1);

   glMatrixMode(GL_TEXTURE1);
   glLoadIdentity();
   // scale and bias to coords from 0 to 1
   glTranslatef(0.5,0.5,0.5);
   glScalef(0.5,0.5,0.5);
   gluPerspective(90.0,1.0,0.01,100.0);
   gluLookAt(lightPos[0], lightPos[1], lightPos[2],0.0,0.0,0.0,0.0,1.0,0.0);
      
   tex_light->bindTexture();
   ...   

Everytime I want to access gl_TextureMatrix[1] in my vertex shader, I get the OpenGL error: invalid enumerant…

What am I doing wrong? Does anyone know where this error comes from? Or is there a better way to get the “ModelViewProjectionMatrix” for my light source position?

Thank you very much
greetings
Simon

glMatrixMode accepts only GL_TEXTURE, not GL_TEXTURE1. You selected the texure unit already with glActiveTexture. The glMatrixMode(GL_TEXTURE) switches to the appropriate matrix.

ok, that was really the thing that caused the error, but unfortunately it was not the only problem:

If I compile my vertex shader without manipulating the Texture Matrix in my app. everything does fine. But if I include the lines
gluPerspective(90.0,1.0,0.01,100.0);
gluLookAt(0.0, 3.0, 3.0,0.0,0.0,0.0,0.0,1.0,0.0);
for my Texture Matrix, I can’t compile my vertex shader anymore.

In my shader I have only the following lines:

 
projPos = gl_TextureMatrix[1] * gl_Vertex ;
gl_TexCoord[0]  = gl_MultiTexCoord0;
gl_Position = ftransform(); 

I do not understand why this doesn’t work…

What do you mean with “can’t compile”? Do you mean that the compile call fails if you call gluPerspective and gluLookAt prior to compiling the vertex shader?

What hardware are you using btw?

thank you for this notice, this has been my problem. I called gluPersepctive and gluLookAt before compiling the shader and so the compile failed. Now I changed the order and it works :slight_smile:

btw: Quadro FX 1000

thx
Simon

Compiling and linking GLSL shaders has nothing to do with when you change your matrices. That’s why Humus asked.
“Can’t compile” with GLSL shaders means that you either had no context current and all OpenGL commands went to the bit-heaven or that you had an error in the shader source and the info log of the program should contain sufficient text to indicate what the error was.
For future errors of these kind, give the complete shader source of vertex and fragment shaders.
It’s your responsibility to make sure that the initialization of your program is done in the correct order. Always remember that OpenGL is a state machine.
For example, you call glActiveTexture(GL_TEXTURE1) to set the texture matrix, this switches the texture unit, following calls to glTexImage or glBindTexture will go to texture unit 1. Did you intend that?

yes I considered that, but sometimes it’s a little bit difficult for me to keep track of that, because on the one hand I am currently working with GLSL in GLUT and on the other hand I try to get my shaders working in SGI Performer and therefore I constantly have to switch and my brain starts smoking :slight_smile:

Thank you both for your help
Simon

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.