Jump to content
  • Advertisement
Sign in to follow this  
Oberon_Command

OpenGL Coordinate systems.

This topic is 4971 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 a newbie to OpenGL, and I was wondering about the coordinate system of OpenGL. Like, how many pixels does 1.0f represent? Is there an equation for this? I thought of x*SCREEN_WIDTH (or height, or depth), but it didn't seem likely, because 2.0f fits on the screen. Can somebody provide an explanation of this for me? Most OpenGL sites I found didn't really cover it.

Share this post


Link to post
Share on other sites
Advertisement
ok. when you draw a quad on teh screen, and you give it

glVertex3f()

what you are doing is telling OpenGL what your model *looks* like.

1.0f is on the local coordinate system relative to
the object you are defining.

in OpenGL you define the model, then you *translate* it to the world.

Lets say that you want to zoom in and out on the quad. FOr this to happen,
you need to translate the quad from it's local coordinate system
into the world so that you can calculate how far the camera is away from it.

I hope this makes sense.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oberon_Command
Yeah, but how many pixels(or voxels, or whatever you call a 3d pixel :) ) is an OpenGL unit?


That depends on the projection matrix. There is no set pixel size per unit. You generally don't specify positions in pixels in a 3D environment. If you are doing 2D and you want to specify screen coordinates, then you use an orthographic projection with the same dimensions as the window.
glOrtho(0, width, 0, height, -1, 1)

That will give you an orthographic projection where 1 unit = 1 pixel on screen, starting at (0,0) in the bottom left corner.

Share this post


Link to post
Share on other sites
This is definitly a confusing topic for new OpenGL users.

The best way to think of this is to imagine drawing an untextured sphere, 1 OpenGL unit in diameter, on a black background. Here is something similar I just found via google.



Now, view it yourself, and decide how large it is... Is the sphere in that image the size of a planet or the size of a marble? Size depends on what you choose to make if it. If you put a texture of the earth on it, you're going to think that it's pretty big. Real world size is a matter of the context you place your '1 OpenGL unit' in.

Share this post


Link to post
Share on other sites
Ooohhh...

I get it now. I think this question (and answer) should be posted in an OpenGL FAQ or something since I couldn't really find any of that stuff anywhere...

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!