Unit?

I’m using gluLookAt to pan a 2D image (textured). What are the units of the parameters (eyeX for example)? How can I construct a relation between these units and pixels?

thanks,

There are no units in OpenGL. If you place your viewpoint at (1, 0, 0), you have placed the viewpoint one unit away from the origin along the positive X-axis. Whether this unit, in your scene, correspond to one meter, one yard, one light year, one micrometer, one inch, one foot, one astronomical unit, or three apples and a banana, is up to you to decide.

And there is no relation betwee these units and a pixel. All coordinates in OpenGL are resolution independent.

You can, of course, set the matrices, so that a unit has some relation to pixel coordinates, but that is just in your eyes, and nothing OpenGL cares about. Here’s an example.

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.5, windowWidth + 0.5, 0.5, windowHeight + 0.5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

This piece of code will set the matrices so that you can, using for example glVertex, set a vertex in window coordinates. You then have a 1:1 correspondence between units and pixels. But that’s just in your eyes. In OpenGL’s eyes, these are just regular projection and modelview matrices, and are not treated special in any way.

lol, Bob: an apple and a banana

A graphics engineer I once knew used to refer to these units as a “bananas per furlong”, I think he was probably closest to the true default graphics unit.