/* This collection of software is designed to help in learning and teaching about using OpenGL to build 3D graphics programs. Copyright (C) 2006 Scott D. Anderson scott.anderson@acm.org */ #include // for isgraph() #include #include #include // for strcmp() #include // for va_list() #include // for stat #include // for stat #include #include // for FLT_MAX #include #include #include void twErrorCheck(char* file, int line) { int err=glGetError(); if(err!=GL_NO_ERROR) { char* msg; switch(err) { case GL_INVALID_ENUM: msg="Invalid Enum"; break; case GL_INVALID_VALUE: msg="Invalid Value"; break; case GL_INVALID_OPERATION: msg="Invalid Operation"; break; case GL_STACK_OVERFLOW: msg="Stack Overflow"; break; case GL_STACK_UNDERFLOW: msg="Stack Underflow"; break; case GL_OUT_OF_MEMORY: msg="Out of Memory"; break; case GL_TABLE_TOO_LARGE: msg="Table too large"; break; } printf("Error %s discovered in check at line %d in %s\n",msg,line,file); } } #include "tw-util.cc" #include "tw-messages.cc" #include "tw-wrappers.cc" #include "tw-menu.cc" #include "tw-color.cc" #include "tw-bounding-box.cc" #include "tw-lighting.cc" #include "tw-window.cc" #include "tw-camera.cc" #include "tw-geometry.cc" #include "tw-keyboard.cc" #include "tw-textures.cc" #include "tw-fonts.cc" #include "tw-objects.cc" #include "tw-mouse.cc" #include "tw-animation.cc" void twDisplayInit(GLclampf bgR, GLclampf bgG, GLclampf bgB) { glClearColor(bgR,bgG,bgB,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_LIGHTING); if( Toggles[LIGHTING] ) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); if( Toggles[SMOOTH] ) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); if( Toggles[FILTER_NEAREST] ) { glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } else { glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } } void twDisplayInit() { twDisplayInit(0.75,0.75,0.75); } void twMainInit() { glEnable(GL_AUTO_NORMAL); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glDepthFunc(GL_LEQUAL); twKeyInit(); glutKeyboardFunc(twKeyboardCallback); glutMouseFunc(twMouseFunction); glutMotionFunc(twMotionFunction); glutReshapeFunc(twReshapeFunction); twIdleFunc(NULL); FieldOfView = FieldOfViewY; // All our toggles default to false for(int i=0; i