- // OpenGL header files
- #include <windows.h>
- #include <gl/gl.h>
- #include <GL/glut.h>
- // Global variables
- float g_spin = 0.0;
- /** This is the GLUT display function. */
- void display()
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(-0.5, 0, 0);
- glRotatef(g_spin += 0.01, 0.0f, 0.0f, 1.0f);
- glBegin(GL_QUADS);
- glVertex3f(-0.25, -0.25, 0.0);
- glVertex3f(0.25, -0.25, 0.0);
- glVertex3f(0.25, 0.25, 0.0);
- glVertex3f(-0.25, 0.25, 0.0);
- glEnd();
- glutSwapBuffers();
- glFlush();
- }
- /** This function is the program entry point. */
- int main(int argc, char** argv)
- {
- // Initialize the GLUT window and define callback functions
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(400, 400);
- glutCreateWindow("quad");
- glutDisplayFunc(display);
- glutIdleFunc(display);
- // This starts everything related to GLUT...
- glutMainLoop();
- return 0;
- }