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

## 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 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 on other sites
Oh, I see...

That makes more sense now. And I did know what glVertex3f() does, I just didn't know how to use it properly.

##### Share on other sites
One other thing: how many pixels(or voxels, or whatever you call a 3d pixel :) ) is an OpenGL unit?

[Edited by - Oberon_Command on February 8, 2005 8:07:12 PM]

##### Share on other sites
Quote:
 Original post by Oberon_CommandYeah, 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 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 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...

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 13
• 10
• ### Forum Statistics

• Total Topics
632580
• Total Posts
3007190

×