/* general OpenGL initialization function */ int initGL() { //warning: this must be done BEFORE anything important //or else it will override it font.Load(); /* Enable Texture Mapping ( NEW ) */ glEnable( GL_TEXTURE_2D ); /* Enable smooth shading */ glShadeModel( GL_SMOOTH ); /* Set the background black */ //glClearColor( 0.46f, 0.54f, 0.64f, 0.0f ); glClearColor(0,0,0,0); /* Depth buffer setup */ glClearDepth( 1.0f ); /* Enables Depth Testing */ glEnable( GL_DEPTH_TEST ); /* The Type Of Depth Test To Do */ glDepthFunc( GL_LEQUAL ); /* Really Nice Perspective Calculations */ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); /* Position The Light */ glLightfv( GL_LIGHT1, GL_POSITION, LightPosition ); /* Setup The Diffuse Light */ glLightfv( GL_LIGHT1, GL_DIFFUSE, LightDiffuse ); glLightfv( GL_LIGHT1, GL_SPECULAR, LightSpecular ); /* Setup The Ambient Light */ glLightfv( GL_LIGHT1, GL_AMBIENT, LightAmbient ); /* Enable Light One */ glEnable( GL_LIGHT1 ); /* Enable Lighting */ glEnable( GL_LIGHTING ); //our perspective matrix glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); gluPerspective( 45.0f, (float)SCREEN_WIDTH/SCREEN_HEIGHT, 0.1f, 10000.0f ); glMatrixMode( GL_MODELVIEW ); // Enable front face culling, since that's what Quake3 does //glCullFace(GL_FRONT); //glEnable(GL_CULL_FACE); if (!InitGameData()) return (FALSE); return( TRUE ); }
void ChangeDisplay(int w, int h, int bpp, bool fullscreen, bool reloadtextures) { SCREEN_WIDTH = w; SCREEN_HEIGHT = h; SCREEN_BPP = bpp; /* the flags to pass to SDL_SetVideoMode */ int videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */ videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */ videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */ videoFlags |= SDL_RESIZABLE; /* Enable window resizing */ /* This checks to see if surfaces can be stored in memory */ /*if ( videoInfo->hw_available ) videoFlags |= SDL_HWSURFACE; else videoFlags |= SDL_SWSURFACE; if ( videoInfo->blit_hw ) videoFlags |= SDL_HWACCEL;*/ if (fullscreen) { videoFlags |= SDL_HWSURFACE|SDL_ANYFORMAT|SDL_FULLSCREEN; } else { videoFlags |= SDL_SWSURFACE|SDL_ANYFORMAT; } /* get a SDL surface */ if (surface != NULL) { SDL_FreeSurface(surface); surface = NULL; } surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags ); resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT ); //if (fullscreen) /* ofstream vconf; vconf.open((settings.GetSettingsDir() + "/videoconfig").c_str()); vconf << w << " "; vconf << h << " "; vconf << bpp << " "; vconf << fullscreen << " "; vconf.close(); */ settings.SetDisplayX(w); settings.SetDisplayY(h); settings.SetDisplayDepth(bpp); settings.SetFullscreenEnabled(fullscreen); if (reloadtextures) { font.Load(); } }