Mapping object coords to window coords
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?
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
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
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?
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement