Changeset 4597 in orxonox.OLD for orxonox/trunk/src/lib/graphics/graphics_engine.cc
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/graphics_engine.cc
r4536 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 29 29 \todo this constructor is not jet implemented - do it 30 30 */ 31 GraphicsEngine::GraphicsEngine () 32 { 31 GraphicsEngine::GraphicsEngine () 32 { 33 this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine"); 34 this->setName("GraphicsEngine"); 33 35 this->bDisplayFPS = false; 34 36 this->minFPS = 9999; 35 37 this->maxFPS = 0; 36 this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");37 38 38 39 this->fullscreen = false; … … 51 52 \brief destructs the graphicsEngine. 52 53 */ 53 GraphicsEngine::~GraphicsEngine () 54 GraphicsEngine::~GraphicsEngine () 54 55 { 55 56 // delete what has to be deleted here … … 79 80 if( videoInfo == NULL) 80 81 { 81 PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError()); 82 PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError()); 82 83 SDL_Quit (); 83 84 } 84 85 if( videoInfo->hw_available) 85 86 this->videoFlags |= SDL_HWSURFACE; 86 else 87 else 87 88 this->videoFlags |= SDL_SWSURFACE; 88 89 /* … … 93 94 // setting up the Resolution 94 95 this->setResolution(800, 600, 16); 95 96 96 97 // Set window labeling 97 98 SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION); 98 99 99 100 // TO DO: Create a cool icon and use it here 100 101 char* loadPic = new char[strlen(ResourceManager::getInstance()->getDataDir())+ 100]; 101 102 sprintf(loadPic, "%s%s", ResourceManager::getInstance()->getDataDir(), "pictures/orxonox-icon32x32.bmp"); 102 SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL); 103 SDL_WM_SetIcon(SDL_LoadBMP(loadPic), NULL); 103 104 delete loadPic; 104 105 // Enable default GL stuff … … 117 118 //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); 118 119 //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); 119 120 121 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 122 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16); 123 SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 120 121 122 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 123 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16); 124 SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 124 125 SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0); 125 126 SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0); … … 144 145 else 145 146 fullscreenFlag = 0; 146 147 147 148 printf ("ok\n"); 148 149 if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags | fullscreenFlag)) == NULL) … … 195 196 /** 196 197 \brief entering 2D Mode 197 198 198 199 this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else 199 200 */ … … 202 203 GraphicsEngine::storeMatrices(); 203 204 SDL_Surface *screen = SDL_GetVideoSurface(); 204 205 205 206 /* Note, there may be other things you need to change, 206 207 depending on how you have your OpenGL state set up. … … 215 216 glEnable(GL_BLEND); 216 217 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 217 218 218 219 glViewport(0, 0, screen->w, screen->h); 219 220 220 221 glMatrixMode(GL_PROJECTION); 221 222 glPushMatrix(); 222 223 glLoadIdentity(); 223 224 224 225 glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0); 225 226 226 227 glMatrixMode(GL_MODELVIEW); 227 228 glPushMatrix(); 228 229 glLoadIdentity(); 229 230 230 231 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 231 232 } … … 238 239 glMatrixMode(GL_MODELVIEW); 239 240 glPopMatrix(); 240 241 241 242 glMatrixMode(GL_PROJECTION); 242 243 glPopMatrix(); 243 244 244 245 glPopAttrib(); 245 246 } 246 247 247 248 /** 248 \brief stores the GL_matrices 249 \brief stores the GL_matrices 249 250 */ 250 251 void GraphicsEngine::storeMatrices(void) … … 271 272 /* Get available fullscreen/hardware modes */ 272 273 this->videoModes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); 273 274 274 275 /* Check is there are any modes available */ 275 276 if(this->videoModes == (SDL_Rect **)0){ … … 277 278 exit(-1); 278 279 } 279 280 280 281 /* Check if our resolution is restricted */ 281 282 if(this->videoModes == (SDL_Rect **)-1){ … … 301 302 if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS; 302 303 if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS; 303 304 304 305 #ifndef NO_TEXT 305 306 char tmpChar1[20]; … … 315 316 } 316 317 } 317 318 318 319 /** 319 320 \brief displays the Frames per second … … 335 336 this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/druid.ttf", 35, TEXT_DYNAMIC, 0, 255, 0); 336 337 this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT); 337 this->geTextMinFPS->setPosition(5, 560); 338 this->geTextMinFPS->setPosition(5, 560); 338 339 #endif /* NO_TEXT */ 339 340 } … … 341 342 } 342 343 343 344
Note: See TracChangeset
for help on using the changeset viewer.