Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6885 was 6885, checked in by patrick, 18 years ago

trunk: implemented a working lense-flare

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