You are right, some of the code is posted below.
In the main:
void display(void) {
glClearColor(0.0, 0.2, 0.4, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(eye.x, eye.y, eye.z, eye.x + camera_forward.x,
eye.y + camera_forward.y, eye.z + camera_forward.z, 0, 1, 0);
shader.bind();
/* Draw every shape in the scene */
scene.draw_shapes();
shader.unbind();
/* Random sphere */
glTranslatef(0,10,0);
glutSolidSphere(4, 32, 32);
glFlush();
glutSwapBuffers();
}
/* Initialize polygons, light and enables */
void init(void) {
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
/* Setup lighting variables */
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
float ambientColor[] = { 0.0, 0.0, 0.0, 0.0 };
float diffuseColor[] = { 1.0, 1.0, 1.0, 0.0 };
float specularColor[] = { 0.2, 0.2, 0.2, 0.0 };
float position[] = { -200.0, 400.0, 200.0, 1.0 };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularColor);
glLightfv(GL_LIGHT0, GL_POSITION, position);
old_time = 0.0;
/* Initialize bullit settings */
bullit.set_mass(0.2);
bullit.set_velocity(10,15,0);
bullit.set_acceleration(0,-10,0);
bullit.set_drag(0.9);
bullit.set_position(-80,50,0);
scene.add_shape(&bullit);
scene.add_shape(&ground);
shader.init("GLSL/shader.vert", "GLSL/shader.frag");
}
This is the draw function from the scene in scene.cpp:
/* Draw all shapes */
void Scene::draw_shapes() {
for(int i = 0; i < shapes.size(); i++) {
if(shapes[i]->get_type() == SPHERE) {
Sphere sphere = *((Sphere *) shapes[i]);
sphere.draw();
}
else if(shapes[i]->get_type() == PLANE) {
Plane plane = *((Plane *) shapes[i]);
plane.draw();
}
}
}
And this is the draw function in sphere.cpp:
/* Draw the sphere */
void Sphere::draw() {
glColor3f(color.x, color.y, color.z);
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glutSolidSphere(radius, 32, 32);
glPopMatrix();
}