Vertex SHaders

Hi all,

i have this problems, with my vertex shader I want the same output of standard OpenGL, but it’s very hard write all OpenGL pipeline.

Example:

if I have set in my c/c++ program this


glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,f);

but I use many standard OpenGL funcs.

How can my vertex program run this code? Do I must write my code?
Is there a way easier?

Thanks and execuse me for my Englsih.

Hi,

3DLabs once proposed a free tool, which generated shader code equivalent to a given fixed function state. I could not find it anymore (broken link), but it is/was named “3DLabs ShaderGen - Fixed Functionality Shader Generation Tool”, it may be helpful.

Cheers,
Nicolas.

Edit. shadergen has been mirrored here

ok thanks but there is another way? I must change only this


vec4 col;

gl_Position = gl_Vertex; //I dont need World and View matrices
col = gl_Color;
col[3] *= 0.5;
gl_Color = col;

I’m not sure to understand what you mean.

Do you want to only have a vertex shader, using the fixed function pipeline for fragment processing ?

Does your vertex shader only do the operations you mentionned, or is it a simple example ?

A better syntax should be (untested)(I’m not familiar with vertex shader-only programs) :


void main()
{
  gl_Position = gl_Vertex;
  
  vec4 color = gl_Color;
  color.z *= 0.5;
  // to pass color to fixed-function fragment shader
  gl_FrontColor = color;
  gl_BackColor = color;   // if needed ?
}

Did you have a look GLSL specification ? The “Built-in variables” chapter could give you all you need.

HTH,
Nicolas.

ok thanks i solved with 3DLabs, but now I have a new problem


float colors[20]

i = int(VertexColor.r * 20.0);
color = vec4(colors[i],colors[i+1],colors[i+2],VertexColor.a);
color = texel * color;

…and it doesnt work. ow can i fix it?

What does glGetShaderInfoLog return?

you dont worry i solved with sampler1d and 1 texture 1d. However it shows messages like you can use only texture coordinates or only loop etc etc. If you want more info I can replicate the bug. Thanks again

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