Results 1 to 3 of 3

Thread: Reverse quad - how?

  1. #1
    Member Newbie
    Join Date
    Jul 2009
    Posts
    33

    Reverse quad - how?

    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.

    Code :
    // 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?

  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: Reverse quad - how?

    Well you are using glRotate incorrectly for a start.
    http://www.opengl.org/documentation/...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.

  3. #3
    Member Newbie
    Join Date
    Jul 2009
    Posts
    33

    Re: Reverse quad - how?

    EDIT: I solved it now. Thanks!

Similar Threads

  1. Replies: 1
    Last Post: 07-04-2013, 01:42 AM
  2. Reverse glScissor ?
    By imported_raziza in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-13-2012, 07:56 AM
  3. Reverse rotation
    By Oldschool in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-20-2009, 04:53 AM
  4. Stereo Reverse In Quad Buffer Problem
    By XaVinci in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 08-18-2004, 01:27 PM
  5. How to reverse normals when using AUTO_NORMAL
    By ahbear in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-25-2004, 11:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean