//------------------------------------------------------------------- // init //------------------------------------------------------------------- void init(int argc, char** argv) { glEnable(GL_TEXTURE_2D); glEnable(GL_NORMALIZE); glShadeModel(GL_SMOOTH); glEnable(GL_COLOR_MATERIAL); // Black Background glClearColor(0.00f, 0.80f, 0.80f, 0.0f); glEnable(GL_DEPTH_TEST); lights(); //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); makeMickey(); }
int main(int argc, char *argv[]) { Uint8* keys; int done=0; SM.LoadSound("eerie.wav"); SM.LoadSound("indicator.wav"); SM.LoadSound("static.mp3"); SM.LoadMusic("UNREAL.S3M"); // Create a new OpenGL window with the title "Cone3D Basecode" at // 640x480x32, fullscreen and check for errors along the way if(CreateGLWindow("SDL & OpenGL", 640, 480, 16, 0) == 0){ printf("Could not initalize OpenGL :(\n\n"); KillGLWindow(); return 0; } // Hide the mouse cursor //SDL_ShowCursor(0); // This is the main loop for the entire program and it will run until done==TRUE int changeit = 1; int reset = 1; makeMickey(); while(!done){ // Draw the scene if (changeit == 1) { DrawGLScene(); changeit = 0; } // And poll for events SDL_Event event; while ( SDL_PollEvent(&event) ) { switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: handleKey(event.key); break; case SDL_MOUSEMOTION: SDL_PeepEvents (&event,9,SDL_GETEVENT,SDL_MOUSEMOTION); handleMouseMotion(event.motion); if (reset == 1) { xpos = 0; ypos = 0; reset = 0; } //this affects the screen. changeit = 1; break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: handleMouseButtons(event.button); break; case SDL_QUIT: // then we're done and we'll end this program done=1; break; default: break; }// switch }// while // 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=1; }// while done // Kill the GL & SDL screens KillGLWindow(); // And quit return 0; }