Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/graphics_engine.cc @ 7264

Last change on this file since 7264 was 7256, checked in by bensch, 19 years ago

orxonox/trunk: merged the preferences back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/preferences . -r7233:HEAD
no conflicts… nice work

File size: 16.9 KB
RevLine 
[4597]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
[1855]10
11   ### File Specific:
[3610]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[3610]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
[1853]17
[3610]18#include "graphics_engine.h"
[7193]19#include "util/loading/resource_manager.h"
[4817]20#include "event_handler.h"
[6441]21#include "state.h"
[1853]22
[6142]23#include "world_entity.h"
24
[4849]25#include "render_2d.h"
[5347]26#include "text_engine.h"
[4850]27#include "light.h"
[5347]28#include "shader.h"
[3611]29#include "debug.h"
[5347]30
[7256]31#include "util/preferences.h"
[4770]32#include "substring.h"
[5344]33#include "text.h"
[4770]34
[5819]35#include "globals.h"
[5857]36#include "texture.h"
[5755]37
[6753]38#include "effects/graphics_effect.h"
[6772]39#include "effects/fog_effect.h"
[6884]40#include "effects/lense_flare.h"
[6753]41
[6522]42#include "shell_command.h"
43
[6815]44
45#include "parser/tinyxml/tinyxml.h"
[7193]46#include "util/loading/load_param.h"
47#include "util/loading/factory.h"
[6979]48#include "class_list.h"
[6815]49
[5755]50#ifdef __WIN32__
[6162]51 #include "static_model.h"
[5755]52#endif
[1856]53using namespace std;
[1853]54
[6522]55SHELL_COMMAND(wireframe, GraphicsEngine, wireframe);
56
[6976]57
[3245]58/**
[4836]59 *  standard constructor
[5262]60 */
[4597]61GraphicsEngine::GraphicsEngine ()
[3365]62{
[4597]63  this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");
64  this->setName("GraphicsEngine");
[4784]65
66  this->isInit = false;
67
[4245]68  this->bDisplayFPS = false;
69  this->minFPS = 9999;
70  this->maxFPS = 0;
[4135]71
[5079]72  this->geTextCFPS = NULL;
73  this->geTextMaxFPS = NULL;
74  this->geTextMinFPS = NULL;
75
[4768]76  this->fullscreenFlag = 0;
[5225]77  this->videoFlags = 0;
78  this->screen = NULL;
[5260]79
[6979]80  // initialize the Modules
[5285]81  TextEngine::getInstance();
[6979]82  this->graphicsEffects = NULL;
83
[3611]84}
[3610]85
[3621]86/**
[4836]87 *  The Pointer to this GraphicsEngine
[3621]88*/
[3611]89GraphicsEngine* GraphicsEngine::singletonRef = NULL;
[3610]90
[3621]91/**
[4836]92 *  destructs the graphicsEngine.
[3611]93*/
[4597]94GraphicsEngine::~GraphicsEngine ()
[3611]95{
96  // delete what has to be deleted here
[7029]97  this->displayFPS( false );
[4849]98
[5286]99  //TextEngine
[5285]100  delete TextEngine::getInstance();
[5347]101  // render 2D
102  delete Render2D::getInstance();
[5079]103
[5225]104  SDL_QuitSubSystem(SDL_INIT_VIDEO);
[6979]105  //   if (this->screen != NULL)
106  //     SDL_FreeSurface(this->screen);
[5240]107
[4849]108  GraphicsEngine::singletonRef = NULL;
[3611]109}
110
[6815]111
[4830]112/**
[6815]113 * loads the GraphicsEngine Specific Parameters.
114 * @param root: the XML-Element to load the Data From
115 */
116void GraphicsEngine::loadParams(const TiXmlElement* root)
117{
[6979]118  LoadParamXML(root, "GraphicsEffect", this, GraphicsEngine, loadGraphicsEffects)
119  .describe("loads a graphics effect");
[6815]120}
121
122
[6980]123
124
[6815]125/**
[6980]126 * @param root The XML-element to load GraphicsEffects from
127 */
128void GraphicsEngine::loadGraphicsEffects(const TiXmlElement* root)
129{
130  LOAD_PARAM_START_CYCLE(root, element);
131  {
[7035]132    PRINTF(4)("element is: %s\n", element->Value());
[6980]133    Factory::fabricate(element);
134  }
135  LOAD_PARAM_END_CYCLE(element);
136}
137
138
139
140/**
[4830]141 * initializes the GraphicsEngine with default settings.
142 */
[4784]143int GraphicsEngine::init()
144{
[4830]145  if (this->isInit)
146    return -1;
147  this->initVideo(640, 480, 16);
[4784]148}
149
[3611]150/**
[4830]151 * loads the GraphicsEngine's settings from a given ini-file and section
152 * @returns nothing usefull
153 */
[7256]154int GraphicsEngine::initFromPreferences()
[4830]155{
156  // looking if we are in fullscreen-mode
[7256]157  const std::string fullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0");
158
[7221]159  if (fullscreen[0] == '1' || fullscreen == "true")
[4830]160    this->fullscreenFlag = SDL_FULLSCREEN;
161
162  // looking if we are in fullscreen-mode
[7256]163  const std::string textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "0");
[7221]164  if (textures[0] == '1' || textures == "true")
165    Texture::setTextureEnableState(true);
[4830]166  else
[5857]167    Texture::setTextureEnableState(false);
[4830]168
169  // searching for a usefull resolution
[7256]170  SubString resolution(Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_RESOLUTION, "640x480").c_str(), 'x'); ///FIXME
[4833]171  //resolution.debug();
[7221]172  MultiType x = resolution.getString(0), y = resolution.getString(1);
173  this->initVideo(x.getInt(), y.getInt(), 16);
[4833]174
[6979]175  //   GraphicsEffect* fe = new FogEffect(NULL);
176  //   this->loadGraphicsEffect(fe);
177  //   fe->activate();
178  //   PRINTF(0)("--------------------------------------------------------------\n");
[6884]179
[6967]180  //LenseFlare* ge = new LenseFlare();
181  //this->loadGraphicsEffect(ge);
[6884]182
[6967]183  //ge->addFlare("pictures/lense_flare/sun.png"); //sun
184  //ge->addFlare("pictures/lense_flare/lens2.png"); //first halo
185  //ge->addFlare("pictures/lense_flare/lens1.png"); //small birst
186  //ge->addFlare("pictures/lense_flare/lens3.png"); //second halo
187  //ge->addFlare("pictures/lense_flare/lens4.png");
188  //ge->addFlare("pictures/lense_flare/lens1.png");
189  //ge->addFlare("pictures/lense_flare/lens3.png");
[6884]190
[6966]191  //ge->activate();
[4830]192}
193
194
195
196/**
[4836]197 *  initializes the Video for openGL.
[5346]198 *
199 * This has to be done only once when starting orxonox.
200 */
[4784]201int GraphicsEngine::initVideo(unsigned int resX, unsigned int resY, unsigned int bbp)
[3611]202{
[4784]203  if (this->isInit)
204    return -1;
[5024]205  //   initialize SDL_VIDEO
[5225]206  if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
[5024]207  {
208    PRINTF(1)("could not initialize SDL Video\n");
[6979]209    //      return -1;
[5024]210  }
[3617]211  // initialize SDL_GL-settings
212  this->setGLattribs();
[3610]213
[3617]214  // setting the Video Flags.
[5225]215  this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_GL_DOUBLEBUFFER;
[3610]216
217  /* query SDL for information about our video hardware */
218  const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
219  if( videoInfo == NULL)
[6979]220  {
221    PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError());
222    SDL_Quit ();
223  }
[3610]224  if( videoInfo->hw_available)
[3611]225    this->videoFlags |= SDL_HWSURFACE;
[4597]226  else
[3611]227    this->videoFlags |= SDL_SWSURFACE;
[3610]228  /*
[3619]229  if(VideoInfo -> blit_hw)
[3610]230    VideoFlags |= SDL_HWACCEL;
231  */
[6979]232  // setting up the Resolution
[4784]233  this->setResolution(resX, resY, bbp);
[3611]234
[5260]235  // GRABBING ALL GL-extensions
236  this->grabHardwareSettings();
237
[3621]238  // Enable default GL stuff
239  glEnable(GL_DEPTH_TEST);
[4784]240
[4849]241  Render2D::getInstance();
[4833]242
[4784]243  this->isInit = true;
[3365]244}
[1853]245
[4770]246/**
[4619]247 * sets the Window Captions and the Name of the icon.
248 * @param windowName The name of the Window
249 * @param icon The name of the Icon on the Disc
250 */
[7221]251void GraphicsEngine::setWindowName(const std::string& windowName, const std::string& icon)
[4619]252{
[7221]253  SDL_Surface* iconSurf = SDL_LoadBMP(icon.c_str());
[5240]254  if (iconSurf != NULL)
255  {
[5241]256    Uint32 colorkey = SDL_MapRGB(iconSurf->format, 0, 0, 0);
[5240]257    SDL_SetColorKey(iconSurf, SDL_SRCCOLORKEY, colorkey);
[7221]258    SDL_WM_SetIcon(iconSurf, NULL);
[5240]259    SDL_FreeSurface(iconSurf);
260  }
[5024]261
[7221]262  SDL_WM_SetCaption (windowName.c_str(), icon.c_str());
[4619]263}
264
265
266/**
[4836]267 *  Sets the GL-attributes
[5346]268 */
[4746]269int GraphicsEngine::setGLattribs()
[3617]270{
271  // Set video mode
272  // TO DO: parse arguments for settings
273  //SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
274  //SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
275  //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
276  //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
277
[4597]278
279  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
280  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
281  SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0);
[3617]282  SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
283  SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
284  SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
285  SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
286}
287
[5261]288/**
289 * grabs the Hardware Specifics
290 * checks for all the different HW-types
291 */
[5260]292void GraphicsEngine::grabHardwareSettings()
293{
294  const char* renderer = (const char*) glGetString(GL_RENDERER);
295  const char* vendor   = (const char*) glGetString(GL_VENDOR);
296  const char* version  = (const char*) glGetString(GL_VERSION);
297  const char* extensions = (const char*) glGetString(GL_EXTENSIONS);
298
[6979]299  //  printf("%s %s %s\n %s", renderer, vendor, version, extensions);
[5260]300
[7221]301  if (renderer != NULL)
[5260]302  {
[7221]303    this->hwRenderer == renderer;
[5260]304  }
[7221]305  if (vendor != NULL)
[5260]306  {
[7221]307    this->hwVendor == vendor;
[5260]308  }
[7221]309  if (version != NULL)
[5260]310  {
[7221]311    this->hwVersion == version;
[5260]312  }
313
[7221]314  if (extensions != NULL)
315    this->hwExtensions.split(extensions, " \n\t,");
[5260]316
[6634]317  PRINT(4)("Running on : vendor: %s,  renderer: %s,  version:%s\n", vendor, renderer, version);
[5260]318  PRINT(4)("Extensions:\n");
[7221]319  for (unsigned int i = 0; i < this->hwExtensions.getCount(); i++)
320    PRINT(4)("%d: %s\n", i, this->hwExtensions.getString(i).c_str());
[5263]321
322
323  // inizializing GLEW
324  GLenum err = glewInit();
325  if (GLEW_OK != err)
326  {
327    /* Problem: glewInit failed, something is seriously wrong. */
328    PRINTF(1)("%s\n", glewGetErrorString(err));
329  }
330  PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
[5260]331}
332
[6162]333
[3621]334/**
[4836]335 *  sets the Resolution of the Screen to display the Graphics to.
336 * @param width The width of the window
337 * @param height The height of the window
338 * @param bpp bits per pixel
[5346]339 */
[3619]340int GraphicsEngine::setResolution(int width, int height, int bpp)
[3610]341{
[3611]342  this->resolutionX = width;
343  this->resolutionY = height;
344  this->bitsPerPixel = bpp;
[6441]345  State::setResolution( width, height);
[4739]346
[5255]347  if (this->screen != NULL)
[5237]348    SDL_FreeSurface(screen);
[4769]349  if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags | this->fullscreenFlag)) == NULL)
[6979]350  {
351    PRINTF(1)("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags, SDL_GetError());
352    //    SDL_Quit();
353    //    return -1;
354  }
355  glViewport(0, 0, width, height);                     // Reset The Current Viewport
[5755]356
[5790]357#ifdef __WIN32__
[6979]358  // REBUILDING TEXTURES (ON WINDOWS CONTEXT SWITCH)
359  const std::list<BaseObject*>* texList = ClassList::getList(CL_TEXTURE);
360  if (texList != NULL)
361  {
362    std::list<BaseObject*>::const_iterator reTex;
363    for (reTex = texList->begin(); reTex != texList->end(); reTex++)
364      dynamic_cast<Texture*>(*reTex)->rebuild();
365  }
366  // REBUILDING MODELS
367  const std::list<BaseObject*>* modelList = ClassList::getList(CL_STATIC_MODEL);
368  if (texList != NULL)
369  {
370    std::list<BaseObject*>::const_iterator reModel;
371    for (reModel = modelList->begin(); reModel != modelList->end(); reModel++)
372      dynamic_cast<StaticModel*>(*reModel)->rebuild();
373  }
[5755]374#endif /* __WIN32__ */
[4135]375}
[3610]376
[4458]377/**
[4836]378 *  sets Fullscreen mode
379 * @param fullscreen true if fullscreen, false if windowed
[4458]380*/
[4135]381void GraphicsEngine::setFullscreen(bool fullscreen)
382{
[4768]383  if (fullscreen)
[5789]384    this->fullscreenFlag = SDL_FULLSCREEN;
[4768]385  else
[5789]386    this->fullscreenFlag = 0;
[4135]387  this->setResolution(this->resolutionX, this->resolutionY, this->bitsPerPixel);
[3543]388}
[3617]389
[4458]390/**
[4836]391 *  sets the background color
392 * @param red the red part of the background
393 * @param blue the blue part of the background
394 * @param green the green part of the background
395 * @param alpha the alpha part of the background
[5346]396 */
[4374]397void GraphicsEngine::setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
398{
399  glClearColor(red, green, blue, alpha);
400}
401
[3621]402/**
[4836]403 *  Signalhandler, for when the resolution has changed
404 * @param resizeInfo SDL information about the size of the new screen size
[5346]405 */
[4782]406int GraphicsEngine::resolutionChanged(const SDL_ResizeEvent& resizeInfo)
[3619]407{
[4782]408  this->setResolution(resizeInfo.w, resizeInfo.h, this->bitsPerPixel);
[3619]409}
[3617]410
[3622]411/**
[4833]412
413/**
[4836]414 *  entering 2D Mode
[4597]415
[3790]416   this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else
417*/
[4746]418void GraphicsEngine::enter2DMode()
[3790]419{
[4955]420  //GraphicsEngine::storeMatrices();
[3790]421  SDL_Surface *screen = SDL_GetVideoSurface();
[4597]422
[3790]423  /* Note, there may be other things you need to change,
424     depending on how you have your OpenGL state set up.
425  */
426  glPushAttrib(GL_ENABLE_BIT);
427  glDisable(GL_DEPTH_TEST);
428  glDisable(GL_CULL_FACE);
429  glDisable(GL_LIGHTING);  // will be set back when leaving 2D-mode
[3617]430
[3790]431  glMatrixMode(GL_PROJECTION);
432  glPushMatrix();
433  glLoadIdentity();
434  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
[4597]435
[3790]436  glMatrixMode(GL_MODELVIEW);
437  glPushMatrix();
438  glLoadIdentity();
439}
[3617]440
[3790]441/**
[5346]442 *  leaves the 2DMode again also @see Font::enter2DMode()
443 */
[4746]444void GraphicsEngine::leave2DMode()
[3790]445{
[4597]446
[4834]447  glMatrixMode(GL_MODELVIEW);
[3790]448  glPopMatrix();
[4597]449
[6780]450  glMatrixMode(GL_PROJECTION);
451  glPopMatrix();
452
[3790]453  glPopAttrib();
454}
[3622]455
[6522]456void GraphicsEngine::wireframe()
457{
[6523]458  glPolygonMode(GL_FRONT, GL_LINE);
[6522]459}
460
[3844]461/**
[4836]462 *  stores the GL_matrices
[5346]463 */
[4746]464void GraphicsEngine::storeMatrices()
[3844]465{
466  glGetDoublev(GL_PROJECTION_MATRIX, GraphicsEngine::projMat);
467  glGetDoublev(GL_MODELVIEW_MATRIX, GraphicsEngine::modMat);
468  glGetIntegerv(GL_VIEWPORT, GraphicsEngine::viewPort);
469}
[3622]470
[3844]471//! the stored ModelView Matrix.
472GLdouble GraphicsEngine::modMat[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
473//! the stored Projection Matrix
474GLdouble GraphicsEngine::projMat[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
475//! The ViewPort
476GLint GraphicsEngine::viewPort[4] = {0,0,0,0};
[3790]477
478
[3844]479
[3617]480/**
[4836]481 *  outputs all the Fullscreen modes.
[5346]482 */
[4746]483void GraphicsEngine::listModes()
[3617]484{
485  /* Get available fullscreen/hardware modes */
486  this->videoModes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
[4597]487
[3617]488  /* Check is there are any modes available */
[6979]489  if(this->videoModes == (SDL_Rect **)0)
490  {
[3617]491    PRINTF(1)("No modes available!\n");
492    exit(-1);
493  }
[4597]494
[3617]495  /* Check if our resolution is restricted */
[6979]496  if(this->videoModes == (SDL_Rect **)-1)
497  {
[4135]498    PRINTF(2)("All resolutions available.\n");
[3617]499  }
[6979]500  else
501  {
[3617]502    /* Print valid modes */
503    PRINT(0)("Available Resoulution Modes are\n");
504    for(int i = 0; this->videoModes[i]; ++i)
[4135]505      PRINT(4)(" |  %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h);
[3617]506  }
[4245]507}
508
[4458]509/**
[5261]510 * checks wether a certain extension is availiable
511 * @param extension the Extension to check for (ex. GL_ARB_texture_env_dot3)
512 * @return true if it is, false otherwise
513 */
[7221]514bool GraphicsEngine::hwSupportsEXT(const std::string& extension)
[5261]515{
[7221]516  for (unsigned int i = 0; i < this->hwExtensions.getCount(); i++)
517    if ( this->hwExtensions.getString(i) == extension)
518      return true;
[5261]519  return false;
520}
521
522/**
[5084]523 * updates everything that is to be updated in the GraphicsEngine
524 */
525void GraphicsEngine::update(float dt)
526{
[5406]527  Render2D::getInstance()->update(dt);
[5084]528}
529
530
531/**
[4836]532 *  ticks the Text
533 * @param dt the time passed
[5346]534 */
535void GraphicsEngine::tick(float dt)
[4245]536{
[4458]537  if( unlikely(this->bDisplayFPS))
[4849]538  {
539    this->currentFPS = 1.0/dt;
540    if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
541    if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
[4597]542
[4536]543#ifndef NO_TEXT
[6979]544    char tmpChar1[20];
545    sprintf(tmpChar1, "Current:  %4.0f", this->currentFPS);
546    this->geTextCFPS->setText(tmpChar1);
547    char tmpChar2[20];
548    sprintf(tmpChar2, "Max:    %4.0f", this->maxFPS);
549    this->geTextMaxFPS->setText(tmpChar2);
550    char tmpChar3[20];
551    sprintf(tmpChar3, "Min:    %4.0f", this->minFPS);
552    this->geTextMinFPS->setText(tmpChar3);
[4536]553#endif /* NO_TEXT */
[4849]554
[6815]555  }
[4849]556
557  Render2D::getInstance()->tick(dt);
[6815]558
559  // tick the graphics effects
[6979]560  if (this->graphicsEffects != NULL || (this->graphicsEffects = ClassList::getList(CL_GRAPHICS_EFFECT)) != NULL)
561  {
562    std::list<BaseObject*>::const_iterator it;
563    for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
564      dynamic_cast<GraphicsEffect*>(*it)->tick(dt);
565  }
[4245]566}
[4597]567
[4849]568
569void GraphicsEngine::draw() const
570{
[7221]571  //  LightManager::getInstance()->draw();
[6778]572
[6780]573  GraphicsEngine::storeMatrices();
[5318]574  Shader::suspendShader();
[5417]575
[5397]576  Render2D::getInstance()->draw(E2D_LAYER_ALL);
[5318]577  Shader::restoreShader();
[6815]578
[6979]579  if (this->graphicsEffects != NULL)
580  {
581    //draw the graphics effects
582    list<BaseObject*>::const_iterator it;
583    for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
584      dynamic_cast<GraphicsEffect*>(*it)->draw();
585  }
[4849]586}
587
[6142]588void GraphicsEngine::draw(const std::list<WorldEntity*>& drawList ) const
589{
590  std::list<WorldEntity*>::const_iterator entity;
591  for (entity = drawList.begin(); entity != drawList.end(); entity++)
[6222]592    if ((*entity)->isVisible())
593      (*entity)->draw();
[6142]594}
595
596
[4458]597/**
[5346]598 * displays the Frames per second
[4836]599 * @param display if the text should be displayed
[4458]600*/
[4245]601void GraphicsEngine::displayFPS(bool display)
602{
[4536]603#ifndef NO_TEXT
[5346]604  if( display )
605  {
[6979]606    if (this->geTextCFPS == NULL)
607    {
608      this->geTextCFPS = new Text("fonts/arial_black.ttf", 15);
609      this->geTextCFPS->setName("curFPS");
610      this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
611      this->geTextCFPS->setAbsCoor2D(5, 0);
612    }
613    if (this->geTextMaxFPS == NULL)
614    {
615      this->geTextMaxFPS = new Text("fonts/arial_black.ttf", 15);
616      this->geTextMaxFPS->setName("MaxFPS");
617      this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT);
618      this->geTextMaxFPS->setAbsCoor2D(5, 20);
619    }
620    if (this->geTextMinFPS == NULL)
621    {
622      this->geTextMinFPS = new Text("fonts/arial_black.ttf", 15);
623      this->geTextMinFPS->setName("MinFPS");
624      this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
625      this->geTextMinFPS->setAbsCoor2D(5, 40);
626    }
[5346]627  }
[6979]628  else
[5346]629  {
[6979]630    delete this->geTextCFPS;
631    this->geTextCFPS = NULL;
632    delete this->geTextMaxFPS;
633    this->geTextMaxFPS = NULL;
634    delete this->geTextMinFPS;
635    this->geTextMinFPS = NULL;
[5346]636  }
637  this->bDisplayFPS = display;
638#else
639  this->bDisplayFPS = false;
[4536]640#endif /* NO_TEXT */
[3617]641}
[4245]642
[4597]643
[4817]644/**
[5346]645  processes the events for the GraphicsEngine class
[4836]646* @param the event to handle
[4817]647 */
648void GraphicsEngine::process(const Event &event)
649{
650  switch (event.type)
651  {
[7221]652  case EV_VIDEO_RESIZE:
653    this->resolutionChanged(event.resize);
654    break;
[4817]655  }
[6753]656}
Note: See TracBrowser for help on using the repository browser.