Coordinate systems.
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.
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.
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.
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.
That makes more sense now. And I did know what glVertex3f() does, I just didn't know how to use it properly.
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]
[Edited by - Oberon_Command on February 8, 2005 8:07:12 PM]
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement