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

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627662
• Total Posts
2978508
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 10
• 12
• 22
• 13