Jump to content
  • Advertisement
Sign in to follow this  
Cromulent

Very irrating and simple OpenGL problem (GL_QUADS)

This topic is 3971 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

Okay I have a very simple OpenGL problem but it is very annoying. I have drawn what I assume to be a square (all the co-ordinates make it a square if you plot it on a graph) yet OpenGL seems to render it as a rectangle. At first I thought it was because I was using a widescreen resolution so I changed it to a standard aspect ratio but it still renders as a square. I'm using gluOrtho2D if that makes any difference. Do I need to account for anything in my co-ordinates at all? Because this is a really irrating problem. Even the NeHe tutorial (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02) says that the co-ordinates make a square yet when I render I get a rectangle. What is going on?

Share this post


Link to post
Share on other sites
Advertisement
Yes. The coordinates you send get multiplied by the modelview matrix
and the projection matrix.
Posting some code would help...

Share this post


Link to post
Share on other sites
Does the view volume specified by invoking gluOrtho2D match the proportions of the window/screen you render into? Is the glViewport properly set-up?

EDIT: E.g. the view volume can be computed as

horiz = 0.5f * columns / ( resolution * scale );
vert = 0.5f * rows / ( resolution * scale );
gluOrtho2D( -horiz, +horiz, -vert, +vert );
where (columns, rows) denotes the size of the window/screen in pixels, resolution denotes the video resolution, and scale denotes just a scale factor (e.g. 1/10 if you want to have the image a tenth of the real world size). However, the important part is that horiz is proportional to columns, and vert is proportional to rows.

Share this post


Link to post
Share on other sites
As is always the case with things like this it appears that I have messed up on the viewport. Thanks for the quick responses. I'm going to re-read some of the red book I think as I have obviously missed out on some important stuff :(.

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!