Spinning Topp Logo BlackTopp Studios
inc
gamewindow.cpp
1 // © Copyright 2010 - 2016 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 _graphicsgamewindow_cpp
41 #define _graphicsgamewindow_cpp
42 
43 #include "Graphics/gamewindow.h"
44 #include "Graphics/viewport.h"
45 #include "Graphics/cameraproxy.h"
46 #include "Graphics/graphicsmanager.h"
47 
48 #include "crossplatform.h"
49 #include "entresol.h"
50 
51 #include "serialization.h"
52 #include "exception.h"
53 
54 #ifdef MEZZ_WINDOWS
55 #include <windows.h>
56 #endif
57 
58 #ifdef MEZZ_LINUX
59 #include <X11/X.h> //x11proto-core-dev
60 #include <X11/Xlib.h> //libx11-dev
61 #endif
62 
63 #ifdef MEZZ_MACOSX
64 #include <Cocoa/Cocoa.h>
65 #endif
66 
67 #include <SDL.h>
68 #include "../src/video/SDL_sysvideo.h"
69 #include <Ogre.h>
70 
71 namespace Mezzanine
72 {
73  namespace Graphics
74  {
75  GameWindow::GameWindow(const String& WindowCaption, const Whole Width, const Whole Height, const Whole Flags) :
76  OgreWindow(NULL),
77  SDLWindow(NULL),
78  RequestedFSAA(0),
79  CreationFlags(0)
80  { this->CreateGameWindow(WindowCaption,Width,Height,Flags); }
81 
83  OgreWindow(NULL),
84  SDLWindow(NULL),
85  RequestedFSAA(0),
86  CreationFlags(0)
87  { this->ProtoDeSerialize(XMLNode); }
88 
90  {
91  this->DestroyAllViewports();
92  // first lets clear out the user data manually, the alternative is using SDL's allocation methods to make it, which we can opt for later
93  if( this->SDLWindow ) {
94  SDL_WindowUserData* WindowData = this->SDLWindow->data;
95  this->SDLWindow->data = NULL;
96  delete WindowData;
97 
98  SDL_DestroyWindow(this->SDLWindow);
99  }
100 
101  //this->OgreWindow->destroy();
102  Ogre::Root::getSingleton().destroyRenderTarget(this->OgreWindow);
103  }
104 
105  void GameWindow::CreateGameWindow(const String& WindowCaption, const Whole Width, const Whole Height, const Whole Flags)
106  {
108  this->CreationFlags = Flags;
109  this->Settings.WinRes.SetResolution(Width,Height);
110 
112  if(WF_Fullscreen & Flags) {
113  this->Settings.Fullscreen = true;
114  }
115 
116  if(WF_Hidden & Flags) {
117  Opts["hidden"] = "true";
118  }
119 
120  if(WF_VsyncEnabled & Flags) {
121  Opts["vsync"] = "true";
122  this->Settings.VSync = true;
123  }
124 
125  if(WF_FSAA_16 & Flags) {
126  Opts["FSAA"] = "16";
127  }else if(WF_FSAA_8 & Flags) {
128  Opts["FSAA"] = "8";
129  }else if(WF_FSAA_4 & Flags) {
130  Opts["FSAA"] = "4";
131  }else if(WF_FSAA_2 & Flags) {
132  Opts["FSAA"] = "2";
133  }
134 
135  if(WF_Resizeable & Flags) {
136  Opts["border"] = "resize";
137  }else if(WF_Borderless & Flags) {
138  Opts["border"] = "none";
139  }else{
140  Opts["border"] = "fixed";
141  }
142 
143  if(WF_Maximized & Flags) {
144 
145  }
146 
147  #ifdef MEZZ_MACOSX
148  Opts["macAPI"] = "cocoa";
149  #endif
150 
151  //#ifdef MEZZ_LINUX
152  //Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ResourceManager::GetSingletonPtr()->GetEngineDataDirectory(),"FileSystem");
153  //#endif
154  this->OgreWindow = Ogre::Root::getSingleton().createRenderWindow(WindowCaption, this->Settings.WinRes.Width, this->Settings.WinRes.Height, this->Settings.Fullscreen, &Opts);// */
155  this->RequestedFSAA = this->GetActualFSAALevel();
156 
157  if( !(WF_Hidden & Flags) ) {
158  #ifdef MEZZ_WINDOWS
159  HWND Data = 0;
160  #endif
161  #ifdef MEZZ_LINUX
162  Window Data = 0;
163  #endif
164  #ifdef MEZZ_MACOSX
165  NSWindow* Data = 0;
166  #endif
167  this->OgreWindow->getCustomAttribute("WINDOW",&Data);
168  this->SDLWindow = SDL_CreateWindowFrom((void*)Data);
169  this->SDLWindow->data = new SDL_WindowUserData();
170  this->SDLWindow->data->name = NULL;
171  this->SDLWindow->data->data = this;
172  this->SDLWindow->data->next = NULL;
173  }
174  }
175 
177  {
178  for( ViewportIterator ViewIt = this->Viewports.begin() ; ViewIt != this->Viewports.end() ; ++ViewIt )
179  {
180  if( (*ViewIt)->GetZOrder() > NewVP->GetZOrder() ) {
181  this->Viewports.insert( ViewIt, NewVP );
182  return;
183  }
184  }
185  this->Viewports.push_back( NewVP );
186  }
187 
189  {
190  for( ViewportIterator ViewIt = this->Viewports.begin() ; ViewIt != this->Viewports.end() ; ++ViewIt )
191  {
192  CameraProxy* Cam = (*ViewIt)->GetCamera();
193  if(Cam)
194  Cam->SetAspectRatio((Real)((*ViewIt)->GetActualWidth()) / (Real)((*ViewIt)->GetActualHeight()));
195  }
196  }
197 
198  ///////////////////////////////////////////////////////////////////////////////
199  // Viewport Management
200 
201  Viewport* GameWindow::CreateViewport(CameraProxy* ViewportCamera, const Integer ZOrder)
202  {
203  Viewport* NewViewport = new Viewport(ViewportCamera,ZOrder,this);
204  this->AddViewport(NewViewport);
205  return NewViewport;
206  }
207 
209  {
210  Whole Count = Index;
211  ConstViewportIterator ViewIt = this->Viewports.begin();
212  while( Count-- )
213  ++ViewIt;
214 
215  return (*ViewIt);
216  }
217 
219  {
220  for( ConstViewportIterator ViewIt = this->Viewports.begin() ; ViewIt != this->Viewports.end() ; ++ViewIt )
221  {
222  if( (*ViewIt)->GetZOrder() == ZOrder ) {
223  return (*ViewIt);
224  }
225  }
226  return NULL;
227  }
228 
230  {
231  return this->Viewports.size();
232  }
233 
235  {
236  for( ViewportIterator ViewIt = this->Viewports.begin() ; ViewIt != this->Viewports.end() ; ++ViewIt )
237  {
238  if ( ToBeDestroyed == (*ViewIt) ) {
239  delete ToBeDestroyed;
240  this->Viewports.erase(ViewIt);
241  return;
242  }
243  }
244  }
245 
247  {
248  for( ViewportIterator ViewIt = this->Viewports.begin() ; ViewIt != this->Viewports.end() ; ++ViewIt )
249  {
250  delete (*ViewIt);
251  }
252  this->Viewports.clear();
253  }
254 
256  { return this->Viewports.begin(); }
257 
259  { return this->Viewports.end(); }
260 
262  { return this->Viewports.begin(); }
263 
265  { return this->Viewports.end(); }
266 
268  { return this->Viewports.rbegin(); }
269 
271  { return this->Viewports.rend(); }
272 
274  { return this->Viewports.rbegin(); }
275 
277  { return this->Viewports.rend(); }
278 
279  ///////////////////////////////////////////////////////////////////////////////
280  // Window Metrics Management
281 
282  void GameWindow::SetWidth(const Whole& Width)
283  { this->SetResolution(Width,this->Settings.WinRes.Height); }
284 
286  { return this->Settings.WinRes.Width; }
287 
288  void GameWindow::SetHeight(const Whole& Height)
289  { this->SetResolution(this->Settings.WinRes.Width,Height); }
290 
292  { return this->Settings.WinRes.Height; }
293 
295  { this->SetResolution(WinRes.Width,WinRes.Height); }
296 
297  void GameWindow::SetResolution(const Whole& Width, const Whole& Height)
298  {
299  if( this->Settings.WinRes.Width != Width || this->Settings.WinRes.Height != Height ) {
300  if( this->Settings.Fullscreen ) {
301  SDL_DisplayMode CurrentDisplay;
302  SDL_GetWindowDisplayMode(SDLWindow,&CurrentDisplay);
303  CurrentDisplay.w = Width;
304  CurrentDisplay.h = Height;
305  // CurrentDisplay.refresh_rate = 60;
306  if(SDL_SetWindowDisplayMode(SDLWindow,&CurrentDisplay) == 0) {
307  this->OgreWindow->setFullscreen(true,Width,Height);
308  //this->OgreWindow->resize(Width,Height);
309  }
310  //this->OgreWindow->resize(Width,Height);
311  }else{
312  SDL_SetWindowSize(SDLWindow,Width,Height);
313  //this->OgreWindow->setFullscreen(false,Width,Height);
314  this->OgreWindow->resize(Width,Height);
315  }
317  this->Settings.WinRes.Width = Width;
318  this->Settings.WinRes.Height = Height;
319  }
320  }
321 
323  {
324  return this->Settings.WinRes;
325  }
326 
327  void GameWindow::SetFullscreen(const Boole Fullscreen)
328  {
329  //static SDL_DisplayMode FSDisplayMode;
330 
331  if( Fullscreen != this->Settings.Fullscreen ) {
332  /*if( !Fullscreen && this->Settings.Fullscreen ) {
333  const WindowSettings& DeskSet = this->Manager->GetDesktopSettings();
334  if( this->Settings.WinRes.Width > DeskSet.WinRes.Width || this->Settings.WinRes.Height > DeskSet.WinRes.Height ) {
335  this->Settings.WinRes.Width = DeskSet.WinRes.Width;
336  this->Settings.WinRes.Height = DeskSet.WinRes.Height;
337  }
338  if( this->Settings.WinRes.Width == DeskSet.WinRes.Width || this->Settings.WinRes.Height == DeskSet.WinRes.Height ) {
339  Whole ResultWidth, ResultHeight;
340  crossplatform::SanitizeWindowedRes(Settings.WinRes.Width,Settings.WinRes.Height,ResultWidth,ResultHeight);
341  this->SetResolution(ResultWidth,ResultHeight);
342  this->Settings.WinRes.Width = DeskSet.WinRes.Width;
343  this->Settings.WinRes.Height = DeskSet.WinRes.Height;
344  }
345  }else if(Fullscreen && !Settings.Fullscreen) {
346  FSDisplayMode.w = this->Settings.WinRes.Width;
347  FSDisplayMode.h = this->Settings.WinRes.Height;
348  FSDisplayMode.refresh_rate = Settings.RefreshRate;
349  SDL_SetWindowDisplayMode(SDLWindow,&FSDisplayMode);
350  }// */
351 
352  if(SDL_SetWindowFullscreen(SDLWindow, Fullscreen?SDL_TRUE:SDL_FALSE ) == 0) {
353  this->OgreWindow->setFullscreen(Fullscreen,this->Settings.WinRes.Width,this->Settings.WinRes.Height);
355  this->Settings.Fullscreen = Fullscreen;
356  }
357  }
358  }
359 
361  {
362  return this->Settings.Fullscreen;
363  }
364 
366  {
367  this->SetFullscreen( NewSettings.Fullscreen );
368  this->SetResolution( NewSettings.WinRes.Width, NewSettings.WinRes.Height );
369  }
370 
372  {
373  return this->Settings;
374  }
375 
376  ///////////////////////////////////////////////////////////////////////////////
377  // Window Settings Methods
378 
380  { return this->OgreWindow->getName(); }
381 
383  { this->RequestedFSAA = FSAA; }
384 
386  { return this->RequestedFSAA; }
387 
389  { return this->OgreWindow->getFSAA(); }
390 
392  { this->OgreWindow->setVSyncEnabled(Enable); }
393 
395  { return this->OgreWindow->isVSyncEnabled(); }
396 
398  { this->OgreWindow->setHidden(Hidden); }
399 
401  { return this->OgreWindow->isHidden(); }
402 
404  { return (this->CreationFlags & GameWindow::WF_Resizeable); }
405 
407  { return (this->CreationFlags & GameWindow::WF_Borderless); }
408 
409  ///////////////////////////////////////////////////////////////////////////////
410  // Window Stats Methods
411 
413  { return this->OgreWindow->getLastFPS(); }
414 
416  { return this->OgreWindow->getAverageFPS(); }
417 
419  { return this->OgreWindow->getBestFPS(); }
420 
422  { return this->OgreWindow->getWorstFPS(); }
423 
425  { return this->OgreWindow->getBestFrameTime(); }
426 
428  { return this->OgreWindow->getWorstFrameTime(); }
429 
430  ///////////////////////////////////////////////////////////////////////////////
431  // Serialization
432 
433  void GameWindow::ProtoSerialize(XML::Node& ParentNode) const
434  {
435  XML::Node SelfRoot = ParentNode.AppendChild( GameWindow::GetSerializableName() );
436 
437  this->ProtoSerializeProperties(SelfRoot);
438  this->ProtoSerializeViewports(SelfRoot);
439  }
440 
442  {
443  XML::Node PropertiesNode = SelfRoot.AppendChild( GameWindow::GetSerializableName() + "Properties" );
444 
445  if( PropertiesNode.AppendAttribute("Version").SetValue("1") &&
446  PropertiesNode.AppendAttribute("Caption").SetValue( this->GetWindowCaption() ) &&
447  PropertiesNode.AppendAttribute("Width").SetValue( this->GetWidth() ) &&
448  PropertiesNode.AppendAttribute("Height").SetValue( this->GetHeight() ) &&
449  PropertiesNode.AppendAttribute("Fullscreen").SetValue( this->GetFullscreen() ) &&
450  PropertiesNode.AppendAttribute("Hidden").SetValue( this->IsHidden() ) &&
451  PropertiesNode.AppendAttribute("Vsync").SetValue( this->VsyncEnabled() ) &&
452  PropertiesNode.AppendAttribute("Resizeable").SetValue( this->BorderIsResizeable() ) &&
453  PropertiesNode.AppendAttribute("Borderless").SetValue( this->IsBorderless() ) &&
454  PropertiesNode.AppendAttribute("FSAA").SetValue( this->GetFSAALevel() ) )
455  /// @todo Currently the maximized setting does nothing in the gamewindow. If it gets implemented, so does this.
456  //PropertiesNode.AppendAttribute("Maximized").SetValue( (*WinIt)-> );// */ )
457  {
458  return;
459  }else{
460  SerializeError("Create XML Attribute Values",GameWindow::GetSerializableName() + "Properties",true);
461  }
462  }
463 
465  {
466  XML::Node ViewportsNode = SelfRoot.AppendChild( "Viewports" );
467  if( ViewportsNode.AppendAttribute("Version").SetValue("1") == false ) {
468  SerializeError("Create XML Version Attribute","Viewports",true);
469  }
470 
471  for( ConstViewportIterator ViewIt = this->Viewports.begin() ; ViewIt != this->Viewports.end() ; ++ViewIt )
472  {
473  (*ViewIt)->ProtoSerialize(ViewportsNode);
474  }
475  }
476 
478  {
479  this->ProtoDeSerializeProperties(SelfRoot);
480  this->ProtoDeSerializeViewports(SelfRoot);
481  }
482 
484  {
485  this->DestroyAllViewports();
486  if( this->OgreWindow != NULL ) {
487  Ogre::Root::getSingleton().destroyRenderTarget(this->OgreWindow);
488  this->OgreWindow = NULL;
489  }
490 
491  XML::Attribute CurrAttrib;
492  XML::Node PropertiesNode = SelfRoot.GetChild( GameWindow::GetSerializableName() + "Properties" );
493 
494  if( !PropertiesNode.Empty() ) {
495  if(SelfRoot.GetAttribute("Version").AsInt() == 1) {
496  String WinCaption;
497  Whole WinWidth = 0, WinHeight = 0, WinFlags = 0;
498 
499  CurrAttrib = SelfRoot.GetAttribute("Caption");
500  if( !CurrAttrib.Empty() )
501  WinCaption = CurrAttrib.AsString();
502 
503  CurrAttrib = SelfRoot.GetAttribute("Width");
504  if( !CurrAttrib.Empty() )
505  WinWidth = CurrAttrib.AsWhole();
506 
507  CurrAttrib = SelfRoot.GetAttribute("Height");
508  if( !CurrAttrib.Empty() )
509  WinHeight = CurrAttrib.AsWhole();
510 
511  CurrAttrib = SelfRoot.GetAttribute("Fullscreen");
512  if( !CurrAttrib.Empty() && CurrAttrib.AsBool() )
513  WinFlags |= WF_Fullscreen;
514 
515  CurrAttrib = SelfRoot.GetAttribute("Hidden");
516  if( !CurrAttrib.Empty() && CurrAttrib.AsBool() )
517  WinFlags |= WF_Hidden;
518 
519  CurrAttrib = SelfRoot.GetAttribute("Vsync");
520  if( !CurrAttrib.Empty() && CurrAttrib.AsBool() )
521  WinFlags |= WF_VsyncEnabled;
522 
523  CurrAttrib = SelfRoot.GetAttribute("Resizeable");
524  if( !CurrAttrib.Empty() && CurrAttrib.AsBool() )
525  WinFlags |= WF_Resizeable;
526 
527  CurrAttrib = SelfRoot.GetAttribute("Borderless");
528  if( !CurrAttrib.Empty() && CurrAttrib.AsBool() )
529  WinFlags |= WF_Borderless;
530 
531  CurrAttrib = SelfRoot.GetAttribute("FSAA");
532  if( !CurrAttrib.Empty() ) {
533  Whole FSAALevel = CurrAttrib.AsWhole();
534  if( FSAALevel == 1 ) {
535  WinFlags |= WF_FSAA_2;
536  }else if( FSAALevel == 2 ) {
537  WinFlags |= WF_FSAA_4;
538  }else if( FSAALevel == 3 ) {
539  WinFlags |= WF_FSAA_8;
540  }else if( FSAALevel == 4 ) {
541  WinFlags |= WF_FSAA_16;
542  }
543  }
544 
545  this->CreateGameWindow(WinCaption,WinWidth,WinHeight,WinFlags);
546  }else{
547  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + GameWindow::GetSerializableName() + ": Not Version 1.");
548  }
549  }else{
550  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,GameWindow::GetSerializableName() + " was not found in the provided XML node, which was expected.");
551  }
552  }
553 
555  {
556  this->DestroyAllViewports();
557 
558  XML::Attribute CurrAttrib;
559  XML::Node ViewportsNode = SelfRoot.GetChild( "Viewports" );
560 
561  if( !ViewportsNode.Empty() ) {
562  if(ViewportsNode.GetAttribute("Version").AsInt() == 1) {
563  for( XML::NodeIterator ViewNodeIt = ViewportsNode.begin() ; ViewNodeIt != ViewportsNode.end() ; ++ViewNodeIt )
564  {
565  Viewport* NewViewport = new Viewport( (*ViewNodeIt), this );
566  this->AddViewport(NewViewport);
567  }
568  }else{
569  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for RenderLayers: Not Version 1.");
570  }
571  }
572  }
573 
575  { return "GameWindow"; }
576 
577  ///////////////////////////////////////////////////////////////////////////////
578  // Internal Methods
579 
580  Ogre::RenderWindow* GameWindow::_GetOgreWindowPointer()
581  { return this->OgreWindow; }
582 
584  { return this->SDLWindow; }
585  }//Graphics
586 }//Mezzanine
587 
588 #endif
Creates a window with resizable borders, otherwise it is fixed size.
Definition: gamewindow.h:87
GameWindow(const String &WindowCaption, const Whole Width, const Whole Height, const Whole Flags)
Class constructor.
Definition: gamewindow.cpp:75
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
Enables Fullscreen Anti-Aliasing level 4 for the window.
Definition: gamewindow.h:84
void DestroyViewport(Viewport *ToBeDestroyed)
Destroys a viewport within this window.
Definition: gamewindow.cpp:234
void SetHeight(const Whole &Height)
Sets the height of the game window.
Definition: gamewindow.cpp:288
Boole BorderIsResizeable() const
Gets whether or not this window has a resizeable border.
Definition: gamewindow.cpp:403
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
Boole IsHidden() const
Gets whether this window is hidden.
Definition: gamewindow.cpp:400
SDL_Window * SDLWindow
A pointer to the internal window used for collecting input.
Definition: gamewindow.h:106
void CreateGameWindow(const String &WindowCaption, const Whole Width, const Whole Height, const Whole Flags)
Convenience method for constructing a window.
Definition: gamewindow.cpp:105
Enables Fullscreen Anti-Aliasing level 16 for the window.
Definition: gamewindow.h:86
bool AsBool(bool def=false) const
Attempts to convert the value of the attribute to a float and returns the results.
Real GetAverageFPS() const
Gets the Average FPS.
Definition: gamewindow.cpp:415
Ogre::RenderWindow * OgreWindow
A pointer to the internal window used for rendering.
Definition: gamewindow.h:103
const String & GetWindowCaption() const
Gets the the text in the titlebar.
Definition: gamewindow.cpp:379
void ProtoDeSerializeViewports(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the viewports of this object with it...
Definition: gamewindow.cpp:554
Whole Height
The pixel height of the window.
Definition: resolution.h:66
ViewportContainer::iterator ViewportIterator
Iterator type for Viewport instances stored by this class.
Definition: gamewindow.h:69
ViewportIterator BeginViewport()
Gets an iterator to the first viewport in this window.
Definition: gamewindow.cpp:255
Removes all window decorations from the window(titlebar, borders, etc.).
Definition: gamewindow.h:89
Thrown when the requested identity could not be found.
Definition: exception.h:94
Integer GetZOrder() const
Gets the Zorder assigned to this viewport.
Definition: viewport.cpp:96
Real GetLastFPS() const
Gets the FPS based on the last frame rendered.
Definition: gamewindow.cpp:412
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
Boole Fullscreen
This is the desired state of whether the window is fullscreen or not.
This stores all the basic configuration options a game window supports.
Definition: resolution.h:57
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
Boole IsBorderless() const
Gets whether this window is borderless.
Definition: gamewindow.cpp:406
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
void SetWidth(const Whole &Width)
Sets the width of the game window.
Definition: gamewindow.cpp:282
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
void AddViewport(Viewport *NewVP)
Inserts a Viewport into this window based on it's ZOrder.
Definition: gamewindow.cpp:176
virtual void SetAspectRatio(const Real Ratio)
Sets the aspect ratio of the cameras veiw.
void SetHidden(Boole Hidden)
Hides (shows) the window.
Definition: gamewindow.cpp:397
This stores all the basic configuration options a game window supports.
Ogre::RenderWindow * _GetOgreWindowPointer()
This will get a pointer to the Ogre RenderWindow.
Definition: gamewindow.cpp:580
void SetResolution(const Resolution &WinRes)
Sets the width and height of the game window.
Definition: gamewindow.cpp:294
void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
Definition: gamewindow.cpp:441
bool Empty() const
Is this storing anything at all?
static String GetSerializableName()
Get the name of the the XML tag the Renderable class will leave behind as its instances are serialize...
Definition: gamewindow.cpp:574
This implements the exception hiearchy for Mezzanine.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Definition: gamewindow.cpp:477
ReverseViewportIterator ReverseBeginViewport()
Gets an iterator to the last viewport in this window.
Definition: gamewindow.cpp:267
void UpdateViewportsAndCameras()
Updates all the viewports of this window and the cameras attached to them after a change in window ge...
Definition: gamewindow.cpp:188
const WindowSettings & GetSettings()
Gets the current window settings.
Definition: gamewindow.cpp:371
ViewportContainer::reverse_iterator ReverseViewportIterator
Reverse Iterator type for Viewport instances stored by this class.
Definition: gamewindow.h:73
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
The interface for serialization.
ReverseViewportIterator ReverseEndViewport()
Gets an iterator to one before the first viewport in this window.
Definition: gamewindow.cpp:270
Enables Fullscreen Anti-Aliasing level 2 for the window.
Definition: gamewindow.h:83
bool SetValue(const Char8 *rhs)
Set the value of this.
void ProtoSerializeViewports(XML::Node &SelfRoot) const
Convert the viewports of this class to an XML::Node ready for serialization.
Definition: gamewindow.cpp:464
void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
Definition: gamewindow.cpp:483
ViewportIterator EndViewport()
Gets an iterator to one passed the last viewport in this window.
Definition: gamewindow.cpp:258
void SetRenderOptions(const WindowSettings &NewSettings)
Changes the X Resolution, Y Resolution, and fullscreen at the same time.
Definition: gamewindow.cpp:365
This enables vsync for the window.
Definition: gamewindow.h:82
Whole AsWhole(Whole def=0) const
Attempts to convert the value of the attribute to a Whole and returns the results.
Viewport * CreateViewport(CameraProxy *ViewportCamera, const Integer ZOrder)
Creates an additional Viewport within a created render window.
Definition: gamewindow.cpp:201
static GraphicsManager * GetSingletonPtr()
Fetches a pointer to the singleton.
Definition: singleton.h:97
This class is for creating and managing viewports within a game window.
Definition: viewport.h:65
Whole GetFSAALevel() const
Gets the last set Anti-Aliasing level on this Window.
Definition: gamewindow.cpp:385
Whole Width
The pixel width of the window.
Definition: resolution.h:64
WindowSettings Settings
A struct storing all the window dimensions and update settings.
Definition: gamewindow.h:94
This file contains the declaration for the World proxy wrapping camera functionality.
Child node iterator (a bidirectional iterator over a collection of Node)
Definition: nodeiterator.h:77
Whole GetActualFSAALevel() const
Gets the actual Anti-Aliasing level currently being used by this game window.
Definition: gamewindow.cpp:388
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
iterator begin() const
Get a Child node iterator that references the first child Node.
Real GetBestFrameTime() const
Gets the shortest amount of time it's taken to render a frame.
Definition: gamewindow.cpp:424
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
ViewportContainer::const_reverse_iterator ConstReverseViewportIterator
Const Reverse Iterator type for Viewport instances stored by this class.
Definition: gamewindow.h:75
iterator end() const
Get a Child node iterator that references one past the last child Node.
ViewportContainer Viewports
A container storing all the viewports belonging to this window.
Definition: gamewindow.h:97
bool Empty() const
Is this storing anything at all?
ViewportContainer::const_iterator ConstViewportIterator
Const Iterator type for Viewport instances stored by this class.
Definition: gamewindow.h:71
void EnableVsync(Boole Enable)
Enables (or disables) vsync on this window.
Definition: gamewindow.cpp:391
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
Definition: gamewindow.cpp:433
void SetFSAALevel(const Whole FSAA)
Sets the level of Full Scale Anti-Aliasing to be used when rendering to this window.
Definition: gamewindow.cpp:382
Whole GetHeight() const
Gets the height of the game window.
Definition: gamewindow.cpp:291
This enables fullscreen on the window.
Definition: gamewindow.h:80
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:206
Whole GetWidth() const
Gets the Width of the game window.
Definition: gamewindow.cpp:285
This hides the window so that it isn't visible.
Definition: gamewindow.h:81
Real GetBestFPS() const
Gets the Best FPS.
Definition: gamewindow.cpp:418
This is the proxy class for placing and manipulating a camera in the scene.
Definition: cameraproxy.h:65
Boole VsyncEnabled() const
Gets whether or not vsync is currently enabled on this window.
Definition: gamewindow.cpp:394
SDL_Window * _GetSDLWindowPointer()
This will get a pointer to the SDL Window.
Definition: gamewindow.cpp:583
Whole GetNumViewports() const
Gets the number of viewports within this window.
Definition: gamewindow.cpp:229
Real GetWorstFrameTime() const
Gets the longest amount of time it's taken to render a frame.
Definition: gamewindow.cpp:427
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Whole RequestedFSAA
The last set FSAA level for this gamewindow (used for serialization).
Definition: gamewindow.h:109
Real GetWorstFPS() const
Gets the Worst FPS.
Definition: gamewindow.cpp:421
void DestroyAllViewports()
Destroys every viewport within this window.
Definition: gamewindow.cpp:246
~GameWindow()
Class destructor.
Definition: gamewindow.cpp:89
GraphicsManager * Manager
A pointer to the manager that created this window.
Definition: gamewindow.h:100
Resolution WinRes
This stores the Height and Width of the render window.
void SetFullscreen(const Boole Fullscreen)
Set the Fullscreen Setting.
Definition: gamewindow.cpp:327
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Boole GetFullscreen() const
Gets the Fullscreen Setting.
Definition: gamewindow.cpp:360
Enables Fullscreen Anti-Aliasing level 8 for the window.
Definition: gamewindow.h:85
Whole CreationFlags
A bit field containing all the flags used in the construction of this GameWindow. ...
Definition: gamewindow.h:112
Viewport * GetViewport(const Whole Index) const
Gets a viewport by index.
Definition: gamewindow.cpp:208
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Boole VSync
This is the desired state of whether to enable VSync or not.
Viewport * GetViewportByZOrder(const Integer ZOrder) const
Gets a viewport by ZOrder.
Definition: gamewindow.cpp:218
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
Node GetChild(const Char8 *Name) const
Attempt to get a child Node with a given name.
Maximizes the window immediately after construction.
Definition: gamewindow.h:88
const Resolution & GetResolution() const
Gets the width and height of the game window.
Definition: gamewindow.cpp:322
void SetResolution(const Whole ResWidth, const Whole ResHeight)
Sets the width and height of this resolution.
Definition: resolution.h:95