Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/resources/src/lib/graphics/graphics_engine.cc @ 7318

Last change on this file since 7318 was 7229, checked in by bensch, 19 years ago

resources: some minor implementations

File size: 17.0 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
[5944]31#include "parser/ini_parser/ini_parser.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 * @param iniParser the iniParser to load from
153 * @param section the Section in the ini-file to load from
154 * @returns nothing usefull
155 */
156int GraphicsEngine::initFromIniFile(IniParser* iniParser)
157{
158  // looking if we are in fullscreen-mode
[7221]159  const std::string fullscreen = iniParser->getVar(CONFIG_NAME_FULLSCREEN, CONFIG_SECTION_VIDEO, "0");
160  if (fullscreen[0] == '1' || fullscreen == "true")
[4830]161    this->fullscreenFlag = SDL_FULLSCREEN;
162
163  // looking if we are in fullscreen-mode
[7221]164  const std::string textures = iniParser->getVar(CONFIG_NAME_TEXTURES, CONFIG_SECTION_VIDEO_ADVANCED, "0");
165  if (textures[0] == '1' || textures == "true")
166    Texture::setTextureEnableState(true);
[4830]167  else
[5857]168    Texture::setTextureEnableState(false);
[4830]169
170  // searching for a usefull resolution
[7221]171  SubString resolution(iniParser->getVar(CONFIG_NAME_RESOLUTION, CONFIG_SECTION_VIDEO, "640x480").c_str(), 'x'); ///FIXME
[4833]172  //resolution.debug();
[7221]173  MultiType x = resolution.getString(0), y = resolution.getString(1);
174  this->initVideo(x.getInt(), y.getInt(), 16);
[4833]175
[6979]176  //   GraphicsEffect* fe = new FogEffect(NULL);
177  //   this->loadGraphicsEffect(fe);
178  //   fe->activate();
179  //   PRINTF(0)("--------------------------------------------------------------\n");
[6884]180
[6967]181  //LenseFlare* ge = new LenseFlare();
182  //this->loadGraphicsEffect(ge);
[6884]183
[6967]184  //ge->addFlare("pictures/lense_flare/sun.png"); //sun
185  //ge->addFlare("pictures/lense_flare/lens2.png"); //first halo
186  //ge->addFlare("pictures/lense_flare/lens1.png"); //small birst
187  //ge->addFlare("pictures/lense_flare/lens3.png"); //second halo
188  //ge->addFlare("pictures/lense_flare/lens4.png");
189  //ge->addFlare("pictures/lense_flare/lens1.png");
190  //ge->addFlare("pictures/lense_flare/lens3.png");
[6884]191
[6966]192  //ge->activate();
[4830]193}
194
195
196
197/**
[4836]198 *  initializes the Video for openGL.
[5346]199 *
200 * This has to be done only once when starting orxonox.
201 */
[4784]202int GraphicsEngine::initVideo(unsigned int resX, unsigned int resY, unsigned int bbp)
[3611]203{
[4784]204  if (this->isInit)
205    return -1;
[5024]206  //   initialize SDL_VIDEO
[5225]207  if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
[5024]208  {
209    PRINTF(1)("could not initialize SDL Video\n");
[6979]210    //      return -1;
[5024]211  }
[3617]212  // initialize SDL_GL-settings
213  this->setGLattribs();
[3610]214
[3617]215  // setting the Video Flags.
[5225]216  this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_GL_DOUBLEBUFFER;
[3610]217
218  /* query SDL for information about our video hardware */
219  const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
220  if( videoInfo == NULL)
[6979]221  {
222    PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError());
223    SDL_Quit ();
224  }
[3610]225  if( videoInfo->hw_available)
[3611]226    this->videoFlags |= SDL_HWSURFACE;
[4597]227  else
[3611]228    this->videoFlags |= SDL_SWSURFACE;
[3610]229  /*
[3619]230  if(VideoInfo -> blit_hw)
[3610]231    VideoFlags |= SDL_HWACCEL;
232  */
[6979]233  // setting up the Resolution
[4784]234  this->setResolution(resX, resY, bbp);
[3611]235
[5260]236  // GRABBING ALL GL-extensions
237  this->grabHardwareSettings();
238
[3621]239  // Enable default GL stuff
240  glEnable(GL_DEPTH_TEST);
[4784]241
[4849]242  Render2D::getInstance();
[4833]243
[4784]244  this->isInit = true;
[3365]245}
[1853]246
[4770]247/**
[4619]248 * sets the Window Captions and the Name of the icon.
249 * @param windowName The name of the Window
250 * @param icon The name of the Icon on the Disc
251 */
[7221]252void GraphicsEngine::setWindowName(const std::string& windowName, const std::string& icon)
[4619]253{
[7221]254  SDL_Surface* iconSurf = SDL_LoadBMP(icon.c_str());
[5240]255  if (iconSurf != NULL)
256  {
[5241]257    Uint32 colorkey = SDL_MapRGB(iconSurf->format, 0, 0, 0);
[5240]258    SDL_SetColorKey(iconSurf, SDL_SRCCOLORKEY, colorkey);
[7221]259    SDL_WM_SetIcon(iconSurf, NULL);
[5240]260    SDL_FreeSurface(iconSurf);
261  }
[5024]262
[7221]263  SDL_WM_SetCaption (windowName.c_str(), icon.c_str());
[4619]264}
265
266
267/**
[4836]268 *  Sets the GL-attributes
[5346]269 */
[4746]270int GraphicsEngine::setGLattribs()
[3617]271{
272  // Set video mode
273  // TO DO: parse arguments for settings
274  //SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
275  //SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
276  //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
277  //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
278
[4597]279
280  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
281  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
282  SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0);
[3617]283  SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
284  SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
285  SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
286  SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
287}
288
[5261]289/**
290 * grabs the Hardware Specifics
291 * checks for all the different HW-types
292 */
[5260]293void GraphicsEngine::grabHardwareSettings()
294{
295  const char* renderer = (const char*) glGetString(GL_RENDERER);
296  const char* vendor   = (const char*) glGetString(GL_VENDOR);
297  const char* version  = (const char*) glGetString(GL_VERSION);
298  const char* extensions = (const char*) glGetString(GL_EXTENSIONS);
299
[6979]300  //  printf("%s %s %s\n %s", renderer, vendor, version, extensions);
[5260]301
[7221]302  if (renderer != NULL)
[5260]303  {
[7221]304    this->hwRenderer == renderer;
[5260]305  }
[7221]306  if (vendor != NULL)
[5260]307  {
[7221]308    this->hwVendor == vendor;
[5260]309  }
[7221]310  if (version != NULL)
[5260]311  {
[7221]312    this->hwVersion == version;
[5260]313  }
314
[7221]315  if (extensions != NULL)
316    this->hwExtensions.split(extensions, " \n\t,");
[5260]317
[6634]318  PRINT(4)("Running on : vendor: %s,  renderer: %s,  version:%s\n", vendor, renderer, version);
[5260]319  PRINT(4)("Extensions:\n");
[7221]320  for (unsigned int i = 0; i < this->hwExtensions.getCount(); i++)
321    PRINT(4)("%d: %s\n", i, this->hwExtensions.getString(i).c_str());
[5263]322
323
324  // inizializing GLEW
325  GLenum err = glewInit();
326  if (GLEW_OK != err)
327  {
328    /* Problem: glewInit failed, something is seriously wrong. */
329    PRINTF(1)("%s\n", glewGetErrorString(err));
330  }
331  PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
[5260]332}
333
[6162]334
[3621]335/**
[4836]336 *  sets the Resolution of the Screen to display the Graphics to.
337 * @param width The width of the window
338 * @param height The height of the window
339 * @param bpp bits per pixel
[5346]340 */
[3619]341int GraphicsEngine::setResolution(int width, int height, int bpp)
[3610]342{
[3611]343  this->resolutionX = width;
344  this->resolutionY = height;
345  this->bitsPerPixel = bpp;
[6441]346  State::setResolution( width, height);
[4739]347
[5255]348  if (this->screen != NULL)
[5237]349    SDL_FreeSurface(screen);
[4769]350  if((this->screen = SDL_SetVideoMode(this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags | this->fullscreenFlag)) == NULL)
[6979]351  {
352    PRINTF(1)("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags, SDL_GetError());
353    //    SDL_Quit();
354    //    return -1;
355  }
356  glViewport(0, 0, width, height);                     // Reset The Current Viewport
[5755]357
[5790]358#ifdef __WIN32__
[7229]359  // renewing GL-settings
360  glEnable(GL_DEPTH_TEST);
361
[6979]362  // REBUILDING TEXTURES (ON WINDOWS CONTEXT SWITCH)
363  const std::list<BaseObject*>* texList = ClassList::getList(CL_TEXTURE);
364  if (texList != NULL)
365  {
366    std::list<BaseObject*>::const_iterator reTex;
367    for (reTex = texList->begin(); reTex != texList->end(); reTex++)
368      dynamic_cast<Texture*>(*reTex)->rebuild();
369  }
370  // REBUILDING MODELS
371  const std::list<BaseObject*>* modelList = ClassList::getList(CL_STATIC_MODEL);
372  if (texList != NULL)
373  {
374    std::list<BaseObject*>::const_iterator reModel;
375    for (reModel = modelList->begin(); reModel != modelList->end(); reModel++)
376      dynamic_cast<StaticModel*>(*reModel)->rebuild();
377  }
[5755]378#endif /* __WIN32__ */
[4135]379}
[3610]380
[4458]381/**
[4836]382 *  sets Fullscreen mode
383 * @param fullscreen true if fullscreen, false if windowed
[4458]384*/
[4135]385void GraphicsEngine::setFullscreen(bool fullscreen)
386{
[4768]387  if (fullscreen)
[5789]388    this->fullscreenFlag = SDL_FULLSCREEN;
[4768]389  else
[5789]390    this->fullscreenFlag = 0;
[4135]391  this->setResolution(this->resolutionX, this->resolutionY, this->bitsPerPixel);
[3543]392}
[3617]393
[4458]394/**
[4836]395 *  sets the background color
396 * @param red the red part of the background
397 * @param blue the blue part of the background
398 * @param green the green part of the background
399 * @param alpha the alpha part of the background
[5346]400 */
[4374]401void GraphicsEngine::setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
402{
403  glClearColor(red, green, blue, alpha);
404}
405
[3621]406/**
[4836]407 *  Signalhandler, for when the resolution has changed
408 * @param resizeInfo SDL information about the size of the new screen size
[5346]409 */
[4782]410int GraphicsEngine::resolutionChanged(const SDL_ResizeEvent& resizeInfo)
[3619]411{
[4782]412  this->setResolution(resizeInfo.w, resizeInfo.h, this->bitsPerPixel);
[3619]413}
[3617]414
[3622]415/**
[4833]416
417/**
[4836]418 *  entering 2D Mode
[4597]419
[3790]420   this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else
421*/
[4746]422void GraphicsEngine::enter2DMode()
[3790]423{
[4955]424  //GraphicsEngine::storeMatrices();
[3790]425  SDL_Surface *screen = SDL_GetVideoSurface();
[4597]426
[3790]427  /* Note, there may be other things you need to change,
428     depending on how you have your OpenGL state set up.
429  */
430  glPushAttrib(GL_ENABLE_BIT);
431  glDisable(GL_DEPTH_TEST);
432  glDisable(GL_CULL_FACE);
433  glDisable(GL_LIGHTING);  // will be set back when leaving 2D-mode
[3617]434
[3790]435  glMatrixMode(GL_PROJECTION);
436  glPushMatrix();
437  glLoadIdentity();
438  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
[4597]439
[3790]440  glMatrixMode(GL_MODELVIEW);
441  glPushMatrix();
442  glLoadIdentity();
443}
[3617]444
[3790]445/**
[5346]446 *  leaves the 2DMode again also @see Font::enter2DMode()
447 */
[4746]448void GraphicsEngine::leave2DMode()
[3790]449{
[4597]450
[4834]451  glMatrixMode(GL_MODELVIEW);
[3790]452  glPopMatrix();
[4597]453
[6780]454  glMatrixMode(GL_PROJECTION);
455  glPopMatrix();
456
[3790]457  glPopAttrib();
458}
[3622]459
[6522]460void GraphicsEngine::wireframe()
461{
[6523]462  glPolygonMode(GL_FRONT, GL_LINE);
[6522]463}
464
[3844]465/**
[4836]466 *  stores the GL_matrices
[5346]467 */
[4746]468void GraphicsEngine::storeMatrices()
[3844]469{
470  glGetDoublev(GL_PROJECTION_MATRIX, GraphicsEngine::projMat);
471  glGetDoublev(GL_MODELVIEW_MATRIX, GraphicsEngine::modMat);
472  glGetIntegerv(GL_VIEWPORT, GraphicsEngine::viewPort);
473}
[3622]474
[3844]475//! the stored ModelView Matrix.
476GLdouble GraphicsEngine::modMat[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
477//! the stored Projection Matrix
478GLdouble GraphicsEngine::projMat[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
479//! The ViewPort
480GLint GraphicsEngine::viewPort[4] = {0,0,0,0};
[3790]481
482
[3844]483
[3617]484/**
[4836]485 *  outputs all the Fullscreen modes.
[5346]486 */
[4746]487void GraphicsEngine::listModes()
[3617]488{
489  /* Get available fullscreen/hardware modes */
490  this->videoModes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
[4597]491
[3617]492  /* Check is there are any modes available */
[6979]493  if(this->videoModes == (SDL_Rect **)0)
494  {
[3617]495    PRINTF(1)("No modes available!\n");
496    exit(-1);
497  }
[4597]498
[3617]499  /* Check if our resolution is restricted */
[6979]500  if(this->videoModes == (SDL_Rect **)-1)
501  {
[4135]502    PRINTF(2)("All resolutions available.\n");
[3617]503  }
[6979]504  else
505  {
[3617]506    /* Print valid modes */
507    PRINT(0)("Available Resoulution Modes are\n");
508    for(int i = 0; this->videoModes[i]; ++i)
[4135]509      PRINT(4)(" |  %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h);
[3617]510  }
[4245]511}
512
[4458]513/**
[5261]514 * checks wether a certain extension is availiable
515 * @param extension the Extension to check for (ex. GL_ARB_texture_env_dot3)
516 * @return true if it is, false otherwise
517 */
[7221]518bool GraphicsEngine::hwSupportsEXT(const std::string& extension)
[5261]519{
[7221]520  for (unsigned int i = 0; i < this->hwExtensions.getCount(); i++)
521    if ( this->hwExtensions.getString(i) == extension)
522      return true;
[5261]523  return false;
524}
525
526/**
[5084]527 * updates everything that is to be updated in the GraphicsEngine
528 */
529void GraphicsEngine::update(float dt)
530{
[5406]531  Render2D::getInstance()->update(dt);
[5084]532}
533
534
535/**
[4836]536 *  ticks the Text
537 * @param dt the time passed
[5346]538 */
539void GraphicsEngine::tick(float dt)
[4245]540{
[4458]541  if( unlikely(this->bDisplayFPS))
[4849]542  {
543    this->currentFPS = 1.0/dt;
544    if( unlikely(this->currentFPS > this->maxFPS)) this->maxFPS = this->currentFPS;
545    if( unlikely(this->currentFPS < this->minFPS)) this->minFPS = this->currentFPS;
[4597]546
[4536]547#ifndef NO_TEXT
[6979]548    char tmpChar1[20];
549    sprintf(tmpChar1, "Current:  %4.0f", this->currentFPS);
550    this->geTextCFPS->setText(tmpChar1);
551    char tmpChar2[20];
552    sprintf(tmpChar2, "Max:    %4.0f", this->maxFPS);
553    this->geTextMaxFPS->setText(tmpChar2);
554    char tmpChar3[20];
555    sprintf(tmpChar3, "Min:    %4.0f", this->minFPS);
556    this->geTextMinFPS->setText(tmpChar3);
[4536]557#endif /* NO_TEXT */
[4849]558
[6815]559  }
[4849]560
561  Render2D::getInstance()->tick(dt);
[6815]562
563  // tick the graphics effects
[6979]564  if (this->graphicsEffects != NULL || (this->graphicsEffects = ClassList::getList(CL_GRAPHICS_EFFECT)) != NULL)
565  {
566    std::list<BaseObject*>::const_iterator it;
567    for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
568      dynamic_cast<GraphicsEffect*>(*it)->tick(dt);
569  }
[4245]570}
[4597]571
[4849]572
573void GraphicsEngine::draw() const
574{
[7221]575  //  LightManager::getInstance()->draw();
[6778]576
[6780]577  GraphicsEngine::storeMatrices();
[5318]578  Shader::suspendShader();
[5417]579
[5397]580  Render2D::getInstance()->draw(E2D_LAYER_ALL);
[5318]581  Shader::restoreShader();
[6815]582
[6979]583  if (this->graphicsEffects != NULL)
584  {
585    //draw the graphics effects
586    list<BaseObject*>::const_iterator it;
587    for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
588      dynamic_cast<GraphicsEffect*>(*it)->draw();
589  }
[4849]590}
591
[6142]592void GraphicsEngine::draw(const std::list<WorldEntity*>& drawList ) const
593{
594  std::list<WorldEntity*>::const_iterator entity;
595  for (entity = drawList.begin(); entity != drawList.end(); entity++)
[6222]596    if ((*entity)->isVisible())
597      (*entity)->draw();
[6142]598}
599
600
[4458]601/**
[5346]602 * displays the Frames per second
[4836]603 * @param display if the text should be displayed
[4458]604*/
[4245]605void GraphicsEngine::displayFPS(bool display)
606{
[4536]607#ifndef NO_TEXT
[5346]608  if( display )
609  {
[6979]610    if (this->geTextCFPS == NULL)
611    {
612      this->geTextCFPS = new Text("fonts/arial_black.ttf", 15);
613      this->geTextCFPS->setName("curFPS");
614      this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
615      this->geTextCFPS->setAbsCoor2D(5, 0);
616    }
617    if (this->geTextMaxFPS == NULL)
618    {
619      this->geTextMaxFPS = new Text("fonts/arial_black.ttf", 15);
620      this->geTextMaxFPS->setName("MaxFPS");
621      this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT);
622      this->geTextMaxFPS->setAbsCoor2D(5, 20);
623    }
624    if (this->geTextMinFPS == NULL)
625    {
626      this->geTextMinFPS = new Text("fonts/arial_black.ttf", 15);
627      this->geTextMinFPS->setName("MinFPS");
628      this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
629      this->geTextMinFPS->setAbsCoor2D(5, 40);
630    }
[5346]631  }
[6979]632  else
[5346]633  {
[6979]634    delete this->geTextCFPS;
635    this->geTextCFPS = NULL;
636    delete this->geTextMaxFPS;
637    this->geTextMaxFPS = NULL;
638    delete this->geTextMinFPS;
639    this->geTextMinFPS = NULL;
[5346]640  }
641  this->bDisplayFPS = display;
642#else
643  this->bDisplayFPS = false;
[4536]644#endif /* NO_TEXT */
[3617]645}
[4245]646
[4597]647
[4817]648/**
[5346]649  processes the events for the GraphicsEngine class
[4836]650* @param the event to handle
[4817]651 */
652void GraphicsEngine::process(const Event &event)
653{
654  switch (event.type)
655  {
[7221]656  case EV_VIDEO_RESIZE:
657    this->resolutionChanged(event.resize);
658    break;
[4817]659  }
[6753]660}
Note: See TracBrowser for help on using the repository browser.