So I'm fairly new to OpenGL and texturing. I have a flat plane like primitive (2 triangles) that I'm trying to map an image on to. I've done this 2 ways. The first way I wrote a Fragment shader that uses sampler2d uniform, and calles texture2d to map the pixel of the image to the primitive, and this works fine and looks like this:
Correct
THe second approach I took i used glEnable and didn't use any shaders, and the image looked like this:
Wrong
A lot of this code is a work project so I can't post a lot of it but I'm basically rendering like this:
void draw()
{
glColor4f(0.0, 1.0, 0.0, 1.0)
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEX_COORD_ARRAY);
glBindTexture(GL_TEXTURE_2D, id);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glNormalPointer(GL_FLOAT, 0, normals);
glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
// then draw arrays....
// disable client states
}
I know the green is coming from my glColor call but I guess I just wanna understand what's going on behind the scenes here? I would think if I call glColor before I render that none of the image would would show up because its coloring everything green. This makes total sense from the shader standpoint but I don;t get this approach. How would I make it work using the old method without shaders as I did with the shader?