Jump to content
  • Advertisement
Sign in to follow this  
Chisser98

OpenGL Front face change - any help appreciated!

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi again! I'm having a really weird problem with my call to glOrtho(), in that when I call it as GL11.glOrtho(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight(), -1, 1); and then draw my quad, the quad displays as I would expect. I draw my quad while my Front Face is Counter-Clockwise (call glFrontFace(GL_CCW); when I init the OpenGL stuff). However, my problem arises when I try calling glOrtho() as GL11.glOrtho(0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), 0, -1, 1);. Here, my quad doesn't display anywhere! After some fiddling around, I found that if I changed the ordering of my vertices on my quad to make them Clockwise, it drew fine! So my question is, does anyone know why this is so? It seems like the Front Face changes unexpectedly when I change my coordinate system using the glOrtho call. I'm guessing there is some concept I'm missing when you change coordinate systems, but I'm really at a loss. btw, I'm using the LWJGL library in Java to do my OpenGL (don't know if that matters tho). Thanks for any help! I appreciate it! Cheers Jarrett

Share this post


Link to post
Share on other sites
Advertisement
But wouldn't that leave me with an area of only 2 pixels x 2 pixels? I was under the impression that glOrtho() should receive screen dimensions (i.e. the Display.getDisplayMode().getWidth() would return 800 in my case, and likewise .getHeight() returns 600).

Share this post


Link to post
Share on other sites
Quote:
Original post by dpadam450
Typically its -1, 1, -1, 1, 0, farPlane


I've never seen this used, though I'm aware it is (to the OP: it just maps the viewport coords from -1 to +1, it's nothing to do with the number of pixels). Most code I've come across uses pixel coords like the OP, and -1, +1 for the near and far planes.

If you change your y coordinates, you changing the winding of the polygon you draw. eg:


4--3 1--2
| | => | |
1--2 4--3


In the first quad, up the page is higher y. In the second, up the page is lower y. Thus while you're drawing your face in exactly the same way, it's no longer ccw, and becomes a back face.

Share this post


Link to post
Share on other sites
Ahhhh ok, that makes sense. I've recoded my 2D stuff with that in mind and it's working beautifully. Thanks for the insight sprite_hound!

cheers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!