if you are using orthographic projection then glulookat probably won’t work (i had this same problem when i started using GL)
try putting this (or a variant) in your glResize() function after glViewport(), if you don’t have it…
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (double) width / height, 1, 4096);
where width & height are the width & height of your gl window.
then, in your rendering function:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(-4, 2, 2, 0, 0, 0, 0, 1, 0);
then
glutSolidCube(2.0f); or whatever you are gonna draw
You then do…
glLoadIdentity(); glTranslatef(12.0f,0.0f,-24.0f);
The loadIdentity is basically going to reset what you set in gluLookAt, so I’m not sure why it would work without the gluLookAt, but won’t work with it.
Try using glPushMatrix, glPopMatrix instead of resetting the matrix every time.
For instance
glPushMatrix();
glTranslatef(12.0f,0.0f,-24.0f);
// draw your scene
glPopMatrix();
You don’t show how you setup your projection matrix so I’m not sure if that will keep your object in the scene or not.
also, if you are using gluLookAt to look directly into the up vector that you specify, you will get a blank screen. [another pull-my-hair-out-because-this-should-be-working-but-it-isn’t GL nightmare]. but i guess its all part of the experience
Yes, you must check the rest of the code. you need to call glEnd(); function and SwapBuffer() since you are using double buffers. Also the object is small in size and placed at (12, 0, -24) and camra at (0, 0, -10) and focused at (0,0,0). This suggest that (1) object is ou of feild-of-vision becasue 12-units translation along x-axis or (2) it is in the scene but since it is very far away from the camer (at a distance of “14”- units along z-axis) so its not visible.
Also try focussing your camer at the object by passing (12, 0, -24) as the focus point… If the object is there you’ll see it.
In order to make object more visible uyou can also use glPointSize(); funcion.
Well…hope any of these things work