#include #include "camera_gl.h" #include "bezier.h" #include static GLint Height; /*height of window*/ static Camera_GL *TheCamera; static Point3D P[4][4] = {{{-2.500, -2.500, 0.002},{-2.500, -1.250,0.020},{-2.500, 0.000, 0.044},{-2.500, 1.250, 0.020}}, {{-1.250, -2.500, 0.020},{-1.250, -1.250, 0.210},{-1.250, 0.000, 0.458},{-1.250,1.250, 0.210}}, {{0.000, -2.500, 0.044},{0.000, -1.250, 0.458},{0.000, 0.000, 1.000},{0.000,1.250, 0.458}}, {{1.250, -2.500, 0.020},{1.250, -1.250, 0.210},{1.250, 0.000, 0.458},{1.250,1.250, 0.210}}}; static void display () { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(0.0,0.0,0.0); displayBezier(P); glFlush(); } static void reshape(int width, int height) { setCOP_GL(TheCamera,0.0,0.0,-6.0); setClipPlanes_GL(TheCamera,-5.9,200.0); setVPWindow_GL(TheCamera,-4.0,4.0,-0.5,0.75); clickProject_GL(TheCamera); glViewport (0, 0, width, height); /*define the viewport*/ } static void initialise(void) { /*GL_FLAT or GL_SMOOTH*/ glShadeModel(GL_FLAT); /*set the background (clear) Color to white*/ glClearColor(1.0,1.0,1.0,0.0); glEnable(GL_DEPTH_TEST); /*set the depth buffer for clearing*/ glClearDepth(1.0); /*initialise the camera*/ TheCamera = newCamera_GL(); setVRP_GL(TheCamera,0.0,0.0,0.0); setVPN_GL(TheCamera,1.0,1.0,-0.05); setVUV_GL(TheCamera,0.0,0.0,1.0); clickView_GL(TheCamera); } int main(int argc, char** argv) { int window; glutInit(&argc,argv); /*record the window height*/ Height = 500; glutInitWindowSize(Height,Height); glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH); window = glutCreateWindow("Bezier"); glutSetWindow(window); initialise(); /*register callbacks*/ glutDisplayFunc(display); /*display function*/ glutReshapeFunc(reshape); glutMainLoop(); }