void drawOrientedWireSphere(float r, const Matrix4& basis) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); glMultMatrix(basis); drawWireSphere(r); glPopMatrix(); }
void drawSphereNormals() { //Draw the sphere. drawWireSphere(); //Draw the normals. glVertexPointer(3, GL_FLOAT, 0, sphereNormalsV); glColorPointer(3, GL_FLOAT, 0, sphereNormalsC); for (int i = 0; i < SECTIONS * SECTIONS; i++) glDrawArrays(GL_LINES, i * 2, 3); }
void display() { //Clear buffers and set the transformation matrix to the identity matrix. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //Increment global angle variables (take FPS into account). a += 90 / FPS; b += 90 / FPS; c += 90 / FPS; d += 90 / FPS; a %= 360; b %= 360; c %= 360; d %= 360; //Draw scene depending on program state. switch (state) { case 1: rotateY(a); rotateZ(a); drawWireSphere(); break; case 2: rotateX(20); rotateY(b); drawWireCone(); break; case 3: rotateY(a); rotateZ(a); drawSphereNormals(); break; case 4: rotateY(d); drawShadedSphere(); break; case 5: drawAnimation(); break; } //Swap buffers. SDL_GL_SwapBuffers(); }
void drawAnimation() { //Rotate the SphereNormals display in the x-axis. scale(0.35, 0.35, 0.35); rotateX(a); rotateZ(a); translate(0, 0, 4); drawSphereNormals(); glLoadIdentity(); //Rotate the WireCone drawing in the y-axis. scale(0.35, 0.35, 0.35); rotateY(b); rotateX(b); translate(4, 0, 0); drawWireCone(); glLoadIdentity(); //Rotate the WireSphere drawing the the z-axis. scale(0.35, 0.35, 0.35); rotateZ(c); rotateY(c); translate(0, 4, 0); drawWireSphere(); glLoadIdentity(); //Rotate the ShadedSphere drawing (on the spot) through the x-, y- and z- axis. scale(0.35, 0.35, 0.35); rotateY(d); drawShadedSphere(); glLoadIdentity(); //Reset the camera to orthographic. glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2, 2, -2, 2, 2, -2); glMatrixMode(GL_MODELVIEW); }