40 #ifndef _graphicsgamewindow_cpp
41 #define _graphicsgamewindow_cpp
43 #include "Graphics/gamewindow.h"
44 #include "Graphics/viewport.h"
46 #include "Graphics/graphicsmanager.h"
48 #include "crossplatform.h"
64 #include <Cocoa/Cocoa.h>
68 #include "../src/video/SDL_sysvideo.h"
94 SDL_WindowUserData* WindowData = this->
SDLWindow->data;
102 Ogre::Root::getSingleton().destroyRenderTarget(this->
OgreWindow);
117 Opts[
"hidden"] =
"true";
121 Opts[
"vsync"] =
"true";
136 Opts[
"border"] =
"resize";
138 Opts[
"border"] =
"none";
140 Opts[
"border"] =
"fixed";
148 Opts[
"macAPI"] =
"cocoa";
154 this->
OgreWindow = Ogre::Root::getSingleton().createRenderWindow(WindowCaption, this->
Settings.
WinRes.
Width, this->Settings.WinRes.Height, this->Settings.Fullscreen, &Opts);
167 this->
OgreWindow->getCustomAttribute(
"WINDOW",&Data);
168 this->
SDLWindow = SDL_CreateWindowFrom((
void*)Data);
169 this->
SDLWindow->data =
new SDL_WindowUserData();
180 if( (*ViewIt)->GetZOrder() > NewVP->
GetZOrder() ) {
222 if( (*ViewIt)->GetZOrder() == ZOrder ) {
238 if ( ToBeDestroyed == (*ViewIt) ) {
239 delete ToBeDestroyed;
301 SDL_DisplayMode CurrentDisplay;
302 SDL_GetWindowDisplayMode(
SDLWindow,&CurrentDisplay);
303 CurrentDisplay.w = Width;
304 CurrentDisplay.h = Height;
306 if(SDL_SetWindowDisplayMode(
SDLWindow,&CurrentDisplay) == 0) {
307 this->
OgreWindow->setFullscreen(
true,Width,Height);
312 SDL_SetWindowSize(
SDLWindow,Width,Height);
352 if(SDL_SetWindowFullscreen(
SDLWindow, Fullscreen?SDL_TRUE:SDL_FALSE ) == 0) {
392 { this->
OgreWindow->setVSyncEnabled(Enable); }
395 {
return this->
OgreWindow->isVSyncEnabled(); }
425 {
return this->
OgreWindow->getBestFrameTime(); }
428 {
return this->
OgreWindow->getWorstFrameTime(); }
473 (*ViewIt)->ProtoSerialize(ViewportsNode);
487 Ogre::Root::getSingleton().destroyRenderTarget(this->
OgreWindow);
494 if( !PropertiesNode.
Empty() ) {
497 Whole WinWidth = 0, WinHeight = 0, WinFlags = 0;
500 if( !CurrAttrib.
Empty() )
504 if( !CurrAttrib.
Empty() )
505 WinWidth = CurrAttrib.
AsWhole();
508 if( !CurrAttrib.
Empty() )
509 WinHeight = CurrAttrib.
AsWhole();
532 if( !CurrAttrib.
Empty() ) {
534 if( FSAALevel == 1 ) {
536 }
else if( FSAALevel == 2 ) {
538 }
else if( FSAALevel == 3 ) {
540 }
else if( FSAALevel == 4 ) {
561 if( !ViewportsNode.
Empty() ) {
575 {
return "GameWindow"; }
Creates a window with resizable borders, otherwise it is fixed size.
GameWindow(const String &WindowCaption, const Whole Width, const Whole Height, const Whole Flags)
Class constructor.
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.
Enables Fullscreen Anti-Aliasing level 4 for the window.
void DestroyViewport(Viewport *ToBeDestroyed)
Destroys a viewport within this window.
void SetHeight(const Whole &Height)
Sets the height of the game window.
Boole BorderIsResizeable() const
Gets whether or not this window has a resizeable border.
bool Boole
Generally acts a single bit, true or false.
Boole IsHidden() const
Gets whether this window is hidden.
SDL_Window * SDLWindow
A pointer to the internal window used for collecting input.
void CreateGameWindow(const String &WindowCaption, const Whole Width, const Whole Height, const Whole Flags)
Convenience method for constructing a window.
Enables Fullscreen Anti-Aliasing level 16 for the window.
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.
Ogre::RenderWindow * OgreWindow
A pointer to the internal window used for rendering.
const String & GetWindowCaption() const
Gets the the text in the titlebar.
void ProtoDeSerializeViewports(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the viewports of this object with it...
Whole Height
The pixel height of the window.
ViewportContainer::iterator ViewportIterator
Iterator type for Viewport instances stored by this class.
ViewportIterator BeginViewport()
Gets an iterator to the first viewport in this window.
Removes all window decorations from the window(titlebar, borders, etc.).
Thrown when the requested identity could not be found.
Integer GetZOrder() const
Gets the Zorder assigned to this viewport.
Real GetLastFPS() const
Gets the FPS based on the last frame rendered.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
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.
int Integer
A datatype used to represent any integer close to.
Boole IsBorderless() const
Gets whether this window is borderless.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
void SetWidth(const Whole &Width)
Sets the width of the game window.
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.
virtual void SetAspectRatio(const Real Ratio)
Sets the aspect ratio of the cameras veiw.
void SetHidden(Boole Hidden)
Hides (shows) the window.
This stores all the basic configuration options a game window supports.
Ogre::RenderWindow * _GetOgreWindowPointer()
This will get a pointer to the Ogre RenderWindow.
void SetResolution(const Resolution &WinRes)
Sets the width and height of the game window.
void ProtoSerializeProperties(XML::Node &SelfRoot) const
Convert the properties of this class to an XML::Node ready for serialization.
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...
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.
ReverseViewportIterator ReverseBeginViewport()
Gets an iterator to the last viewport in this window.
void UpdateViewportsAndCameras()
Updates all the viewports of this window and the cameras attached to them after a change in window ge...
const WindowSettings & GetSettings()
Gets the current window settings.
ViewportContainer::reverse_iterator ReverseViewportIterator
Reverse Iterator type for Viewport instances stored by this class.
float Real
A Datatype used to represent a real floating point number.
The interface for serialization.
ReverseViewportIterator ReverseEndViewport()
Gets an iterator to one before the first viewport in this window.
Enables Fullscreen Anti-Aliasing level 2 for the window.
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.
void ProtoDeSerializeProperties(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite the properties of this object with it...
ViewportIterator EndViewport()
Gets an iterator to one passed the last viewport in this window.
void SetRenderOptions(const WindowSettings &NewSettings)
Changes the X Resolution, Y Resolution, and fullscreen at the same time.
This enables vsync for the window.
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.
static GraphicsManager * GetSingletonPtr()
Fetches a pointer to the singleton.
This class is for creating and managing viewports within a game window.
Whole GetFSAALevel() const
Gets the last set Anti-Aliasing level on this Window.
Whole Width
The pixel width of the window.
WindowSettings Settings
A struct storing all the window dimensions and update settings.
This file contains the declaration for the World proxy wrapping camera functionality.
Child node iterator (a bidirectional iterator over a collection of Node)
Whole GetActualFSAALevel() const
Gets the actual Anti-Aliasing level currently being used by this game window.
A light-weight handle for manipulating nodes in DOM tree.
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.
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.
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.
bool Empty() const
Is this storing anything at all?
ViewportContainer::const_iterator ConstViewportIterator
Const Iterator type for Viewport instances stored by this class.
void EnableVsync(Boole Enable)
Enables (or disables) vsync on this window.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
void SetFSAALevel(const Whole FSAA)
Sets the level of Full Scale Anti-Aliasing to be used when rendering to this window.
Whole GetHeight() const
Gets the height of the game window.
This enables fullscreen on the window.
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Whole GetWidth() const
Gets the Width of the game window.
This hides the window so that it isn't visible.
Real GetBestFPS() const
Gets the Best FPS.
This is the proxy class for placing and manipulating a camera in the scene.
Boole VsyncEnabled() const
Gets whether or not vsync is currently enabled on this window.
SDL_Window * _GetSDLWindowPointer()
This will get a pointer to the SDL Window.
Whole GetNumViewports() const
Gets the number of viewports within this window.
Real GetWorstFrameTime() const
Gets the longest amount of time it's taken to render a frame.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Whole RequestedFSAA
The last set FSAA level for this gamewindow (used for serialization).
Real GetWorstFPS() const
Gets the Worst FPS.
void DestroyAllViewports()
Destroys every viewport within this window.
~GameWindow()
Class destructor.
GraphicsManager * Manager
A pointer to the manager that created this window.
Resolution WinRes
This stores the Height and Width of the render window.
void SetFullscreen(const Boole Fullscreen)
Set the Fullscreen Setting.
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.
Enables Fullscreen Anti-Aliasing level 8 for the window.
Whole CreationFlags
A bit field containing all the flags used in the construction of this GameWindow. ...
Viewport * GetViewport(const Whole Index) const
Gets a viewport by index.
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.
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.
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.
const Resolution & GetResolution() const
Gets the width and height of the game window.
void SetResolution(const Whole ResWidth, const Whole ResHeight)
Sets the width and height of this resolution.