#include <GL/gl.h>
#include <GL/glu.h>
#include "aux.h"
/* GL_SMOOTH is actually the default shading model. */
void myinit (void)
{
glShadeModel (GL_SMOOTH);
}
void cube(void)
{
glBegin (GL_QUADS);
glColor3f (1.0, 0.0, 0.0); glVertex3f (5.0, 0.0, 0.0);
glColor3f (1.0, 1.0, 0.0); glVertex3f (5.0, 5.0, 0.0);
glColor3f (0.0, 1.0, 0.0); glVertex3f (0.0, 5.0, 0.0);
glColor3f (0.0, 0.0, 0.0); glVertex3f (0.0, 0.0,0.0);
glEnd ();
glBegin (GL_QUADS);
glColor3f (1.0, 0.0, 0.0); glVertex3f (5.0, 0.0, 0.0);
glColor3f (1.0, 0.0, 1.0); glVertex3f (5.0, 0.0, 5.0);
glColor3f (0.0, 0.0, 1.0); glVertex3f (0.0, 0.0, 5.0);
glColor3f (0.0, 0.0, 0.0); glVertex3f (0.0, 0.0,0.0);
glEnd ();
glBegin (GL_QUADS);
glColor3f (0.0, 1.0, 0.0); glVertex3f (0.0, 5.0, 0.0);
glColor3f (0.0, 1.0, 1.0); glVertex3f (0.0, 5.0, 5.0);
glColor3f (0.0, 0.0, 1.0); glVertex3f (0.0, 0.0, 5.0);
glColor3f (0.0, 0.0, 0.0); glVertex3f (0.0, 0.0,0.0);
glEnd ();
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.0); glVertex3f(0.0,0.0,0.0); glVertex3f(10.0,0.0,0.0);
glEnd();
glBegin(GL_LINES);
glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,10.0,0.0);
glEnd();
glBegin(GL_LINES);
glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,0.0,10.0);
glEnd();
}
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
cube ();
glFlush ();
}
void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glLoadIdentity();
glRotatef(-30.0,1.0,0.0,0.0);
glRotatef(45.0,0.0,1.0,0.0);
glOrtho(-8.0,8.0, -8.0, 8.0 , -8.0, 8.0);
}
int main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 750, 750);
auxInitWindow (argv[0]);
glClearColor(1.0,1.0,1.0,0.0);
myinit();
auxReshapeFunc (myReshape);
auxMainLoop(display);
}