Saga3D API Documentation  1.0-RC4
saga::SagaDevice Class Referenceabstract

The Irrlicht device. You can create it with createDevice() or createDeviceEx(). More...

#include <SagaDevice.h>

Public Member Functions

virtual ~SagaDevice ()
 
virtual bool run ()=0
 Runs the device. More...
 
virtual void yield ()=0
 Cause the device to temporarily pause execution for 500ms and let other processes run. More...
 
virtual void sleep (std::uint32_t timeMs)=0
 Pause execution and let other processes to run for a specified amount of time. More...
 
virtual std::uint32_t getTime () const =0
 Returns time elapsed in milliseconds since initialization. More...
 
virtual const std::shared_ptr< video::IVideoDriver > & getVideoDriver () const =0
 Provides access to the video driver for drawing 3d and 2d geometry. More...
 
virtual const std::shared_ptr< scene::ISceneManager > & getSceneManager () const =0
 Provides access to the scene manager. More...
 
virtual void addEventReceiver (IEventReceiver *receiver)=0
 Register your event listener, which receives SDL_Event. More...
 
virtual void setWindowCaption (const std::string &text)=0
 Sets the caption of the window. More...
 
virtual bool isWindowActive () const =0
 Returns if the window is active. More...
 
virtual bool isWindowFocused () const =0
 Checks if the Irrlicht window has focus. More...
 
virtual bool isWindowMinimized () const =0
 Checks if the Irrlicht window is minimized. More...
 
virtual bool isFullscreen () const =0
 Checks if the Irrlicht window is running in fullscreen mode. More...
 
virtual void closeDevice ()=0
 Notifies the device that it should close itself. More...
 
virtual void setResizable (bool resize=false)=0
 Sets if the window should be resizable in windowed mode. More...
 
virtual std::uint32_t getWidth () const =0
 Get window's width. More...
 
virtual std::uint32_t getHeight () const =0
 Get window's height. More...
 
virtual float getAspectRatio () const =0
 Get aspect ratio. More...
 
virtual void setWindowSize (const glm::uvec2 &size)=0
 Resize the render window. More...
 
virtual void minimizeWindow ()=0
 Minimizes the window if possible. More...
 
virtual void maximizeWindow ()=0
 Maximizes the window if possible. More...
 
virtual void restoreWindow ()=0
 Restore the window to normal size if possible. More...
 
virtual glm::ivec2 getWindowPosition ()=0
 Get the position of the frame on-screen. More...
 

Detailed Description

The Irrlicht device. You can create it with createDevice() or createDeviceEx().

This is the most important class of the Irrlicht Engine. You can access everything in the engine if you have a pointer to an instance of this class. There should be only one instance of this class at any time.

Definition at line 35 of file SagaDevice.h.

Constructor & Destructor Documentation

◆ ~SagaDevice()

virtual saga::SagaDevice::~SagaDevice ( )
inlinevirtual

Definition at line 39 of file SagaDevice.h.

Member Function Documentation

◆ addEventReceiver()

virtual void saga::SagaDevice::addEventReceiver ( IEventReceiver receiver)
pure virtual

Register your event listener, which receives SDL_Event.

Parameters
receiverobject whose class is derived from IEventReceiver

◆ closeDevice()

virtual void saga::SagaDevice::closeDevice ( )
pure virtual

Notifies the device that it should close itself.

IrrlichtDevice::run() will always return false after closeDevice() was called.

◆ getAspectRatio()

virtual float saga::SagaDevice::getAspectRatio ( ) const
pure virtual

Get aspect ratio.

◆ getHeight()

virtual std::uint32_t saga::SagaDevice::getHeight ( ) const
pure virtual

Get window's height.

◆ getSceneManager()

virtual const std::shared_ptr<scene::ISceneManager>& saga::SagaDevice::getSceneManager ( ) const
pure virtual

Provides access to the scene manager.

Returns
Pointer to the scene manager.

◆ getTime()

virtual std::uint32_t saga::SagaDevice::getTime ( ) const
pure virtual

Returns time elapsed in milliseconds since initialization.

Returns
Time in milliseconds

◆ getVideoDriver()

virtual const std::shared_ptr<video::IVideoDriver>& saga::SagaDevice::getVideoDriver ( ) const
pure virtual

Provides access to the video driver for drawing 3d and 2d geometry.

Returns
Pointer the video driver.

◆ getWidth()

virtual std::uint32_t saga::SagaDevice::getWidth ( ) const
pure virtual

Get window's width.

◆ getWindowPosition()

virtual glm::ivec2 saga::SagaDevice::getWindowPosition ( )
pure virtual

Get the position of the frame on-screen.

◆ isFullscreen()

virtual bool saga::SagaDevice::isFullscreen ( ) const
pure virtual

Checks if the Irrlicht window is running in fullscreen mode.

Returns
True if window is fullscreen.

◆ isWindowActive()

virtual bool saga::SagaDevice::isWindowActive ( ) const
pure virtual

Returns if the window is active.

If the window is inactive, nothing needs to be drawn. So if you don't want to draw anything when the window is inactive, create your drawing loop this way:

while(device->run())
{
if (device->isWindowActive())
{
// draw everything here
}
else
device->yield();
}
Returns
True if window is active.

◆ isWindowFocused()

virtual bool saga::SagaDevice::isWindowFocused ( ) const
pure virtual

Checks if the Irrlicht window has focus.

Returns
True if window has focus.

◆ isWindowMinimized()

virtual bool saga::SagaDevice::isWindowMinimized ( ) const
pure virtual

Checks if the Irrlicht window is minimized.

Returns
True if window is minimized.

◆ maximizeWindow()

virtual void saga::SagaDevice::maximizeWindow ( )
pure virtual

Maximizes the window if possible.

◆ minimizeWindow()

virtual void saga::SagaDevice::minimizeWindow ( )
pure virtual

Minimizes the window if possible.

◆ restoreWindow()

virtual void saga::SagaDevice::restoreWindow ( )
pure virtual

Restore the window to normal size if possible.

◆ run()

virtual bool saga::SagaDevice::run ( )
pure virtual

Runs the device.

Also increments the virtual timer by calling ITimer::tick();. You can prevent this by calling ITimer::stop(); before and ITimer::start() after calling IrrlichtDevice::run(). Returns false if device wants to be deleted. Use it in this way:

while(device->run())
{
// draw everything here
}

If you want the device to do nothing if the window is inactive (recommended), use the slightly enhanced code shown at isWindowActive().

Note if you are running Irrlicht inside an external, custom created window: Calling Device->run() will cause Irrlicht to dispatch windows messages internally. If you are running Irrlicht in your own custom window, you can also simply use your own message loop using GetMessage, DispatchMessage and whatever and simply don't use this method. But note that Irrlicht will not be able to fetch user input then. See saga::SDeviceCreationParameters::WindowId for more information and example code.

◆ setResizable()

virtual void saga::SagaDevice::setResizable ( bool  resize = false)
pure virtual

Sets if the window should be resizable in windowed mode.

The default is false. This method only works in windowed mode.

Parameters
resizeFlag whether the window should be resizable.

◆ setWindowCaption()

virtual void saga::SagaDevice::setWindowCaption ( const std::string &  text)
pure virtual

Sets the caption of the window.

Parameters
textNew text of the window caption.

◆ setWindowSize()

virtual void saga::SagaDevice::setWindowSize ( const glm::uvec2 &  size)
pure virtual

Resize the render window.

This will only work in windowed mode and is not yet supported on all systems. It does set the drawing/clientDC size of the window, the window decorations are added to that. You get the current window size with IVideoDriver::getScreenSize() (might be unified in future)

◆ sleep()

virtual void saga::SagaDevice::sleep ( std::uint32_t  timeMs)
pure virtual

Pause execution and let other processes to run for a specified amount of time.

It may not wait the full given time, as sleep may be interrupted

Parameters
timeMsTime to sleep for in milliseconds.

◆ yield()

virtual void saga::SagaDevice::yield ( )
pure virtual

Cause the device to temporarily pause execution for 500ms and let other processes run.

This should bring down processor usage without major performance loss


The documentation for this class was generated from the following file: