Sign in to follow this  
Oberon_Command

OpenGL Coordinate systems.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this