Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


OpenGL Coordinates in OpenGL

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

I am new to OpenGL and a certain part is confusing me. I am used to plotting images to a screen based on their x and y coordinates. OpenGL seems to be different. It seems to plot images based on a single digit number. Someone told me I could use the basic coordinate system with the glOrtho function, yet it doesn't seem to work for me. I plot "glVertex2f(.5, .5); glVertex2f(.5, 1); glVertex2f(1, 1); glVertex2f(1, .5);" and the sqaure shows up at the right end of the screen, which is way more than .5 or 1 pixel. Can someone explain OpenGL's plotting system or show me how to manipulate OpenGL to use the coordinate system? If possible, can you point me to some sample source codes that deal with this issue. Thank you. [edited by - Chocoboko on September 2, 2002 11:20:54 PM]

Share this post

Link to post
Share on other sites
Hi,the answer to your question is not so simple,but here it is.The problem is the coordinate system OpenGL uses.Check your Resize function and you will see that code:


That tells OpenGL that the current matrix mode is GL_PROJECTION and you can modify the projection matrix.By then calling glLoadIdentiy you tell OpenGL to equal the projection matrix with the identity matrix(the projection matrix is now clear).After that you can use one of the OpenGL functions to set a new projection matrix or do that yourself(ex3mly hard).There are 2 types of projection states:the orthographic and the perspective.The first one is set with glOrtho and the second with gluPerspective or with glFrustum.
If you are using glOrtho to set your projection matrix,OpenGL uses the same coordinate system as Windows.Here is a quick example with orhographic projection:

RECT rcClientRect;



This will draw a green quad that covers all of your client area.

If you are using perspective projection you will use the Cartesian(don''t know if the name is right) coordinate system.It looks something like that:


Yeah,that''s look very familiar from the math lessons with that nasty,ugly teacher.The point O is in the center of your screen until you change the modelview matrix.So here is a example with perspective projection:



This will draw a rect at the center of your screen.Well that''s all.If you have questions write on Mihail121@Yahoo.co.uk

The pain is coming...this sommer!!!

Share this post

Link to post
Share on other sites

  • 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!