You are correct I did need to swap the two lines. I put together a simple program, for an example:
Originally posted by Jambolo:
[b] nexusone, you need to swap these two lines.
[This message has been edited by Jambolo (edited 03-28-2002).][/b]
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
static int hour = 0, day = 0, week = 0;
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
}
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glTranslatef(0, 0, -10);
glColor3f( 0.0, 0.0, 1.0);
glPushMatrix();
glRotatef(hour, 0, 1, 0);
glRotatef( 90, 1, 0, 0);
glutWireSphere( 2, 16, 8);
glPopMatrix();
glTranslatef(0, 0, -10);
glPushMatrix();
glRotatef(week, 0, 1, 0);
glRotatef( 90, 1, 0, 0);
glTranslatef( 4, 0, 0);
glRotatef(day, 0, 0, 1);
glColor3f( 0.5, 0.5, 0.5);
glutWireSphere(0.5, 16, 8);
glPopMatrix();
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(60.0,(GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
}
void keyboard (unsigned char key, int x, int y)
{
switch (key) {
case ‘D’:
day = day + 15;
if (day > 360) day = 0;
glutPostRedisplay();
break;
case ‘W’:
week = week + 10;
if (week > 360) week = 0;
glutPostRedisplay();
break;
case ‘H’:
hour = hour + 15;
if (hour > 360) hour = 0;
glutPostRedisplay();
break;
case 27:
exit(0);
break;
default:
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (10, 10);
glutCreateWindow (argv[0]);
glutSetWindowTitle(“Glutplanets”);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
[This message has been edited by nexusone (edited 03-28-2002).]