![]() |
SGCT master (487fac4)
Simple Graphics Cluster Toolkit
|
The Engine class is the central part of SGCT and handles most of the callbacks, rendering, network handling, input devices, etc. More...
#include <sgct/engine.h>
Classes | |
| struct | Statistics |
| Structure with all statistics gathered about different frametimes. More... | |
| struct | Settings |
| struct | Callbacks |
| This struct holds all of the callback functions that can be used by the client library to be called during the different times of the frame. More... | |
Public Types | |
| using | DrawFunction = void (*)(const RenderData&) |
Public Member Functions | |
| void | terminate () |
| Signals to SGCT that the application should be terminated at the end of the next frame. | |
| void | exec () |
| This function starts the SGCT render loop in which the rendering, synchronization, event handling, and everything else happens. | |
| const Statistics & | statistics () const |
| Returns the Engine::Statistics object that contains all collected information about the frametimes, drawtimes, and other frame-based statistics. | |
| float | nearClipPlane () const |
| Returns the distance to the near clipping plane in meters. | |
| float | farClipPlane () const |
| Returns the distance to the far clipping plane in meters. | |
| void | setNearAndFarClippingPlanes (float nearClippingPlane, float farClippingPlane) |
| Set the near and far clipping planes. | |
| void | updateFrustums () const |
| This functions updates the frustum of all viewports. | |
| const Window * | focusedWindow () const |
| Return the Window that currently has the focus. | |
| void | setStatsGraphVisibility (bool value) |
| Determines whether the graph displaying the rendering stats is being displayed or not. | |
| float | statsGraphScale () const |
| Returns the current scaling value used to render the statistics graphs if they are enabled. | |
| void | setStatsGraphScale (float scale) |
| Sets the new scaling value for the statistics graph rendering. | |
| vec2 | statsGraphOffset () const |
| Returns the current offset value used to render the statistics graphics away from the center of the screen if they are enabled. | |
| void | setStatsGraphOffset (vec2 offset) |
| Sets the new offet value for the statistics graph rendering. | |
| void | takeScreenshot (std::vector< int > windowIds=std::vector< int >()) |
| Takes an RGBA screenshot and saves it as a PNG file. | |
| void | resetScreenshotNumber () |
| Resets the screenshot number to 0. | |
| void | setScreenshotNumber (unsigned int number) |
| Sets the number that the next screenshot will recieve with the next call of takeScreenshot. | |
| unsigned int | screenShotNumber () const |
| Returns the number the next screenshot will receive upon the next call of takeScreenshot. | |
| Engine::DrawFunction | drawFunction () const |
| This function returns the draw function to be used in internal classes that need to repeatedly call this. | |
| Engine::DrawFunction | draw2DFunction () const |
| const Node & | thisNode () const |
| Returns a reference to the node that represents this computer. | |
| const std::vector< std::unique_ptr< Window > > & | windows () const |
| Returns a list of all windows for the current node. | |
| bool | isMaster () const |
| Returns if this Node is the master in a clustered environment. | |
| unsigned int | currentFrameNumber () const |
| Returns the number of the current frame. | |
| void | setCapturePath (std::filesystem::path path) |
| Set capture/screenshot path used by SGCT. | |
| void | setCaptureFromBackBuffer (bool state) |
| Set if capture should capture warped from backbuffer instead of texture. | |
| StatisticsRenderer * | statisticsRenderer () |
| const Settings & | settings () const |
Static Public Member Functions | |
| static Engine & | instance () |
| Returns the global Engine object that is created through the Engine::create function. | |
| static void | create (config::Cluster cluster, Callbacks callbacks, const Configuration &arg) |
| Creates the singleton Engine that is accessible through the Engine::instance function. | |
| static void | destroy () |
| Destroys the singleton Engine instance that was created by Engine::create and that is accessible through the Engine::instance function. | |
| static User & | defaultUser () |
| Returns a pointer to the default user, i.e. | |
The Engine class is the central part of SGCT and handles most of the callbacks, rendering, network handling, input devices, etc.
| using sgct::Engine::DrawFunction = void (*)(const RenderData&) |
|
static |
Creates the singleton Engine that is accessible through the Engine::instance function.
This function can only be called while no Engine instance exists, which means that either it has to be the first call to this function or the destroy function was called in between.
| cluster | The configuration object for the config::Cluster that contains the information about how many nodes should exist, how many windows each node should contain and all other potential objects. The result of this is, in general, loaded from a configuration file |
| callbacks | The list of callbacks that should be registered and called during the frame and their correct times. All callbacks are optional |
| arg | The parameters that were set by the user from the commandline that can override some of the behavior from the configuration |
| unsigned int sgct::Engine::currentFrameNumber | ( | ) | const |
Returns the number of the current frame.
The frame number is a monotonically increasing number that will never be repeated.
|
static |
Returns a pointer to the default user, i.e.
the observer position.
|
static |
Destroys the singleton Engine instance that was created by Engine::create and that is accessible through the Engine::instance function.
If this function is called without a valid singleton existing, it is a no-op.
| Engine::DrawFunction sgct::Engine::draw2DFunction | ( | ) | const |
| Engine::DrawFunction sgct::Engine::drawFunction | ( | ) | const |
This function returns the draw function to be used in internal classes that need to repeatedly call this.
In general, there is no need for external applications to store the draw function, but they are free to do so.
| void sgct::Engine::exec | ( | ) |
This function starts the SGCT render loop in which the rendering, synchronization, event handling, and everything else happens.
Control will only return from this function after the program is terminated for any reason or if a non-recoverable error has occurred.
| float sgct::Engine::farClipPlane | ( | ) | const |
Returns the distance to the far clipping plane in meters.
| const Window * sgct::Engine::focusedWindow | ( | ) | const |
Return the Window that currently has the focus.
If no SGCT window has focus, a nullptr is returned.
|
static |
Returns the global Engine object that is created through the Engine::create function.
This function must only be called after the Engine::create function has been called successfully.
| std::logic_error | This error is thrown if this function is called before the Engine::create function is called or after the Engine::destroy function was called |
| bool sgct::Engine::isMaster | ( | ) | const |
| float sgct::Engine::nearClipPlane | ( | ) | const |
Returns the distance to the near clipping plane in meters.
| void sgct::Engine::resetScreenshotNumber | ( | ) |
Resets the screenshot number to 0.
| unsigned int sgct::Engine::screenShotNumber | ( | ) | const |
Returns the number the next screenshot will receive upon the next call of takeScreenshot.
This counter can be reset through setScreenshotNumber.
| void sgct::Engine::setCaptureFromBackBuffer | ( | bool | state | ) |
Set if capture should capture warped from backbuffer instead of texture.
Backbuffer data includes masks and warping.
| void sgct::Engine::setCapturePath | ( | std::filesystem::path | path | ) |
Set capture/screenshot path used by SGCT.
| path | The path including filename without suffix |
| void sgct::Engine::setNearAndFarClippingPlanes | ( | float | nearClippingPlane, |
| float | farClippingPlane ) |
Set the near and far clipping planes.
This operation recalculates all frustums for all viewports.
| nearClippingPlane | The near clipping plane in meters |
| farClippingPlane | The far clipping plane in meters |
| void sgct::Engine::setScreenshotNumber | ( | unsigned int | number | ) |
Sets the number that the next screenshot will recieve with the next call of takeScreenshot.
| number | The next screenshot number |
| void sgct::Engine::setStatsGraphOffset | ( | vec2 | offset | ) |
Sets the new offet value for the statistics graph rendering.
This value determines the placement of the center of the graphs on the screen and is usually in the range of [0,1]. If the statistics graph is currently not showing, calling this function will not have any effects.
| offset | The new offset value for the statistics graph rendering |
| void sgct::Engine::setStatsGraphScale | ( | float | scale | ) |
Sets the new scaling value for the statistics graph rendering.
This value must be in the range [0,1]. If the statistics graph is currently not showing, calling this function will not have any effects.
| scale | The new scaling value for the statistics graph rendering |
| void sgct::Engine::setStatsGraphVisibility | ( | bool | value | ) |
Determines whether the graph displaying the rendering stats is being displayed or not.
| value | The new desired state as to whether the statistics are being shown |
| const Settings & sgct::Engine::settings | ( | ) | const |
| const Statistics & sgct::Engine::statistics | ( | ) | const |
Returns the Engine::Statistics object that contains all collected information about the frametimes, drawtimes, and other frame-based statistics.
The reference returned by this function is valid until the Engine::destroy function is called.
| StatisticsRenderer * sgct::Engine::statisticsRenderer | ( | ) |
| vec2 sgct::Engine::statsGraphOffset | ( | ) | const |
Returns the current offset value used to render the statistics graphics away from the center of the screen if they are enabled.
If the statistics graphs are currently not shown, an error value of {-1, -1} is returned instead.
| float sgct::Engine::statsGraphScale | ( | ) | const |
Returns the current scaling value used to render the statistics graphs if they are enabled.
If the statistics graphs are currently not shown, an error value of -1 is returned instead.
| void sgct::Engine::takeScreenshot | ( | std::vector< int > | windowIds = std::vector< int >() | ) |
Takes an RGBA screenshot and saves it as a PNG file.
If stereo rendering is enabled then two screenshots will be saved per frame, one for each eye. The filename for each image is the window title with an incremental counter appended to it. Each successive call of this function will increment the counter. If it is desired to reset the counter, see setScreenshotNumber.
To record frames for a movie simply call this function every frame you wish to record. The write to disk is multi-threaded.
| void sgct::Engine::terminate | ( | ) |
Signals to SGCT that the application should be terminated at the end of the next frame.
| const Node & sgct::Engine::thisNode | ( | ) | const |
Returns a reference to the node that represents this computer.
| void sgct::Engine::updateFrustums | ( | ) | const |
This functions updates the frustum of all viewports.
If a viewport is tracked, this is done on the fly.
| const std::vector< std::unique_ptr< Window > > & sgct::Engine::windows | ( | ) | const |
Returns a list of all windows for the current node.
This vector might be empty, and is valid for the lifetime of the program until the Engine::destroy function is called.