2

I added a vertex shader to this example:

void main()
{   
    gl_Position = ftransform();
}   

then I get this image:

enter image description here

What am I doing wrong here?

Community
  • 1
  • 1
new_perl
  • 7,345
  • 11
  • 42
  • 72

1 Answers1

6

For texture mapping using a vertex shader you will also need to pass the texture coordinates as well as the vertex positions to the fragment shader. Examples, including the one below, can be found here

void main()
{
    // Transforming The Vertex
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

    // Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader
    texture_coordinate = vec2(gl_MultiTexCoord0);
}
StuGrey
  • 1,479
  • 9
  • 20
  • Blech! Use swizzle notation. I like gl_MultiTexCoord0.xy, because I don't believe in .st; it doesn't convey meaning to me. uv would be appropriate, but GLSL doesn't support it. –  Jul 18 '12 at 14:23