nCine::Backends::GlfwGfxDevice class

GLFW-based graphics device.

Creates and manages the application window and OpenGL context using the cross-platform GLFW library, and handles resolution, video modes and monitor enumeration.

Base classes

class nCine::IGfxDevice
Represents the interface to the graphics device where everything is rendered.

Constructors, destructors, conversion operators

GlfwGfxDevice(const WindowMode& windowMode, const ContextInfo& contextInfo, const DisplayMode& displayMode)
~GlfwGfxDevice() override

Public functions

void SetSwapInterval(int interval) override
Sets the number of vertical blanks to occur before a buffer swap.
void SetResolution(bool fullscreen, int width = 0, int height = 0) override
Sets the screen resolution with two integers.
void Update() override
Updates the screen by swapping the back and front buffers.
void SetWindowPosition(int x, int y) override
Sets the position of the application window with two integers.
void SetWindowSize(int width, int height) override
Sets the window size with two integers.
void SetWindowTitle(StringView windowTitle) override
Sets the application window title.
void SetWindowIcon(StringView iconFilename) override
Sets the application window icon.
auto GetWindowPosition() const -> const Vector2i override
Returns the window position as a Vector2i object.
void FlashWindow() const override
Highlights the application window to notify the user.
auto GetPrimaryMonitorIndex() const -> unsigned int override
Returns the array index of the primary monitor.
auto GetWindowMonitorIndex() const -> unsigned int override
Returns the array index of the monitor associated with the window.
auto GetCurrentVideoMode(unsigned int monitorIndex) const -> const VideoMode& override
Returns the current video mode for the specified monitor.
auto SetVideoMode(unsigned int modeIndex) -> bool override
Sets the video mode used in full screen by the monitor that hosts the window.
auto SupportsAuxiliaryWindows() const -> bool override
Returns true if windows besides the main one can be made, see CreateAuxiliaryWindow().
auto CreateAuxiliaryWindow(const AuxiliaryWindowDesc& desc) -> std::unique_ptr<AuxiliaryWindow> override
Makes a hidden window besides the main one, nullptr if it can't be made, see AuxiliaryWindow.
auto GetGlobalMousePosition(Vector2i& position) const -> bool override
Returns the position of the pointer on the desktop in pixels, false if it isn't known.
auto GetWindowContentScale() const -> float override
Returns the scale of the display the main window is on, 1 for 100 %, see AuxiliaryWindow::GetContentScale().
auto GetGlobalMouseButtons(std::uint32_t& buttons) const -> bool override
Returns the mouse buttons held now as the system has them, false if it isn't known.
auto GetDesktopWorkArea(Vector2i point, Recti& area) const -> bool override
Returns the part of the display at a point of the desktop that windows may take, without the taskbar.

Protected functions

void SetResolutionInternal(int width, int height) override
void UpdateMonitors() override
Updates the array of connected monitors.

Function documentation

void nCine::Backends::GlfwGfxDevice::SetSwapInterval(int interval) override

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::Backends::GlfwGfxDevice::SetWindowSize(int width, int height) override

Sets the window size with two integers.

bool nCine::Backends::GlfwGfxDevice::SetVideoMode(unsigned int modeIndex) override

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

bool nCine::Backends::GlfwGfxDevice::SupportsAuxiliaryWindows() const override

Returns true if windows besides the main one can be made, see CreateAuxiliaryWindow().

Only desktop systems where windows can be placed anywhere have them, with a graphics backend that can present into another window.

float nCine::Backends::GlfwGfxDevice::GetWindowContentScale() const override

Returns the scale of the display the main window is on, 1 for 100 %, see AuxiliaryWindow::GetContentScale().

By default it's how many pixels the main window has for a unit of the desktop.

bool nCine::Backends::GlfwGfxDevice::GetGlobalMouseButtons(std::uint32_t& buttons) const override

Returns the mouse buttons held now as the system has them, false if it isn't known.

Bits 0, 1 and 2 are the left, the right and the middle button. Unlike the events, it's never left behind when a release goes to a window of the application that was just shown or moved under the pointer.

bool nCine::Backends::GlfwGfxDevice::GetDesktopWorkArea(Vector2i point, Recti& area) const override

Returns the part of the display at a point of the desktop that windows may take, without the taskbar.

The display nearest to the point if it's on none. In units of the desktop, as positions of windows are. Returns false if it isn't known.