PDA

View Full Version : texturing problem



powerpad
03-30-2005, 07:10 AM
I want to texture a simple quad with a texture loaded from an img (in .Net with C#)

1. I load the bitmap
2. I call

Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, 3, this.iTexWidth, this.iTexWidth, 0, Gl.GL_BGR_EXT, Gl.GL_UNSIGNED_BYTE, this.tex2.getImageData());3. and I set the quad with

Gl.glBegin(Gl.GL_QUADS);
Gl.glTexCoord2f(0.0f, 1.0f);
Gl.glVertex3f(0.0f, 0.0f, 0.0f);
Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(5.0f, 0.0f, 0.0f);
Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(5.0f, 5.0f, 0.0f);

Gl.glTexCoord2f(0.0f, 0.0f);
Gl.glVertex3f(0.0f, 5.0f, 0.0f);

Gl.glEnd(); but I get a quad with a mirrored texture - which is not the intented result ... has anyone suggestions here ....
tnx

dvm
03-30-2005, 07:32 AM
just change glTexCoord.
(0, 0) should go the bottom left vertex
and (1, 1) to top right. Just play a bit with the other two and you should figure it out.
Texture Coordinates define how the image is applied to the object.

powerpad
03-30-2005, 07:46 AM
I flipped them and this help but the other reason why I asked this was, what about glDrawPixels()

one can't assign texture coordinates to this function only "manual" flipping.

And I tried code from nehe's tutorial on texture mapping and even this has the same problem
- thanks for the fast answer