Sign in to follow this  
doutmost

Question about glTranslate() ??

Recommended Posts

glTranslatef ( float x, float y, float z ) here, what is the measurement for x, y, z, I thought, x,y,z, they are pixels of the monitor, but it seems not. thanks for answer.

Share this post


Link to post
Share on other sites
No. They are units in the world.

glTranslatef(0,0,-50) will put you in the middle of the screen and 50 units back. If you don't even understand that much about OpenGL yet, maybe you should look up the red book online.

Share this post


Link to post
Share on other sites
Quote:
Original post by Vampyre_Dark
No. They are units in the world.

glTranslatef(0,0,-50) will put you in the middle of the screen and 50 units back. If you don't even understand that much about OpenGL yet, maybe you should look up the red book online.


That's pretty much it...Though if you really wanted something like you described, you could do it with glOrtho.

Share this post


Link to post
Share on other sites
it depends on the viewport how much you translate.You probably don't even see the object in the place you've translated it.
If you want to use windows coordinates try this:

glMatrixMode(GL_PROJECTION);
glOrtho(0,width,height,0,-1.0f,1.0f);
/*well..why not 0 and then height this is because for windows
the up is down ;eg.(0,0)is in the up left corner*/

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();//center the axes into the origin OF THE SCREEN
/*-1.0f,1.0f almost don't matter-you don't have depth into the screen*/


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