nCine::IGfxDevice class

Represents the interface to the graphics device where everything is rendered.

Derived classes

class EglGfxDevice
The EGL based graphics device.
class GlfwGfxDevice
The GLFW based graphics device.
class Qt5GfxDevice
The Qt5 based graphics device.
class SdlGfxDevice
The SDL based graphics device.
class UwpGfxDevice
The UWP graphics device (ANGLE/Mesa)

Public types

struct GLContextInfo
Contains the attributes to create an OpenGL context.
struct Monitor
A structure representing a connected monitor.
struct VideoMode
A structure representing a video mode supported by a monitor.
struct WindowMode
A structure used to initialize window properties.

Public static variables

static unsigned int MaxMonitors constexpr
static unsigned int MaxVideoModes constexpr

Constructors, destructors, conversion operators

IGfxDevice(const WindowMode& windowMode, const GLContextInfo& glContextInfo, const DisplayMode& displayMode)
~IGfxDevice() virtual

Public functions

void setSwapInterval(int interval) pure virtual
Sets the number of vertical blanks to occur before a buffer swap.
auto isFullscreen() const -> bool
Returns true if the device renders in full screen.
void setResolution(bool fullscreen, int width = 0, int height = 0) pure virtual
Sets screen resolution with two integers.
void setWindowPosition(int x, int y) pure virtual
Sets the position of the application window with two integers.
void setWindowPosition(Vector2i position)
Sets the position of the application window with a Vector2<int> object.
void setWindowTitle(StringView windowTitle) pure virtual
Sets the application window title.
void setWindowIcon(StringView iconFilename) pure virtual
Sets the application window icon.
auto width() const -> int
Returns the window or video mode width in screen coordinates.
auto height() const -> int
Returns the window or video mode height in screen coordinates.
auto resolution() const -> Vector2i
Returns the window or video mode resolution in screen coordinates as a Vector2i object.
auto screenRect() const -> Rectf
Returns the window or video mode resolution in screen coordinates as a Rectf object.
auto aspect() const -> float
Returns the window or video mode resolution aspect ratio.
void setWindowSize(int width, int height) pure virtual
Sets the window size with two integers.
auto windowPosition() const -> const Vector2i virtual
Returns window position as a Vector2i object.
auto drawableWidth() const -> int
Returns the window width in pixels.
auto drawableHeight() const -> int
Returns the window height in pixels.
auto drawableResolution() const -> Vector2i
Returns the window resolution in pixels as a Vector2i object.
auto drawableScreenRect() const -> Rectf
Returns the window resolution in pixels as a Rectf object.
auto drawableAspect() const -> float
Returns the window drawable resolution aspect ratio.
void flashWindow() const virtual
Highlights the application window to notify the user.
auto glContextInfo() const -> const GLContextInfo&
Returns the OpenGL context creation attributes.
auto displayMode() const -> const DisplayMode&
Returns display mode.
auto numMonitors() const -> unsigned int
Returns the number of connected monitors.
auto primaryMonitorIndex() const -> unsigned int virtual
Returns the array index of the primary monitor.
auto windowMonitorIndex() const -> unsigned int virtual
Returns the array index of the monitor associated with the window.
auto monitor(unsigned int index) const -> const Monitor&
Returns the specified monitor.
auto monitor() const -> const Monitor&
Returns the monitor that hosts the window.
auto currentVideoMode(unsigned int monitorIndex) const -> const VideoMode& pure virtual
Returns the current video mode for the specified monitor.
auto currentVideoMode() const -> const VideoMode&
Returns the current video mode for the monitor that hosts the window.
auto setVideoMode(unsigned int modeIndex) -> bool virtual
Sets the video mode that will be used in full screen by the monitor that hosts the window.
auto windowScalingFactor() const -> float
Returns the scaling factor for application window.

Protected functions

void initGLViewport()
Inits the OpenGL viewport based on the drawable resolution.
void updateMonitors() virtual
Updates the array of connected monitors.
void setResolutionInternal(int width, int height) pure virtual

Protected static variables

static float DefaultDPI constexpr

Protected variables

int width_
Window width in screen coordinates.
int height_
Window height in screen coordinates.
int drawableWidth_
Window width in pixels (for HiDPI screens)
int drawableHeight_
Window height in pixels (for HiDPI screens)
bool isFullscreen_
Whether rendering occurs in full screen.
GLContextInfo glContextInfo_
OpenGL context creation attributes.
DisplayMode displayMode_
Display properties.
Monitor monitors_
unsigned int numMonitors_
VideoMode currentVideoMode_
Used as a cache to avoid searching the current video mode in a monitor's array.

Private functions

void setupGL() virtual
Sets up the initial OpenGL state for the scenegraph.
void update() pure virtual
Updates the screen swapping back and front buffers.

Function documentation

void nCine::IGfxDevice::setSwapInterval(int interval) pure virtual

Sets the number of vertical blanks to occur before a buffer swap.

An interval of -1 will enable adaptive v-sync if available

void nCine::IGfxDevice::setWindowSize(int width, int height) pure virtual

Sets the window size with two integers.

int nCine::IGfxDevice::drawableWidth() const

Returns the window width in pixels.

It may differs from width() on HiDPI screens

int nCine::IGfxDevice::drawableHeight() const

Returns the window height in pixels.

It may differs from height() on HiDPI screens

bool nCine::IGfxDevice::setVideoMode(unsigned int modeIndex) virtual

Sets the video mode that will be used in full screen by the monitor that hosts the window.