View Full Version : Shader and texture coordinates computation

01-03-2013, 05:27 AM

I am discovering that fixed functions concerning textures are not used with shaders...
I replicated glTexGen using the orange book to test : it works.

But I have some beginner questions :

1- Are gl_EyePlane* and gl_ObjectPlane* initialized by glTexGenfv(GL_*, GL_EYE_PLANE, vector) ?
2- Do I have to send the GLenums used with GlTexEnv and GlTexGen to the shader to know how to manage the texture ?
3- And a more general question : what are the fixed functions I can use with the shaders ?

I did not find a simple answer to these questions.
So I am interested in your advices or good links to read.


01-03-2013, 03:57 PM
The general trend in shaders is away from any automatically defined variables. I would recommend loading down the lastest glsl specs (http://www.opengl.org/documentation/glsl/) and having a look at what variables are still defined. Other variables may still be defined for legacy reasons but if you are just starting stick to thoses defined in the specs. You have to load all others in uniforms or shared buffers for yourself.

01-04-2013, 02:58 AM
Hello Tonyo,

When you say "having a look at what variables are still defined" you mean the "built-in variables" excluding the "Compatibility Profile Built-In Variables" ? And the built-in variables can be intialized by OpenGl because they still exist. Did I well understand ?

I think I have to use "compatibility profile variables" because my module have to use an old opengl library... And I am also using GLSL version 110 or 120 so that it works on old graphic cards.

But here's an example of what is not clear for me :
uniform mat4 gl_ModelViewMatrix;
uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
These 2 variables are read-only built-in uniforms.
But my shader receives gl_ModelViewMatrix well initialized and gl_EyePlaneS is not initialized...

If it is not a bug in my code, how to know which variables can be initialized with fixed functions ?

01-04-2013, 04:59 AM
When you say "having a look at what variables are still defined" you mean the "built-in variables"

You still should be able to find the old glsl spec somewhere on www.opengl.org (http://www.opengl.org) to know what is valid for each version. What "version" are defining in your shaders. That may be effecting the built-in variables since on a modern graphics card there is no fixed pipeline and opengl has to emulate it by loading the variables for you.

01-04-2013, 05:43 AM
The links on the specs are on the GLSL wiki ( http://en.wikipedia.org/wiki/GLSL ).

I wrote something wrong in my previous post : the 2 variables are built-in in version 110. Therefore they may be initialized both. So there is something wrong in my code...

Thanks for your explanations.

01-09-2013, 05:51 AM
I have a small related question :
When using shaders the fixed functions are ignored.
Does it mean that the functions are not run or that the functions are run but the results deleted before calling the shaders ?
I.e. must I disable a function with a define :
#ifndef Use_Shader
or will it done automatically ?


NB : concerning the previous post the 2 variables were well defines. It was my error...