Ok, I am confused with how objects and camera gets assigned rotations and translations. I searched everywhere and read lots of tutorials but things still dont quite make sence to me.
I know there is just 1 matrix, the current matrix, but how do you tell opengl to spin one thing translate something else and move camera? I put glLoadIdentity() in between my objects but glLoadIdentity() seems to just make things dissapear.
The following code works fine but the sphere does not rotate, it is in some strange orbit, like it was effected by my camera translation.
Stars rotate with camera fine, terran generation works fine, but sphere is not rotating like i want. I tried that push and pop stuff but seemed to have no effect.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
// Move camera and draw stars
glRotatef(rotate_view, 0.0f, 1.0f, 0.0f);
DrawStars(); // Stars just follow translation
glTranslatef(x_cam, y_cam, z_cam);
// Rotating and drawing a sphere
RotateObject += 0.1f;
glRotatef(RotateObject, 0.0f, 1.0f, 0.0f);
DrawSphere(2.0f, 0.0f, 0.5f, 4.0f, 1);
// Create the terrain
glTranslatef(0.0f, B, A);
CreateTerrain();
Can someone explain what i am doing wrong or a good expanation on how openGL can know what to trans + rotate and how. Keep in mind I am very new to openGL.
Thanx in advance!