#include "windowHandler.h" // Include the Whandler Basecode #include "object.h" int verbose = 1; WindowHandler wHandler; // Create an instance of the whandler basecode class Object* obj; float rotator = 0.0; GLfloat whiteLight[] = {1.0, 1.0, 0.0,1.0}; void DrawGLScene() { rotator +=.001; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glLoadIdentity(); // Reset the view glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,500/375,0.1f,100.0f); gluLookAt (5*sin(rotator),7.5,5*cos(rotator), 0,0,0, 0,1,0); whiteLight[1] = .5+.5*sin(rotator*10); whiteLight[2] = .5+.5*sin(rotator*10); GLfloat lightPosition[] = {10.0*sin(rotator*10), 10, 19.0, 0.0}; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); obj->draw(); SDL_GL_SwapBuffers(); // Swap the buffers } int main(int argc, char *argv[]) { Uint8* keys; // This variable will be used in the keyboard routine int done=FALSE; // We aren't done yet, are we? // Create a new OpenGL window with the title "Cone3D Basecode" at // 640x480x32, fullscreen and check for errors along the way if(wHandler.CreateGLWindow("Whandler Basecode", 500, 375, 32, FALSE) == FALSE) { // If an error is found, display a message, kill the GL and SDL screens (if they were created) and exit printf("Could not initalize OpenGL :(\n\n"); wHandler.KillGLWindow(); return 0; } if (argc>=3) obj = new Object (argv[1], atof(argv[2])); else if (argc>=2) obj = new Object(argv[1]); else obj = new Object(); GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0}; glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); // Build the font from a TGA image font.tga in the data directory // Hide the mouse cursor SDL_ShowCursor(0); // This is the main loop for the entire program and it will run until done==TRUE while(!done) { // Draw the scene DrawGLScene(); // And poll for events SDL_Event event; while ( SDL_PollEvent(&event) ) { switch (event.type) { // If a quit event was recieved case SDL_QUIT: // then we're done and we'll end this program done=TRUE; break; default: break; } } // Get the state of the keyboard keys keys = SDL_GetKeyState(NULL); // and check if ESCAPE has been pressed. If so then quit if(keys[SDLK_ESCAPE]) done=TRUE; } // Kill the GL & SDL screens delete obj; wHandler.KillGLWindow(); // And quit return 0; }