Nirtcpp 2.0.0
Nirtcpp is a high-performance c++ graphics engine.
nirt::NirtcppDevice Class Referenceabstract

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

#include <nirtcpp/NirtcppDevice.hpp>

Inheritance diagram for nirt::NirtcppDevice:
Inheritance graph
Collaboration diagram for nirt::NirtcppDevice:
Collaboration graph

Public Member Functions

virtual bool run ()=0
 Runs the device. More...
 
virtual void yield ()=0
 Cause the device to temporarily pause execution and let other processes run. More...
 
virtual void sleep (u32 timeMs, bool pauseTimer=false)=0
 Pause execution and let other processes to run for a specified amount of time. More...
 
virtual video::IVideoDrivergetVideoDriver ()=0
 Provides access to the video driver for drawing 3d and 2d geometry. More...
 
virtual io::IFileSystemgetFileSystem ()=0
 Provides access to the virtual file system. More...
 
virtual gui::IGUIEnvironmentgetGUIEnvironment ()=0
 Provides access to the 2d user interface environment. More...
 
virtual scene::ISceneManagergetSceneManager ()=0
 Provides access to the scene manager. More...
 
virtual gui::ICursorControlgetCursorControl ()=0
 Provides access to the cursor control. More...
 
virtual ILoggergetLogger ()=0
 Provides access to the message logger. More...
 
virtual video::IVideoModeListgetVideoModeList ()=0
 Gets a list with all video modes available. More...
 
virtual video::IContextManagergetContextManager ()=0
 Get context manager.
 
virtual IOSOperatorgetOSOperator ()=0
 Provides access to the operation system operator object. More...
 
virtual ITimergetTimer ()=0
 Provides access to the engine's timer. More...
 
virtual IRandomizergetRandomizer () const =0
 Provides access to the engine's currently set randomizer. More...
 
virtual void setRandomizer (IRandomizer *r)=0
 Sets a new randomizer. More...
 
virtual IRandomizercreateDefaultRandomizer () const =0
 Creates a new default randomizer. More...
 
virtual void setWindowCaption (const wchar_t *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 Nirtcpp window has the input focus. More...
 
virtual bool isWindowMinimized () const =0
 Checks if the Nirtcpp window is minimized. More...
 
virtual bool isFullscreen () const =0
 Checks if the Nirtcpp window is running in fullscreen mode. More...
 
virtual video::ECOLOR_FORMAT getColorFormat () const =0
 Get the current color format of the window. More...
 
virtual void closeDevice ()=0
 Notifies the device that it should close itself. More...
 
virtual const c8getVersion () const =0
 Get the version of the engine. More...
 
virtual void setEventReceiver (IEventReceiver *receiver)=0
 Sets a new user event receiver which will receive events from the engine. More...
 
virtual IEventReceivergetEventReceiver ()=0
 Provides access to the current event receiver. More...
 
virtual bool postEventFromUser (const SEvent &event)=0
 Sends a user created event to the engine. More...
 
virtual void setInputReceivingSceneManager (scene::ISceneManager *sceneManager)=0
 Sets the input receiving scene manager. More...
 
virtual void setResizable (bool resize=false)=0
 Sets if the window should be resizable in windowed mode. More...
 
virtual void setWindowSize (const nirt::core::dimension2d< u32 > &size)=0
 Resize the render window. More...
 
virtual void minimizeWindow ()=0
 Minimizes the window if possible.
 
virtual void maximizeWindow ()=0
 Maximizes the window if possible.
 
virtual void restoreWindow ()=0
 Restore the window to normal size if possible.
 
virtual core::position2di getWindowPosition ()=0
 Get the position of the frame on-screen.
 
virtual bool activateJoysticks (core::array< SJoystickInfo > &joystickInfo)=0
 Activate any joysticks, and generate events for them. More...
 
virtual bool setGammaRamp (f32 red, f32 green, f32 blue, f32 relativebrightness, f32 relativecontrast)=0
 Set the current Gamma Value for the Display.
 
virtual bool getGammaRamp (f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast)=0
 Get the current Gamma Value for the Display.
 
virtual void setDoubleClickTime (u32 timeMs)=0
 Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. More...
 
virtual u32 getDoubleClickTime () const =0
 Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. More...
 
virtual void clearSystemMessages ()=0
 Remove messages pending in the system message loop. More...
 
virtual E_DEVICE_TYPE getType () const =0
 Get the type of the device. More...
 
- Public Member Functions inherited from nirt::IReferenceCounted
 IReferenceCounted ()
 Constructor.
 
virtual ~IReferenceCounted ()
 Destructor.
 
void grab () const
 Grabs the object. Increments the reference counter by one. More...
 
bool drop () const
 Drops the object. Decrements the reference counter by one. More...
 
s32 getReferenceCount () const
 Get the reference count. More...
 
const c8getDebugName () const
 Returns the debug name of the object. More...
 

Static Public Member Functions

static bool isDriverSupported (video::E_DRIVER_TYPE driver)
 Check if a driver type is supported by the engine. More...
 

Additional Inherited Members

- Protected Member Functions inherited from nirt::IReferenceCounted
void setDebugName (const c8 *newName)
 Sets the debug name of the object. More...
 

Detailed Description

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

This is the most important class of the Nirtcpp 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.

Member Function Documentation

◆ activateJoysticks()

virtual bool nirt::NirtcppDevice::activateJoysticks ( core::array< SJoystickInfo > &  joystickInfo)
pure virtual

Activate any joysticks, and generate events for them.

Nirtcpp contains support for joysticks, but does not generate joystick events by default, as this would consume joystick info that 3rd party libraries might rely on. Call this method to activate joystick support in Nirtcpp and to receive nirt::SJoystickEvent events.

Parameters
joystickInfoOn return, this will contain an array of each joystick that was found and activated.
Returns
true if joysticks are supported on this device and NIRT_COMPILE_WITH_JOYSTICK_EVENTS is defined, false if joysticks are not supported or support is compiled out.

◆ clearSystemMessages()

virtual void nirt::NirtcppDevice::clearSystemMessages ( )
pure virtual

Remove messages pending in the system message loop.

This function is usually used after messages have been buffered for a longer time, for example when loading a large scene. Clearing the message loop prevents that mouse- or buttonclicks which users have pressed in the meantime will now trigger unexpected actions in the gui.
So far the following messages are cleared:
Win32: All keyboard and mouse messages
Linux: All keyboard and mouse messages
All other devices are not yet supported here.
The function is still somewhat experimental, as the kind of messages we clear is based on just a few use-cases. If you think further messages should be cleared, or some messages should not be cleared here, then please tell us.

◆ closeDevice()

virtual void nirt::NirtcppDevice::closeDevice ( )
pure virtual

Notifies the device that it should close itself.

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

◆ createDefaultRandomizer()

virtual IRandomizer * nirt::NirtcppDevice::createDefaultRandomizer ( ) const
pure virtual

Creates a new default randomizer.

The default randomizer provides the random sequence known from previous Nirtcpp versions and is the initial randomizer set on device creation.

Returns
Pointer to the default IRandomizer object.

◆ getColorFormat()

virtual video::ECOLOR_FORMAT nirt::NirtcppDevice::getColorFormat ( ) const
pure virtual

Get the current color format of the window.

Returns
Color format of the window.

◆ getCursorControl()

virtual gui::ICursorControl * nirt::NirtcppDevice::getCursorControl ( )
pure virtual

Provides access to the cursor control.

Returns
Pointer to the mouse cursor control interface.

◆ getDoubleClickTime()

virtual u32 nirt::NirtcppDevice::getDoubleClickTime ( ) const
pure virtual

Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse.

When return value is 0 no double- and tripleclicks will be generated.

Returns
maximal time in milliseconds for two consecutive clicks to be recognized as double click

◆ getEventReceiver()

virtual IEventReceiver * nirt::NirtcppDevice::getEventReceiver ( )
pure virtual

Provides access to the current event receiver.

Returns
Pointer to the current event receiver. Returns 0 if there is none.

◆ getFileSystem()

virtual io::IFileSystem * nirt::NirtcppDevice::getFileSystem ( )
pure virtual

Provides access to the virtual file system.

Returns
Pointer to the file system.

◆ getGUIEnvironment()

virtual gui::IGUIEnvironment * nirt::NirtcppDevice::getGUIEnvironment ( )
pure virtual

Provides access to the 2d user interface environment.

Returns
Pointer to the gui environment.

◆ getLogger()

virtual ILogger * nirt::NirtcppDevice::getLogger ( )
pure virtual

Provides access to the message logger.

Returns
Pointer to the logger.

◆ getOSOperator()

virtual IOSOperator * nirt::NirtcppDevice::getOSOperator ( )
pure virtual

Provides access to the operation system operator object.

The OS operator provides methods for getting system specific information and doing system specific operations, such as exchanging data with the clipboard or reading the operation system version.

Returns
Pointer to the OS operator.

◆ getRandomizer()

virtual IRandomizer * nirt::NirtcppDevice::getRandomizer ( ) const
pure virtual

Provides access to the engine's currently set randomizer.

Returns
Pointer to the IRandomizer object.

◆ getSceneManager()

virtual scene::ISceneManager * nirt::NirtcppDevice::getSceneManager ( )
pure virtual

Provides access to the scene manager.

Returns
Pointer to the scene manager.

◆ getTimer()

virtual ITimer * nirt::NirtcppDevice::getTimer ( )
pure virtual

Provides access to the engine's timer.

The system time can be retrieved by it as well as the virtual time, which also can be manipulated.

Returns
Pointer to the ITimer object.

◆ getType()

virtual E_DEVICE_TYPE nirt::NirtcppDevice::getType ( ) const
pure virtual

Get the type of the device.

This allows the user to check which windowing system is currently being used.

◆ getVersion()

virtual const c8 * nirt::NirtcppDevice::getVersion ( ) const
pure virtual

Get the version of the engine.

The returned string will look like this: "1.2.3" or this: "1.2".

Returns
String which contains the version.

◆ getVideoDriver()

virtual video::IVideoDriver * nirt::NirtcppDevice::getVideoDriver ( )
pure virtual

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

Returns
Pointer the video driver.

◆ getVideoModeList()

virtual video::IVideoModeList * nirt::NirtcppDevice::getVideoModeList ( )
pure virtual

Gets a list with all video modes available.

You only need a null driver (ED_NULL) to access those video modes. So you can get the available modes before starting any other video driver.

Returns
Pointer to a list with all video modes supported by the gfx adapter.

◆ isDriverSupported()

static bool nirt::NirtcppDevice::isDriverSupported ( video::E_DRIVER_TYPE  driver)
inlinestatic

Check if a driver type is supported by the engine.

Even if true is returned the driver may not be available for a configuration requested when creating the device.

◆ isFullscreen()

virtual bool nirt::NirtcppDevice::isFullscreen ( ) const
pure virtual

Checks if the Nirtcpp window is running in fullscreen mode.

Returns
True if window is fullscreen.

◆ isWindowActive()

virtual bool nirt::NirtcppDevice::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 nirt::NirtcppDevice::isWindowFocused ( ) const
pure virtual

Checks if the Nirtcpp window has the input focus.

Returns
True if window has focus.

◆ isWindowMinimized()

virtual bool nirt::NirtcppDevice::isWindowMinimized ( ) const
pure virtual

Checks if the Nirtcpp window is minimized.

Returns
True if window is minimized.

◆ postEventFromUser()

virtual bool nirt::NirtcppDevice::postEventFromUser ( const SEvent event)
pure virtual

Sends a user created event to the engine.

Is is usually not necessary to use this. However, if you are using an own input library for example for doing joystick input, you can use this to post key or mouse input events to the engine. Internally, this method only delegates the events further to the scene manager and the GUI environment.

◆ run()

virtual bool nirt::NirtcppDevice::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 NirtcppDevice::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 Nirtcpp inside an external, custom created window: Calling Device->run() will cause Nirtcpp to dispatch windows messages internally. If you are running Nirtcpp 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 Nirtcpp will not be able to fetch user input then. See nirt::SNirtcppCreationParameters::WindowId for more information and example code.

◆ setDoubleClickTime()

virtual void nirt::NirtcppDevice::setDoubleClickTime ( u32  timeMs)
pure virtual

Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior.

When set to 0 no double- and tripleclicks will be generated.

Parameters
timeMsmaximal time in milliseconds for two consecutive clicks to be recognized as double click

◆ setEventReceiver()

virtual void nirt::NirtcppDevice::setEventReceiver ( IEventReceiver receiver)
pure virtual

Sets a new user event receiver which will receive events from the engine.

Return true in IEventReceiver::OnEvent to prevent the event from continuing along the chain of event receivers. The path that an event takes through the system depends on its type. See nirt::EEVENT_TYPE for details.

Parameters
receiverNew receiver to be used.

◆ setInputReceivingSceneManager()

virtual void nirt::NirtcppDevice::setInputReceivingSceneManager ( scene::ISceneManager sceneManager)
pure virtual

Sets the input receiving scene manager.

If set to null, the main scene manager (returned by GetSceneManager()) will receive the input

Parameters
sceneManagerNew scene manager to be used.

◆ setRandomizer()

virtual void nirt::NirtcppDevice::setRandomizer ( IRandomizer r)
pure virtual

Sets a new randomizer.

Parameters
rPointer to the new IRandomizer object. This object is grab()'ed by the engine and will be released upon the next setRandomizer call or upon device destruction.

◆ setResizable()

virtual void nirt::NirtcppDevice::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 nirt::NirtcppDevice::setWindowCaption ( const wchar_t *  text)
pure virtual

Sets the caption of the window.

Parameters
textNew text of the window caption.

◆ setWindowSize()

virtual void nirt::NirtcppDevice::setWindowSize ( const nirt::core::dimension2d< u32 > &  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 nirt::NirtcppDevice::sleep ( u32  timeMs,
bool  pauseTimer = false 
)
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.
pauseTimerIf true, pauses the device timer while sleeping

◆ yield()

virtual void nirt::NirtcppDevice::yield ( )
pure virtual

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

This should bring down processor usage without major performance loss for Nirtcpp


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