/* $Id: tessdemo.c,v 1.2 1999/09/19 20:09:00 tanner Exp $ */ /* * A demo of the GLU polygon tesselation functions written by Bogdan Sikorski. * This demo isn't built by the Makefile because it needs GLUT. After you've * installed GLUT you can try this demo. * Here's the command for IRIX, for example: cc -g -ansi -prototypes -fullwarn -float -I../include -DSHM tess_demo.c -L../lib -lglut -lMesaGLU -lMesaGL -lm -lX11 -lXext -lXmu -lfpe -lXext -o tess_demo */ /* * $Log: tessdemo.c,v $ * Revision 1.2 1999/09/19 20:09:00 tanner * * lots of autoconf updates * * Revision 1.1.1.1 1999/08/19 00:55:40 jtg * Imported sources * * Revision 3.5 1999/03/28 18:24:37 brianp * minor clean-up * * Revision 3.4 1999/02/14 03:37:07 brianp * fixed callback problem * * Revision 3.3 1998/07/26 01:25:26 brianp * removed include of gl.h and glu.h * * Revision 3.2 1998/06/29 02:37:30 brianp * minor changes for Windows (Ted Jump) * * Revision 3.1 1998/06/09 01:53:49 brianp * main() should return an int * * Revision 3.0 1998/02/14 18:42:29 brianp * initial rev * */ #include #include #include #include #define MAX_POINTS 200 #define MAX_CONTOURS 50 int menu; typedef enum{ QUIT, TESSELATE, CLEAR } menu_entries; typedef enum{ DEFINE, TESSELATED } mode_type; struct { GLint p[MAX_POINTS][2]; GLuint point_cnt; } contours[MAX_CONTOURS]; GLuint contour_cnt; GLsizei width,height; mode_type mode; struct { GLsizei no; GLfloat color[3]; GLint p[3][2]; GLclampf p_color[3][3]; } triangle; #ifndef GLCALLBACK #ifdef CALLBACK #define GLCALLBACK CALLBACK #else #define GLCALLBACK #endif #endif void GLCALLBACK my_error(GLenum err) { int len,i; char const *str; glColor3f(0.9,0.9,0.9); glRasterPos2i(5,5); str=(const char *)gluErrorString(err); len=strlen(str); for(i=0;i2) { glBegin(GL_LINES); glVertex2iv(contours[contour_cnt].p[0]); glVertex2iv(contours[contour_cnt].p[point_cnt-1]); contours[contour_cnt].p[point_cnt][0]= -1; glEnd(); glFinish(); contour_cnt++; contours[contour_cnt].point_cnt=0; } } void mouse_clicked(int button,int state,int x,int y) { x-= x%10; y-= y%10; switch(button) { case GLUT_LEFT_BUTTON: if(state==GLUT_DOWN) left_down(x,y); break; case GLUT_MIDDLE_BUTTON: if(state==GLUT_DOWN) middle_down(x,y); break; } } void display(void) { GLuint i,j; GLuint point_cnt; glClear(GL_COLOR_BUFFER_BIT); switch(mode) { case DEFINE: /* draw grid */ glColor3f (0.6,0.5,0.5); glBegin(GL_LINES); for(i=0;i