I've got a skybox working with OpenGL, but I'm having a strange problem. When I set the camera looking front, back, left or right the skybox draws properly. If I set the camera looking straight up or down however, the skybox isn't drawn. I've got a feeling this is because OpenGL can't decide how to orient the camera, but I'm not sure.
The code I'm using to set the camera is:
gluLookAt(
0.0f, 0.0f, 0.0f, // Position
0.0f, -1.0f, 0.0f, // Look At
0.0f, 1.0f, 0.0f); // Up
Given the the 'up' and 'look at' vectors are opposites, I guess there could be any number of ways of orienting the camera.. possibly.
Yes - Up defines the "upwards" direction from the perspective of the viewer (camera). You could rotate the Up vector (so long as it remains perpendicular to Look-at) to accomplish a "roll" effect (in the traditional pitch/yaw/roll sense of the word).
Yes - Up defines the "upwards" direction from the perspective of the viewer (camera). You could rotate the Up vector (so long as it remains perpendicular to Look-at) to accomplish a "roll" effect (in the traditional pitch/yaw/roll sense of the word).
He is using gluLookAt, which will orthonormalized his camera axes for him in the generated matrix, however, (0, -1, 0) x (0, 1, 0) is obviously (0, 0, 0). So yes, the Up vector supplied to gluLookAt cannot be parallel to the vector formed by (lookAt - eyePosition).
Ah, good to know. I haven't touched OpenGL in many years, and my freshest memory of building view matrices is from doing it by hand where you need to ensure the vectors are normalized and orthogonal :-)