Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: working on the lenseflare

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