PDA

View Full Version : Reverse quad - how?



marce
08-19-2009, 05:25 PM
I have two quads. The second one is just below the first one.
I have binded a texture on them.

I would like the second quad (or texture) upside-down and reversed. I have succeeded in getting it upside-down, but not reversed.


// First quad
gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(topLeft, 1.0f, 0.0f);
gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(topRight, 1.0f, 0);
gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(bottomRight, -1.0f, 0);
gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(bottomLeft, -1.0f, 0.0f);

// gl.glRotated(180, 180, 0, 0); // doesn´t work

// Second quad
gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(topLeft, -1.0f, 0.0f);
gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(topRight, -1.0f, 0);
gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(bottomRight, -3.0f, 0);
gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(bottomLeft, -3.0f, 0.0f);

Now the texture on the second quad is drawn upside-down, but how do I reverse the texture?

scratt
08-19-2009, 07:49 PM
Well you are using glRotate incorrectly for a start.
http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rotate.html
The first parameter is an angle (as you suspect), but the other values refer to x,y,z vectors.

Try gl.glRotated(180,0,0,1.0), and use two identical quads.

The other way, is what you seem to be trying, and that is to alter the Texture Coords, or vertex coords to affect your geometry. It's fairly trivial, and to flip or rotate textures you can simply swap x and y values in the texture coords. Altering the vertex coords will give you different results, but you may not understand them as it all depends on the "winding" of the polygon you make...

I would recommend you try and get hold of a copy of The Red Book and give it a thorough read. Or perhaps work through some of NeHe's tutorials on the web.

marce
08-20-2009, 03:30 AM
EDIT: I solved it now. :) Thanks!