clip.c
contents ::
  Makefile
  clip.c

/***************
 * the next thing to do is 
 * build a solar system like on page 144
 * 
 ****************/

#include <GL/glut.h>
#include <stdlib.h>

void init (){
  glClearColor(0,0,0,0);
  glShadeModel(GL_FLAT);
}

void display(){
  GLdouble eqn[4] = { 0,1,0,0 };
  GLdouble eqn2[4] = { 1,0,0,0 };
  
  glClear(GL_COLOR_BUFFER_BIT);
  glColor3f(1,1,1);
  glPushMatrix();
  glTranslatef(0,0,-5);

  /* clip lower half -- y < 0 */
  glClipPlane(GL_CLIP_PLANE0, eqn);
  glEnable(GL_CLIP_PLANE0);

  /* clip left half -- x < 0 */
  /* glClipPlane(GL_CLIP_PLANE1, eqn2);
     glEnable(GL_CLIP_PLANE1);*/
  
  //  glRotatef(90, 1, 0, 0);
  gluLookAt(1,0,1,0,0,0,0,1,0);
  glutWireSphere(1,20,16);
  glPopMatrix();
  glFlush();
}

void reshape(int w, int h){
  glViewport(0, 0, (GLsizei) w, (GLsizei) h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60, (GLfloat) w/ (GLfloat) h, 1, 20);
  glMatrixMode(GL_MODELVIEW);
}

int main(int argc, char ** argv){
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  glutInitWindowSize(500, 500);
  glutInitWindowPosition(100, 100);
  glutCreateWindow("I am a GOD!");
  init();
  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutMainLoop();
  return 0;
}

James Little