Archived

This topic is now archived and is closed to further replies.

Xtreme

Mapping object coords to window coords

Recommended Posts

Xtreme    122
This is a bit hard to explain. As far as i know, in OGL, the coord system is like this: Y ^ | | | | -----------> X / / / Z What is the "ratio" of object coords to window coords. Example when using glTranslatef(x, y, z) if I replaced it with glTranslatef(1.0, 1.0, 1.0) where is that coord if you were representing them in windows coords?, ie, in pixels?

Share this post


Link to post
Share on other sites
Pauly    122
It all depends on how you set up your projection.

Imagine you set up an orthographic projection with the highs and lows at 0,0 640,480. When you use a window of that size there will be a direct mapping between the world coords and the screen coords.

Correct me if I''m wrong

Paul Groves
pauls opengl page

Share this post


Link to post
Share on other sites
Xtreme    122
Paul,
I meant using perspective projection not ortho.. but you are on the right track!

Is there a function or something that converts from screen to object coords or vice versa?
So, say I set up perspective proj. with the following:
.....
glViewport(0, 0, SCR_W, SCR_H);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90, (double)SCR_W/SCR_H, 1, 1000);
glMatrixMode(GL_MODELVIEW);
.....
where SCR_W & SCR_H are the screen widths and heights respectively.

Now, if I map a texture say, 512x512 pixels onto this, what is the exact ratio?

Share this post


Link to post
Share on other sites