Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8230 was 8148, checked in by bensch, 18 years ago

trunk: output of EventListener Nicer

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