MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
graphicsmanager.cpp
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _graphicsmanager_cpp
41 #define _graphicsmanager_cpp
42 
43 #include "graphicsmanager.h"
44 #include "eventmanager.h"
45 #include "Graphics/cameramanager.h"
46 #include "resourcemanager.h"
47 #include "UI/uimanager.h"
48 #include "Graphics/cameraproxy.h"
49 #include "Graphics/cameramanager.h"
50 #include "crossplatform.h"
51 #include "Graphics/viewport.h"
52 #include "stringtool.h"
53 #include "entresol.h"
54 
55 #include <SDL.h>
56 #include <Ogre.h>
57 
58 #ifdef MEZZ_BUILD_DIRECTX9_SUPPORT
59 #include "OgreD3D9Plugin.h"
60 #endif
61 #ifdef MEZZ_BUILD_DIRECTX11_SUPPORT
62 #include "OgreD3D11Plugin.h"
63 #endif
64 #ifdef MEZZ_BUILD_OPENGLES2_SUPPORT
65 #include "OgreGLES2Plugin.h"
66 #endif
67 #ifdef MEZZ_BUILD_OPENGLES_SUPPORT
68 #include "OgreGLESPlugin.h"
69 #endif
70 #ifdef MEZZ_BUILD_OPENGL_SUPPORT
71 #include "OgreGLPlugin.h"
72 #endif
73 
74 #include <cstdlib>
75 
76 namespace Mezzanine
77 {
78  template<> Graphics::GraphicsManager* Singleton<Graphics::GraphicsManager>::SingletonPtr = NULL;
79 
80  namespace Graphics
81  {
82  ///////////////////////////////////////////////////////////////////////////
83  // RenderWorkUnit Methods
84 
85  RenderWorkUnit::RenderWorkUnit(GraphicsManager* Target) :
86  TargetManager(Target)
87  { }
88 
90  { }
91 
92  void RenderWorkUnit::UseThreads(const Whole& AmountToUse)
93  {
94  //TargetGraphicsManager->SomehowTellOgreHowManyThread(AmountToUse);
95  }
96 
98  {
99  //return TargetGraphicsManager->GetThreadCountFromOgreSomehow();
100  return 1;
101  }
102 
104  {
105  this->TargetManager->ThreadResources = &CurrentThreadStorage; // Allow this full access to any thread specific resources it needs
106  Ogre::WindowEventUtilities::messagePump();
107  this->TargetManager->RenderOneFrame();
108  this->TargetManager->ThreadResources = NULL; // Take it all away.
109  }
110 
111  ///////////////////////////////////////////////////////////////////////////
112  // GraphicsManager Methods
113 
114  //template<> GraphicsManager* Singleton<GraphicsManager>::SingletonPtr = NULL;
115 
117  PrimaryGameWindow(NULL),
118  RenderWork(NULL),
119  ThreadResources(NULL),
120  CurrRenderSys(Graphics::RS_OpenGL2),
121  OgreBeenInitialized(false)
122  {
123  this->Construct();
124  this->AutoGenFiles = false;
125  }
126 
128  PrimaryGameWindow(NULL),
129  RenderWork(NULL),
130  ThreadResources(NULL),
131  CurrRenderSys(Graphics::RS_OpenGL2),
132  OgreBeenInitialized(false)
133  {
134  this->Construct();
135 
136  XML::Attribute CurrAttrib;
137  String PathPreset;
138  // Get whether or not to autogen the directory path and settings file.
139  XML::Node AutoGenNode = XMLNode.GetChild("AutoCreateSettings");
140  if(!AutoGenNode.Empty())
141  {
142  CurrAttrib = AutoGenNode.GetAttribute("Auto");
143  if(!CurrAttrib.Empty())
144  this->AutoGenPath = this->AutoGenFiles = StringTools::ConvertToBool( CurrAttrib.AsString() );
145  }
146  // Get preset path to default to if a path is not provided.
147  XML::Node PathNode = XMLNode.GetChild("SettingsPath");
148  if(!PathNode.Empty())
149  {
150  CurrAttrib = PathNode.GetAttribute("Path");
151  if(!CurrAttrib.Empty())
152  PathPreset = CurrAttrib.AsString();
153 
154  if(!PathPreset.empty())
155  this->SetSettingsFilePath(PathPreset);
156  }
157  // Get the files to be loaded, and load them.
158  XML::Node FilesNode = XMLNode.GetChild("SettingsFiles");
159  if(!FilesNode.Empty())
160  {
161  for( XML::NodeIterator SetFileIt = FilesNode.begin() ; SetFileIt != FilesNode.end() ; ++SetFileIt )
162  {
163  String FileName, FilePath, FileGroup;
164  // Get the filename to load
165  CurrAttrib = (*SetFileIt).GetAttribute("FileName");
166  if(!CurrAttrib.Empty())
167  FileName = CurrAttrib.AsString();
168  // Get the path
169  CurrAttrib = (*SetFileIt).GetAttribute("Path");
170  if(!CurrAttrib.Empty())
171  FilePath = CurrAttrib.AsString();
172  else
173  {
174  CurrAttrib = (*SetFileIt).GetAttribute("Group");
175  if(!CurrAttrib.Empty())
176  FileGroup = CurrAttrib.AsString();
177  }
178 
179  if(FilePath.empty())
180  {
181  if(FileGroup.empty()) this->LoadSettings(FileName);
182  else this->LoadSettingsFromGroup(FileName,FileGroup);
183  }
184  else this->LoadSettings(FileName,FilePath);
185  }
186  }
187  /// @todo This is currently necessary because a render window of some kind needs to exist for the loading
188  /// of resources that occurs later in world construction (when this is constructed by the world, which this
189  /// assumes. If possible this should be removed, to keep construction more flexible.
190  this->InitOgreRenderSystem();
191  }
192 
193 
195  {
196  this->Deinitialize();
197  this->DestroyAllGameWindows(false);
198 
199  UInt32 InitSDLSystems = SDL_WasInit(0);
200  if( SDL_INIT_VIDEO | InitSDLSystems )
201  {
202  SDL_QuitSubSystem(SDL_INIT_VIDEO);
203  }
204 
205  delete RenderWork;
206  }
207 
209  {
210  this->PrimaryGameWindow=0;
211  this->RenderWork = new RenderWorkUnit(this);
212 
213  UInt32 InitSDLSystems = SDL_WasInit(0);
214  if( (SDL_INIT_VIDEO & InitSDLSystems) == 0 )
215  {
216  if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 )
217  { MEZZ_EXCEPTION(Exception::INTERNAL_EXCEPTION,String("Failed to Initialize SDL for Video/Windowing, SDL Error: ") + SDL_GetError()); }
218  }
219 
220  SDL_DisplayMode DeskMode;
221  SDL_GetDesktopDisplayMode(0,&DeskMode);
222  DesktopSettings.RenderWidth = DeskMode.w;
223  DesktopSettings.RenderHeight = DeskMode.h;
224  DesktopSettings.RefreshRate = DeskMode.refresh_rate;
225 
226  }
227 
229  {
230  if( !this->OgreBeenInitialized )
231  {
232  Ogre::Root* OgreCore = Ogre::Root::getSingletonPtr();
233  Ogre::Plugin* CurrentRenderSystem = 0;
234 
235  #ifdef MEZZ_BUILD_DIRECTX9_SUPPORT
236  CurrentRenderSystem = new Ogre::D3D9Plugin();
237  this->RenderSystems.push_back( CurrentRenderSystem );
238  OgreCore->installPlugin( CurrentRenderSystem );
239  this->RenderSystemTypes.push_back( Graphics::RS_DirectX9 );
240  #endif
241  #ifdef MEZZ_BUILD_DIRECTX11_SUPPORT
242  CurrentRenderSystem = new Ogre::D3D11Plugin();
243  this->RenderSystems.push_back( CurrentRenderSystem );
244  OgreCore->installPlugin( CurrentRenderSystem );
245  this->RenderSystemTypes.push_back( Graphics::RS_DirectX11 );
246  #endif
247  #ifdef MEZZ_BUILD_OPENGLES2_SUPPORT
248  CurrentRenderSystem = new Ogre::GLES2Plugin();
249  this->RenderSystems.push_back( CurrentRenderSystem );
250  OgreCore->installPlugin( CurrentRenderSystem );
251  this->RenderSystemTypes.push_back( Graphics::RS_OpenGLES2 );
252  #endif
253  #ifdef MEZZ_BUILD_OPENGLES_SUPPORT
254  CurrentRenderSystem = new Ogre::GLESPlugin();
255  this->RenderSystems.push_back( CurrentRenderSystem );
256  OgreCore->installPlugin( CurrentRenderSystem );
257  this->RenderSystemTypes.push_back( Graphics::RS_OpenGLES1 );
258  #endif
259  #ifdef MEZZ_BUILD_OPENGL_SUPPORT
260  CurrentRenderSystem = new Ogre::GLPlugin();
261  this->RenderSystems.push_back( CurrentRenderSystem );
262  OgreCore->installPlugin( CurrentRenderSystem );
263  this->RenderSystemTypes.push_back( Graphics::RS_OpenGL2 );
264  #endif
265 
266  if( this->RenderSystems.size() == 1 )
267  {
268  //Ogre::RenderSystem* temp = OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->RenderSystemTypes[0] ) );
269  OgreCore->setRenderSystem( OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->RenderSystemTypes[0] ) ) );
270  }else{
271  //Ogre::RenderSystem* temp = OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->CurrRenderSys ) );
272  OgreCore->setRenderSystem( OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->CurrRenderSys ) ) );
273  }
274 
275  OgreCore->initialise(false,"");
276  this->OgreBeenInitialized = true;
277 
278  this->PrimaryGameWindow = new GameWindow("Primary",1,1,GameWindow::WF_Hidden);
279  }
280  }
281 
282 
284  {
285  return "DefaultGraphicsManagerSettings";
286  }
287 
289  {
290  // Create the Group node to be returned
291  XML::Node CurrentSettings = SettingsRootNode.AppendChild("Current");
292  // Create and initialize the rendersystem settings
293  XML::Node RenderSystemNode = CurrentSettings.AppendChild("RenderSystem");
294  RenderSystemNode.AppendAttribute("Name").SetValue( this->GetShortenedRenderSystemName(CurrRenderSys) );
295  // Create and initialize the window configuration
296  for( GameWindowIterator WinIt = this->BeginGameWindow() ; WinIt != this->EndGameWindow() ; ++WinIt )
297  {
298  XML::Node WindowConfigNode = CurrentSettings.AppendChild("GameWindow");
299  WindowConfigNode.AppendAttribute("Caption").SetValue( (*WinIt)->GetWindowCaption() );
300  WindowConfigNode.AppendAttribute("Width").SetValue( StringTools::ConvertToString( (*WinIt)->GetRenderWidth() ) );
301  WindowConfigNode.AppendAttribute("Height").SetValue( StringTools::ConvertToString( (*WinIt)->GetRenderHeight() ) );
302  WindowConfigNode.AppendAttribute("Fullscreen").SetValue( StringTools::ConvertToString( (*WinIt)->GetFullscreen() ) );
303  WindowConfigNode.AppendAttribute("Hidden").SetValue( StringTools::ConvertToString( (*WinIt)->IsHidden() ) );
304  WindowConfigNode.AppendAttribute("Vsync").SetValue( StringTools::ConvertToString( (*WinIt)->VsyncEnabled() ) );
305  WindowConfigNode.AppendAttribute("Resizeable").SetValue( StringTools::ConvertToString( (*WinIt)->BorderIsResizeable() ) );
306  WindowConfigNode.AppendAttribute("Borderless").SetValue( StringTools::ConvertToString( (*WinIt)->IsBorderless() ) );
307  WindowConfigNode.AppendAttribute("FSAA").SetValue( StringTools::ConvertToString( (*WinIt)->GetFSAALevel() ) );
308  /// @todo Currently the maximized setting does nothing in the gamewindow. If it gets implemented, so does this.
309  //WindowConfigNode.AppendAttribute("Maximized").SetValue( (*WinIt)-> );//
310  for( GameWindow::ViewportIterator VPIt = (*WinIt)->BeginViewport() ; VPIt != (*WinIt)->EndViewport() ; ++VPIt )
311  {
312  XML::Node ViewportConfigNode = WindowConfigNode.AppendChild("Viewport");
313  ViewportConfigNode.AppendAttribute("ZOrder").SetValue( (*VPIt)->GetZOrder() );
314  ViewportConfigNode.AppendAttribute("Position").SetValue( StringTools::ConvertToString( Vector2((*VPIt)->GetLeft(),(*VPIt)->GetTop()) ) );
315  ViewportConfigNode.AppendAttribute("Size").SetValue( StringTools::ConvertToString( Vector2((*VPIt)->GetWidth(),(*VPIt)->GetHeight()) ) );
316  }
317  }
318  }
319 
321  {
322  for( ObjectSettingSetContainer::SubSetIterator SubSetIt = Group->SubSetBegin() ; SubSetIt != Group->SubSetEnd() ; ++SubSetIt )
323  {
324  String CurrSettingValue;
325  if( "RenderSystem" == (*SubSetIt)->GetName() )
326  {
327  Graphics::RenderSystem RenderSys = Graphics::RS_OpenGL2;
328  CurrSettingValue = (*SubSetIt)->GetSettingValue("Name");
329  if( GetShortenedRenderSystemName(Graphics::RS_DirectX9) == CurrSettingValue )
330  RenderSys = Graphics::RS_DirectX9;
331  else if( GetShortenedRenderSystemName(Graphics::RS_DirectX11) == CurrSettingValue )
332  RenderSys = Graphics::RS_DirectX11;
333  else if( GetShortenedRenderSystemName(Graphics::RS_OpenGL2) == CurrSettingValue )
334  RenderSys = Graphics::RS_OpenGL2;
335  else if( GetShortenedRenderSystemName(Graphics::RS_OpenGLES1) == CurrSettingValue )
336  RenderSys = Graphics::RS_OpenGLES1;
337  else if( GetShortenedRenderSystemName(Graphics::RS_OpenGLES2) == CurrSettingValue )
338  RenderSys = Graphics::RS_OpenGLES2;
339 
340  this->CurrRenderSys = RenderSys;
341 
342  if( !this->OgreBeenInitialized )
343  {
344  this->SetRenderSystem(this->CurrRenderSys,true);
345  }else{
346  /// @todo May want to make some other data member so that people can accurately get what is set now, instead of what will be set.
347  Entresol::GetSingletonPtr()->Log("WARNING: Attempting to apply new RenderSystem settings after the GraphicsManager has been initialized. "
348  "These Settings will be applied the next time settings are loaded during manager construction if current settings are saved.");
349  }
350  }
351  else if( "GameWindow" == (*SubSetIt)->GetName() )
352  {
353  String WinCaption("Mezzanine Window");
354  Whole WinWidth = 800;
355  Whole WinHeight = 600;
356  Whole WinFlags = 0;
357 
358  // Get the caption.
359  CurrSettingValue = (*SubSetIt)->GetSettingValue("Caption");
360  if(!CurrSettingValue.empty())
361  WinCaption = CurrSettingValue;
362  // Get the width.
363  CurrSettingValue = (*SubSetIt)->GetSettingValue("Width");
364  if(!CurrSettingValue.empty())
365  WinWidth = StringTools::ConvertToUInt32(CurrSettingValue);
366  // Get the height.
367  CurrSettingValue = (*SubSetIt)->GetSettingValue("Height");
368  if(!CurrSettingValue.empty())
369  WinHeight = StringTools::ConvertToUInt32(CurrSettingValue);
370  // Get fullscreen.
371  CurrSettingValue = (*SubSetIt)->GetSettingValue("Fullscreen");
372  if(!CurrSettingValue.empty())
373  {
374  if(StringTools::ConvertToBool(CurrSettingValue))
375  WinFlags = (WinFlags | GameWindow::WF_Fullscreen);
376  }
377  // Get hidden.
378  CurrSettingValue = (*SubSetIt)->GetSettingValue("Hidden");
379  if(!CurrSettingValue.empty())
380  {
381  if(StringTools::ConvertToBool(CurrSettingValue))
382  WinFlags = (WinFlags | GameWindow::WF_Hidden);
383  }
384  // Get vsync.
385  CurrSettingValue = (*SubSetIt)->GetSettingValue("Vsync");
386  if(!CurrSettingValue.empty())
387  {
388  if(StringTools::ConvertToBool(CurrSettingValue))
389  WinFlags = (WinFlags | GameWindow::WF_VsyncEnabled);
390  }
391  // Get resizable.
392  CurrSettingValue = (*SubSetIt)->GetSettingValue("Resizeable");
393  if(!CurrSettingValue.empty())
394  {
395  if(StringTools::ConvertToBool(CurrSettingValue))
396  WinFlags = (WinFlags | GameWindow::WF_Resizeable);
397  }
398  // Get maximized.
399  CurrSettingValue = (*SubSetIt)->GetSettingValue("Maximized");
400  if(!CurrSettingValue.empty())
401  {
402  if(StringTools::ConvertToBool(CurrSettingValue))
403  WinFlags = (WinFlags | GameWindow::WF_Maximized);
404  }
405  // Get borderless.
406  CurrSettingValue = (*SubSetIt)->GetSettingValue("Borderless");
407  if(!CurrSettingValue.empty())
408  {
409  if(StringTools::ConvertToBool(CurrSettingValue))
410  WinFlags = (WinFlags | GameWindow::WF_Borderless);
411  }
412  // Get the FSAA level
413  CurrSettingValue = (*SubSetIt)->GetSettingValue("FSAA");
414  if(!CurrSettingValue.empty())
415  {
416  switch (StringTools::ConvertToUInt32(CurrSettingValue))
417  {
418  case 2:
419  WinFlags = (WinFlags | GameWindow::WF_FSAA_2);
420  break;
421  case 4:
422  WinFlags = (WinFlags | GameWindow::WF_FSAA_4);
423  break;
424  case 8:
425  WinFlags = (WinFlags | GameWindow::WF_FSAA_8);
426  break;
427  case 16:
428  WinFlags = (WinFlags | GameWindow::WF_FSAA_16);
429  break;
430  }
431  }
432  // Finally, construct the window.
433  GameWindow* CurrWindow = this->CreateGameWindow(WinCaption,WinWidth,WinHeight,WinFlags);
434  // Set up the viewports
435  for( ObjectSettingSetContainer::SubSetIterator VPIt = (*SubSetIt)->SubSetBegin() ; VPIt != (*SubSetIt)->SubSetEnd() ; ++VPIt )
436  {
437  if( "Viewport" == (*VPIt)->GetName() )
438  {
439  Integer ZO = 0;
440  Vector2 Position(1,1);
441  Vector2 Size(0,0);
442 
443  CurrSettingValue = (*VPIt)->GetSettingValue("ZOrder");
444  if(!CurrSettingValue.empty())
445  ZO = StringTools::ConvertToInteger( CurrSettingValue );
446  CurrSettingValue = (*VPIt)->GetSettingValue("Position");
447  if(!CurrSettingValue.empty())
448  Position = StringTools::ConvertToVector2( CurrSettingValue );
449  CurrSettingValue = (*VPIt)->GetSettingValue("Size");
450  if(!CurrSettingValue.empty())
451  Size = StringTools::ConvertToVector2( CurrSettingValue );
452 
453  Viewport* CurrViewport = CurrWindow->CreateViewport(NULL,ZO);
454  CurrViewport->SetDimensions(Position.X,Position.Y,Size.X,Size.Y);
455  }// if - Viewport
456  }// for - Viewports
457  }// if - RS || GameWindow
458  }// for - SubSets
459  }
460 
461  ///////////////////////////////////////////////////////////////////////////////
462  // Window Management
463 
464  GameWindow* GraphicsManager::CreateGameWindow(const String& WindowCaption, const Whole& Width, const Whole& Height, const Whole& Flags)
465  {
466  if( !this->OgreBeenInitialized )
467  this->InitOgreRenderSystem();
468 
469  GameWindow* NewWindow = new GameWindow(WindowCaption,Width,Height,Flags);
470  this->GameWindows.push_back(NewWindow);
471  return NewWindow;
472  }
473 
475  {
476  return this->GameWindows.at(Index);
477  }
478 
480  {
481  for( ConstGameWindowIterator WinIt = this->GameWindows.begin() ; WinIt != this->GameWindows.end() ; ++WinIt )
482  {
483  if( (*WinIt)->GetWindowCaption() == Caption ) {
484  return (*WinIt);
485  }
486  }
487  return NULL;
488  }
489 
491  {
492  return this->GameWindows.size();
493  }
494 
496  {
497  for( GameWindowIterator it = this->GameWindows.begin() ; it != this->GameWindows.end() ; it++ )
498  {
499  if( ToBeDestroyed == (*it) )
500  {
501  delete ToBeDestroyed;
502  this->GameWindows.erase(it);
503  return;
504  }
505  }
506  }
507 
508  void GraphicsManager::DestroyAllGameWindows(bool ExcludePrimary)
509  {
510  for( GameWindowIterator Iter = GameWindows.begin() ; Iter != GameWindows.end() ; ++Iter )
511  { delete *Iter; }
512  this->GameWindows.clear();
513 
514  if(!ExcludePrimary)
515  {
516  delete PrimaryGameWindow;
517  this->PrimaryGameWindow = 0;
518  }
519  }
520 
522  {
523  return this->PrimaryGameWindow;
524  }
525 
527  {
528  return this->GameWindows.begin();
529  }
530 
532  {
533  return this->GameWindows.end();
534  }
535 
537  {
538  return this->GameWindows.begin();
539  }
540 
542  {
543  return this->GameWindows.end();
544  }
545 
546  ///////////////////////////////////////////////////////////////////////////////
547  // RenderSystem Management
548 
549  void GraphicsManager::SetRenderSystem(const Graphics::RenderSystem& RenderSys, bool InitializeRenderSystem)
550  {
551  if(!this->OgreBeenInitialized) this->CurrRenderSys = RenderSys;
552  else { MEZZ_EXCEPTION(Exception::INVALID_STATE_EXCEPTION,"Attempting to set RenderSystem after graphics has been initialized. This is not supported."); }
553 
554  if( InitializeRenderSystem )
555  this->InitOgreRenderSystem();
556  }
557 
559  {
560  return this->CurrRenderSys;
561  }
562 
564  {
565  switch(RenderSys)
566  {
567  case Graphics::RS_DirectX9: return "Direct3D9 Rendering Subsystem"; break;
568  case Graphics::RS_DirectX11: return "Direct3D11 Rendering Subsystem"; break;
569  case Graphics::RS_OpenGL2: return "OpenGL Rendering Subsystem"; break; /// @todo This will likely have to change when other OGL systems are implemented
570  // ©ase Graphics::RS_OpenGL3: return ""; break; Not yet implemented
571  // ©ase Graphics::RS_OpenGL4: return ""; break; Not yet implemented
572  case Graphics::RS_OpenGLES1: return "OpenGL ES 1.x Rendering Subsystem"; break;
573  case Graphics::RS_OpenGLES2: return "OpenGL ES 2.x Rendering Subsystem"; break;
574  default: return ""; break;
575  }
576  return "";
577  }
578 
580  {
581  switch(RenderSys)
582  {
583  case Graphics::RS_DirectX9: return "Direct3D9"; break;
584  case Graphics::RS_DirectX11: return "Direct3D11"; break;
585  case Graphics::RS_OpenGL2: return "OpenGL"; break; /// @todo This will likely have to change when other OGL systems are implemented
586  // ©ase Graphics::RS_OpenGL3: return ""; break; Not yet implemented
587  // ©ase Graphics::RS_OpenGL4: return ""; break; Not yet implemented
588  case Graphics::RS_OpenGLES1: return "OpenGLES1.x"; break;
589  case Graphics::RS_OpenGLES2: return "OpenGLES2.x"; break;
590  default: return ""; break;
591  }
592  return "";
593  }
594 
595  ///////////////////////////////////////////////////////////////////////////////
596  // Query Methods
597 
599  {
600  return &(this->SupportedResolutions);
601  }
602 
604  {
605  return &(this->SupportedDevices);
606  }
607 
609  {
610  return this->DesktopSettings;
611  }
612 
613  ///////////////////////////////////////////////////////////////////////////////
614  // Utility Methods
615 
617  {
618  Ogre::Root::getSingleton().renderOneFrame();
619  if( !this->GetPrimaryGameWindow()->_GetOgreWindowPointer()->isVisible() )
620  Ogre::Root::getSingleton().clearEventTimes();
621  }
622 
623  void GraphicsManager::SwapAllBuffers(bool WaitForVsync)
624  {
625  for( Whole X = 0 ; X < this->GetNumGameWindows() ; X++ )
626  this->GetGameWindow(X)->_GetOgreWindowPointer()->swapBuffers(false);
627  }
628 
630  {
631  if( !this->Initialized )
632  {
633  this->TheEntresol->GetScheduler().AddWorkUnitMonopoly(RenderWork, "RenderWork");
634 
635  if( !this->OgreBeenInitialized )
636  this->InitOgreRenderSystem();
637 
638  Ogre::ConfigOptionMap& CurrentRendererOptions = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
639  for( Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin() ;
640  configItr != CurrentRendererOptions.end() ; configItr++)
641  {
642  if( (configItr)->first == "Video Mode" )
643  {
644  for( Whole X = 0 ; X < (configItr)->second.possibleValues.size() ; X++ )
645  {
646  String NewRes = (configItr)->second.possibleValues[X];
648  StringTools::Trim(NewRes);
649  this->SupportedResolutions.push_back(NewRes);
650  }
651  continue;
652  }
653  if( (configItr)->first == "Rendering Device" )
654  {
655  for( Whole Y = 0 ; Y < (configItr)->second.possibleValues.size() ; Y++ )
656  this->SupportedDevices.push_back((configItr)->second.possibleValues[Y]);
657  continue;
658  }
659  }
660 
661  if(this->AutoGenFiles)
662  this->SaveAllSettings();
663 
664  this->Initialized = true;
665  }
666  }
667 
669  {
670  if( this->Initialized )
671  {
673 
674  /// @todo Here is where we should be shutting down the rendersystem, but Ogre in it's poorly coded ways wasn't
675  /// designed for that unless you are also deleting Ogre::Root. Take it up with them if you don't like it.
676  /// (tell me where the thread is when you do, I'll join in)
677  /// Related: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=77036&sid=a7ce7512032eb851d50da083795198f3
678 
679  if(this->AutoGenFiles)
680  this->SaveAllSettings();
681 
682  this->Initialized = false;
683  }
684  }
685 
687  { return this->RenderWork; }
688 
689  ///////////////////////////////////////////////////////////////////////////////
690  // SubSystem Initialization
691 
693  {
694  return SDL_WasInit(SDL_INIT_VIDEO);
695  }
696 
698  {
699  return this->OgreBeenInitialized;
700  }
701 
702  ///////////////////////////////////////////////////////////////////////////////
703  // Type Identifier Methods
704 
706  { return ManagerBase::MT_GraphicsManager; }
707 
709  { return "DefaultGraphicsManager"; }
710 
711  ///////////////////////////////////////////////////////////////////////////////
712  // DefaultGraphicsManagerFactory Methods
713 
715  {
716  }
717 
719  {
720  }
721 
723  {
724  return "DefaultGraphicsManager";
725  }
726 
728  {
730  {
731  /// @todo Add something to log a warning that the manager exists and was requested to be constructed when we have a logging manager set up.
733  }else{
734  return new GraphicsManager();
735  }
736  }
737 
739  {
741  {
742  /// @todo Add something to log a warning that the manager exists and was requested to be constructed when we have a logging manager set up.
744  }else return new GraphicsManager(XMLNode);
745  }
746 
748  {
749  delete ToBeDestroyed;
750  }
751 
752  } // Graphics Namespace
753 } //Mezzanine
754 
755 #endif