OpenGL Coordinate System

Started by
3 comments, last by Brother Bob 19 years, 6 months ago
Do you know how many units the screen is in total? For example, in lesson2, they have: glTranslatef(-1.5f,0.0f,-6.0f); to move to the left of the screen to draw the triangle.. how far left can you move? how far right? etc. we can't translate it 10000000 units left can we? I've searched for this question on google but couldn't find it
Advertisement
Yes you can. How far you can see left or right is dependent on the viewpoint which is set useing gluPerspective(45,640/640,1,100);
Your thinking about the screen the wrong way, consider this: If you think about the movies then a camera shows you one part of the movie set, but actors can be anywhere on the set at any time. If you move the camera round your view changes and so do the "edges" of the picture. If I asked you "how many feet does this actor A have to move to be at the edge of the screen?" what would you say? It depends on the cameras zoom, how far away the camera is from the actor, if the camera is even pointing at the actor to start with, and if its a widescreen camera or a normal one - see what i'm getting at? You can transform objects in your world to any co-ordinates you like, if your camera points there then you'll see the object, if your camera doesn't then you won't. Thats the reason you couldn't find it on google - because there is not an answer.

Quote:Original post by justified
how far left can you move? how far right? etc. we can't translate it 10000000 units left can we?


The only limit is how far you can move something is the limit of a floating point number. I have no idea what it is but it'd be in the billions, basically so large that you can think of it as infinite!

The command bjwbell listed will setup the openGL camera, and you can use gluLookAt() (i think its that) to position it pretty easily. Go look up the camera tutorials on gametutorials.com (they have a nice progression thats easy to understand) and you'll get the idea!
minimum: (-2^32)-1 units
maximum: (2^32)-1 units

That is the case if you're using glVertex3d (signed doubles) to specify the coordinates.

The min/max is (-2^16)-1/(2^16)-1 if you're using signed integers by glVertex3i.

I currently have forgotting how many bits of a float that is not decimals, but it should be high enough for must users by using glVertex3f.

And also think of that the (2^64)-1 is the maximum length of EACH axis (x, y and z). The 3 together will provide (2^64)*(2^64)*(2^64) - 3 units, so I hope that's enough room for you :D
Killers don't end up in jailThey end up on a high-score!
Quote:Original post by nife
minimum: (-2^32)-1 units
maximum: (2^32)-1 units

That is the case if you're using glVertex3d (signed doubles) to specify the coordinates.

A double in OpenGL is required to have at least 64 bits of precision. The range of a common double precision float is about +-10308, or +-21024 if you want base-2.

Quote:Original post by nife
The min/max is (-2^16)-1/(2^16)-1 if you're using signed integers by glVertex3i.

That would be true for a 17-bit singed integer, however, 32 bits is the smallest required size for a singed integer in OpenGL, so at least [-231, 231-1] is the range for GLint.

Quote:Original post by nife
And also think of that the (2^64)-1 is the maximum length of EACH axis (x, y and z). The 3 together will provide (2^64)*(2^64)*(2^64) - 3 units, so I hope that's enough room for you :D

There are no maximum lengths for any axes. If anything, they are, in practice, limited by the precision of the datatype used, what precision they give at what magnitudes, and if that precision is enough for your particular application, and so you can't really say that this or that is a limit.

But I agree that a float is generally enough, when used wisely, for most common situations though.

This topic is closed to new replies.

Advertisement