** File:          starl.c
** Description:   Step 1 in setting up a coordinate
**                system to match vertices of a model
**                (outline of a star).
** Rev:           1.0
** Created:       05 August 2002
** Last Update:   05 August 2002
** Author:        Fran Soddell
** Email:         F.Soddell@bendigo.latrobe.edu.au
*/
#include <GL/glut.h>

/*
** colour management
*/
#define NUM_COLOURS 8
#define ALPHA 0.0
enum {black,
      red,green,blue,
      yellow,magenta,cyan,
      white
};
typedef GLfloat colourType[3];
colourType colour[NUM_COLOURS]={
   {0.0,0.0,0.0},
   {1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0},
   {1.0,1.0,0.0},{1.0,0.0,1.0},{0.0,1.0,1.0},
   {1.0,1.0,1.0}
};
/*
** model management
*/
enum {x,y};
typedef GLdouble vertexType [2];
int starSize=10;
vertexType star[]={
   {0.8,0.1},{1.95,1.1},{3.2,0.4},
   {2.6,1.9},{3.5,2.9},{2.2,2.7},
   {1.6,3.8},{1.3,2.6},{0.1,2.3},
   {1.1,1.6}
};

/*
**  ***********************************************************
*/
void render(vertexType * image, int numVertices, GLenum mode){
   int i;
   glBegin(mode);
      for(i=0;i<numVertices;i++)
         glVertex2d(image[i][x],image[i][y]);
   glEnd();
}
void renderView(){
   glColor3fv(colour[blue]);
   render(star,starSize,GL_LINE_LOOP);
}
void display(){
   /*
   ** Clear the window with the background colour before
   ** (re)rendering.
   */
   glClear(GL_COLOR_BUFFER_BIT);
   renderView();
   glFlush();
}
void setUpGLUT(int argc,char ** argv){
   glutInit(&argc,argv);
   glutCreateWindow("Star");
   /*
   ** Register callbacks.
   */
   glutDisplayFunc(display);
}
void initialiseGL(){
   /*
   ** Set the background colour
   ** (clear colour) to white.
   */
   glClearColor(1,1,1,ALPHA);
}
int main(int argc,char ** argv){
   setUpGLUT(argc,argv);
   initialiseGL();
   /*
   ** Display window and enter the GLUT event
   ** processing loop.
   */
   glutMainLoop();
   return 0;
}

amp;amp;amp;amp;lt;/pre&amp;amp;amp;gt;&amp;amp;amp;lt;/body&amp;amp;amp;gt;&amp;amp;amp;lt;/html&amp;amp;amp;gt;&amp;amp;lt;/pre&amp;amp;gt;&amp;amp;lt;/body&amp;amp;gt;&amp;amp;lt;/html&amp;amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</pre></body></html>