IGfxDevice class
#include <nCine/Graphics/IGfxDevice.h>
Represents the interface to the graphics device where everything is rendered.
Abstracts the platform window and OpenGL context: it owns the window mode, the chosen display mode and the context creation attributes, exposes the window/drawable resolution used to set up the viewport, and enumerates the connected monitors and their video modes. Concrete back-ends (SDL, GLFW, Qt5, Android, ...) implement the platform-specific operations such as resolution changes and buffer swapping.
Derived classes
- class EglGfxDevice
- The EGL-based graphics device.
- class GlfwGfxDevice
- GLFW-based graphics device.
- class LibretroGfxDevice
- Graphics device presenting through the libretro frontend.
- class Qt5GfxDevice
- Graphics device that wraps a Qt5 Qt5Widget.
- class SdlGfxDevice
- SDL2-based graphics device.
- class UwpGfxDevice
- The UWP graphics device.
Public types
- struct WindowMode
- Initial properties of the application window.
- struct VideoMode
- Video mode supported by a monitor.
- struct Monitor
- Connected monitor.
- struct ContextInfo
- Attributes used to create an OpenGL context.
Public static variables
-
static std::
uint32_t MaxMonitors constexpr -
static std::
uint32_t MaxVideoModes constexpr
Constructors, destructors, conversion operators
- IGfxDevice(const WindowMode& windowMode, const ContextInfo& contextInfo, 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
trueif the device renders in full screen. - void SetResolution(bool fullscreen, int width = 0, int height = 0) pure virtual
- Sets the 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
Vector2iobject. - void SetWindowTitle(StringView windowTitle) pure virtual
- Sets the application window title.
- void SetWindowIcon(StringView iconFilename) pure virtual
- Sets the application window icon.
- auto GetWidth() const -> int
- Returns the window or video mode width in screen coordinates.
- auto GetHeight() const -> int
- Returns the window or video mode height in screen coordinates.
- auto GetResolution() const -> Vector2i
- Returns the window or video mode resolution in screen coordinates as a
Vector2iobject. - auto GetScreenRect() const -> Rectf
- Returns the window or video mode resolution in screen coordinates as a
Rectfobject. - auto GetAspect() 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.
- void SetDrawableSize(int width, int height) virtual
- Sets the pixel size of the drawable (the size the frame is rendered at) without touching the window.
- auto GetWindowPosition() const -> const Vector2i virtual
- Returns the window position as a
Vector2iobject. - auto GetDrawableWidth() const -> int
- Returns the window width in pixels.
- auto GetDrawableHeight() const -> int
- Returns the window height in pixels.
- auto GetDrawableResolution() const -> Vector2i
- Returns the window resolution in pixels as a
Vector2iobject. - auto GetDrawableScreenRect() const -> Rectf
- Returns the window resolution in pixels as a
Rectfobject. - auto GetDrawableAspect() const -> float
- Returns the window drawable resolution aspect ratio.
- auto GetDisplayAspect() const -> float virtual
- Returns the aspect ratio the drawable is actually DISPLAYED at.
- void FlashWindow() const virtual
- Highlights the application window to notify the user.
- auto GetContextInfo() const -> const ContextInfo&
- Returns the OpenGL context creation attributes.
- auto GetDisplayMode() const -> const DisplayMode&
- Returns the display mode.
- auto GetMonitorCount() const -> unsigned int
- Returns the number of connected monitors.
- auto GetPrimaryMonitorIndex() const -> unsigned int virtual
- Returns the array index of the primary monitor.
- auto GetWindowMonitorIndex() const -> unsigned int virtual
- Returns the array index of the monitor associated with the window.
- auto GetMonitor(unsigned int index) const -> const Monitor&
- Returns the specified monitor.
- auto GetMonitor() const -> const Monitor&
- Returns the monitor that hosts the window.
- auto GetCurrentVideoMode(unsigned int monitorIndex) const -> const VideoMode& pure virtual
- Returns the current video mode for the specified monitor.
- auto GetCurrentVideoMode() 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 used in full screen by the monitor that hosts the window.
- auto GetWindowScalingFactor() const -> float
- Returns the scaling factor for the application window.
- auto SupportsAuxiliaryWindows() const -> bool virtual
- Returns
trueif windows besides the main one can be made, see CreateAuxiliaryWindow(). -
auto CreateAuxiliaryWindow(const AuxiliaryWindowDesc& desc) -> std::
unique_ptr<AuxiliaryWindow> virtual - Makes a hidden window besides the main one,
nullptrif it can't be made, see AuxiliaryWindow. - void PresentAuxiliaryWindows()
- Shows the contents of every auxiliary window, called once a frame after it's drawn.
- auto GetGlobalMousePosition(Vector2i& position) const -> bool virtual
- Returns the position of the pointer on the desktop in pixels,
falseif it isn't known. -
auto GetGlobalMouseButtons(std::
uint32_t& buttons) const -> bool virtual - Returns the mouse buttons held now as the system has them,
falseif it isn't known. - auto GetDesktopWorkArea(Vector2i point, Recti& area) const -> bool virtual
- Returns the part of the display at a point of the desktop that windows may take, without the taskbar.
- auto GetWindowContentScale() const -> float virtual
- Returns the scale of the display the main window is on, 1 for 100 %, see AuxiliaryWindow::
GetContentScale().
Protected functions
- void InitDeviceViewport()
- Initializes 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
Private functions
- void SetupDevice() virtual
- Sets up the initial OpenGL state for the scene graph.
- void Update() pure virtual
- Updates the screen by swapping the 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.
void nCine:: IGfxDevice:: SetDrawableSize(int width,
int height) virtual
Sets the pixel size of the drawable (the size the frame is rendered at) without touching the window.
Honoured only by a backend that renders the frame into an intermediate surface of its own and stretches it onto the display at present time (the sceGxm backend on PS Vita, see GxmDevice::ScreenWidth), where the surface is recreated at the new size and the application is notified through OnResizeWindow(). Everywhere else the drawable follows the window and this does nothing. Out-of-range sizes are clamped to what the display can show.
int nCine:: IGfxDevice:: GetDrawableWidth() const
Returns the window width in pixels.
It may differ from width() on HiDPI screens.
int nCine:: IGfxDevice:: GetDrawableHeight() const
Returns the window height in pixels.
It may differ from height() on HiDPI screens.
float nCine:: IGfxDevice:: GetDisplayAspect() const virtual
Returns the aspect ratio the drawable is actually DISPLAYED at.
The same as GetDrawableAspect() wherever a pixel of the drawable is square on the display, which is every desktop and handheld target and most consoles. It is not the same on hardware whose video mode does not have square pixels: the PlayStation 2's 640x448 NTSC field pair (1.43) fills a 4:3 television, so a scene composed for the drawable's own ratio comes out stretched by 7% vertically. Anything that decides how much of the world to show - see Jazz2::
bool nCine:: IGfxDevice:: SetVideoMode(unsigned int modeIndex) virtual
Sets the video mode used in full screen by the monitor that hosts the window.
bool nCine:: IGfxDevice:: SupportsAuxiliaryWindows() const virtual
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.
bool nCine:: IGfxDevice:: GetGlobalMouseButtons(std:: uint32_t& buttons) const virtual
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:: IGfxDevice:: GetDesktopWorkArea(Vector2i point,
Recti& area) const virtual
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.
float nCine:: IGfxDevice:: GetWindowContentScale() const virtual
Returns the scale of the display the main window is on, 1 for 100 %, see AuxiliaryWindow::
By default it's how many pixels the main window has for a unit of the desktop.