40 #ifndef _graphicsmanager_cpp
41 #define _graphicsmanager_cpp
43 #include "graphicsmanager.h"
44 #include "eventmanager.h"
45 #include "Graphics/cameramanager.h"
47 #include "UI/uimanager.h"
49 #include "Graphics/cameramanager.h"
50 #include "crossplatform.h"
51 #include "Graphics/viewport.h"
52 #include "stringtool.h"
58 #ifdef MEZZ_BUILD_DIRECTX9_SUPPORT
59 #include "OgreD3D9Plugin.h"
61 #ifdef MEZZ_BUILD_DIRECTX11_SUPPORT
62 #include "OgreD3D11Plugin.h"
64 #ifdef MEZZ_BUILD_OPENGLES2_SUPPORT
65 #include "OgreGLES2Plugin.h"
67 #ifdef MEZZ_BUILD_OPENGLES_SUPPORT
68 #include "OgreGLESPlugin.h"
70 #ifdef MEZZ_BUILD_OPENGL_SUPPORT
71 #include "OgreGLPlugin.h"
78 template<> Graphics::GraphicsManager* Singleton<Graphics::GraphicsManager>::SingletonPtr = NULL;
106 Ogre::WindowEventUtilities::messagePump();
117 PrimaryGameWindow(NULL),
119 ThreadResources(NULL),
120 CurrRenderSys(Graphics::RS_OpenGL2),
121 OgreBeenInitialized(false)
128 PrimaryGameWindow(NULL),
130 ThreadResources(NULL),
131 CurrRenderSys(Graphics::RS_OpenGL2),
132 OgreBeenInitialized(false)
140 if(!AutoGenNode.
Empty())
143 if(!CurrAttrib.
Empty())
148 if(!PathNode.
Empty())
151 if(!CurrAttrib.
Empty())
154 if(!PathPreset.empty())
159 if(!FilesNode.
Empty())
163 String FileName, FilePath, FileGroup;
165 CurrAttrib = (*SetFileIt).GetAttribute(
"FileName");
166 if(!CurrAttrib.
Empty())
169 CurrAttrib = (*SetFileIt).GetAttribute(
"Path");
170 if(!CurrAttrib.
Empty())
174 CurrAttrib = (*SetFileIt).GetAttribute(
"Group");
175 if(!CurrAttrib.
Empty())
199 UInt32 InitSDLSystems = SDL_WasInit(0);
200 if( SDL_INIT_VIDEO | InitSDLSystems )
202 SDL_QuitSubSystem(SDL_INIT_VIDEO);
213 UInt32 InitSDLSystems = SDL_WasInit(0);
214 if( (SDL_INIT_VIDEO & InitSDLSystems) == 0 )
216 if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 )
220 SDL_DisplayMode DeskMode;
221 SDL_GetDesktopDisplayMode(0,&DeskMode);
232 Ogre::Root* OgreCore = Ogre::Root::getSingletonPtr();
233 Ogre::Plugin* CurrentRenderSystem = 0;
235 #ifdef MEZZ_BUILD_DIRECTX9_SUPPORT
236 CurrentRenderSystem =
new Ogre::D3D9Plugin();
238 OgreCore->installPlugin( CurrentRenderSystem );
241 #ifdef MEZZ_BUILD_DIRECTX11_SUPPORT
242 CurrentRenderSystem =
new Ogre::D3D11Plugin();
244 OgreCore->installPlugin( CurrentRenderSystem );
247 #ifdef MEZZ_BUILD_OPENGLES2_SUPPORT
248 CurrentRenderSystem =
new Ogre::GLES2Plugin();
250 OgreCore->installPlugin( CurrentRenderSystem );
253 #ifdef MEZZ_BUILD_OPENGLES_SUPPORT
254 CurrentRenderSystem =
new Ogre::GLESPlugin();
256 OgreCore->installPlugin( CurrentRenderSystem );
259 #ifdef MEZZ_BUILD_OPENGL_SUPPORT
260 CurrentRenderSystem =
new Ogre::GLPlugin();
262 OgreCore->installPlugin( CurrentRenderSystem );
269 OgreCore->setRenderSystem( OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->RenderSystemTypes[0] ) ) );
272 OgreCore->setRenderSystem( OgreCore->getRenderSystemByName( this->GetRenderSystemName( this->CurrRenderSys ) ) );
275 OgreCore->initialise(
false,
"");
285 return "DefaultGraphicsManagerSettings";
325 if(
"RenderSystem" == (*SubSetIt)->GetName() )
328 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Name");
330 RenderSys = Graphics::RS_DirectX9;
332 RenderSys = Graphics::RS_DirectX11;
334 RenderSys = Graphics::RS_OpenGL2;
336 RenderSys = Graphics::RS_OpenGLES1;
338 RenderSys = Graphics::RS_OpenGLES2;
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.");
351 else if(
"GameWindow" == (*SubSetIt)->GetName() )
353 String WinCaption(
"Mezzanine Window");
354 Whole WinWidth = 800;
355 Whole WinHeight = 600;
359 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Caption");
360 if(!CurrSettingValue.empty())
361 WinCaption = CurrSettingValue;
363 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Width");
364 if(!CurrSettingValue.empty())
367 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Height");
368 if(!CurrSettingValue.empty())
371 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Fullscreen");
372 if(!CurrSettingValue.empty())
378 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Hidden");
379 if(!CurrSettingValue.empty())
385 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Vsync");
386 if(!CurrSettingValue.empty())
392 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Resizeable");
393 if(!CurrSettingValue.empty())
399 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Maximized");
400 if(!CurrSettingValue.empty())
406 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"Borderless");
407 if(!CurrSettingValue.empty())
413 CurrSettingValue = (*SubSetIt)->GetSettingValue(
"FSAA");
414 if(!CurrSettingValue.empty())
437 if(
"Viewport" == (*VPIt)->GetName() )
443 CurrSettingValue = (*VPIt)->GetSettingValue(
"ZOrder");
444 if(!CurrSettingValue.empty())
446 CurrSettingValue = (*VPIt)->GetSettingValue(
"Position");
447 if(!CurrSettingValue.empty())
449 CurrSettingValue = (*VPIt)->GetSettingValue(
"Size");
450 if(!CurrSettingValue.empty())
483 if( (*WinIt)->GetWindowCaption() == Caption ) {
499 if( ToBeDestroyed == (*it) )
501 delete ToBeDestroyed;
554 if( InitializeRenderSystem )
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;
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;
583 case Graphics::RS_DirectX9:
return "Direct3D9";
break;
584 case Graphics::RS_DirectX11:
return "Direct3D11";
break;
585 case Graphics::RS_OpenGL2:
return "OpenGL";
break;
588 case Graphics::RS_OpenGLES1:
return "OpenGLES1.x";
break;
589 case Graphics::RS_OpenGLES2:
return "OpenGLES2.x";
break;
590 default:
return "";
break;
618 Ogre::Root::getSingleton().renderOneFrame();
620 Ogre::Root::getSingleton().clearEventTimes();
638 Ogre::ConfigOptionMap& CurrentRendererOptions = Ogre::Root::getSingleton().getRenderSystem()->getConfigOptions();
639 for( Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin() ;
640 configItr != CurrentRendererOptions.end() ; configItr++)
642 if( (configItr)->first ==
"Video Mode" )
644 for(
Whole X = 0 ; X < (configItr)->second.possibleValues.size() ; X++ )
646 String NewRes = (configItr)->second.possibleValues[X];
653 if( (configItr)->first ==
"Rendering Device" )
655 for(
Whole Y = 0 ; Y < (configItr)->second.possibleValues.size() ; Y++ )
694 return SDL_WasInit(SDL_INIT_VIDEO);
706 {
return ManagerBase::MT_GraphicsManager; }
709 {
return "DefaultGraphicsManager"; }
724 return "DefaultGraphicsManager";
749 delete ToBeDestroyed;