PDA

View Full Version : example in redbook named planet.c requires aux.h?



jenny88
05-11-2011, 07:28 AM
I am trying to compile this to do some testing so I can understand it but it requires some file aux.h?

This is the code below

============================================
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include "aux.h"

static int year = 0, day = 0;

void dayAdd (void)
{
day = (day + 10) % 360;
}

void daySubtract (void)
{
day = (day - 10) % 360;
}

void yearAdd (void)
{
year = (year + 5) % 360;
}

void yearSubtract (void)
{
year = (year - 5) % 360;
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);

glColor3f (1.0, 1.0, 1.0);
glPushMatrix();
/* draw sun */
auxWireSphere(1.0);
/* draw smaller planet */
glRotatef ((GLfloat) year, 0.0, 1.0, 0.0);
glTranslatef (2.0, 0.0, 0.0);
glRotatef ((GLfloat) day, 0.0, 1.0, 0.0);
auxWireSphere(0.2);
glPopMatrix();
glFlush();
}

void myinit (void) {
glShadeModel (GL_FLAT);
}

void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef (0.0, 0.0, -5.0);
}

/* Main Loop
* Open window with initial window size, title bar,
* RGBA display mode, and handle input events.
*/
int main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 500, 500);
auxInitWindow (argv[0]);
myinit ();
auxKeyFunc (AUX_LEFT, yearSubtract);
auxKeyFunc (AUX_RIGHT, yearAdd);
auxKeyFunc (AUX_UP, dayAdd);
auxKeyFunc (AUX_DOWN, daySubtract);
auxReshapeFunc (myReshape);
auxMainLoop(display);
}
================================================= ====

ZbuffeR
05-11-2011, 09:13 AM
aux.h is more than old and deprecated.
You can use FreeGlut instead for example.