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 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
Vector2iobject. - auto screenRect() const -> Rectf
- Returns the window or video mode resolution in screen coordinates as a
Rectfobject. - 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.
- 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 windowPosition() const -> const Vector2i virtual
- Returns the window position as a
Vector2iobject. - 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
Vector2iobject. - auto drawableScreenRect() const -> Rectf
- Returns the window resolution in pixels as a
Rectfobject. - auto drawableAspect() const -> float
- Returns the window drawable resolution aspect ratio.
- auto displayAspect() 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 contextInfo() const -> const ContextInfo&
- Returns the OpenGL context creation attributes.
- auto displayMode() const -> const DisplayMode&
- Returns the 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 used in full screen by the monitor that hosts the window.
- auto windowScalingFactor() const -> float
- Returns the scaling factor for the application window.
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:: drawableWidth() const
Returns the window width in pixels.
It may differ from width() on HiDPI screens.
int nCine:: IGfxDevice:: drawableHeight() const
Returns the window height in pixels.
It may differ from height() on HiDPI screens.
float nCine:: IGfxDevice:: displayAspect() const virtual
Returns the aspect ratio the drawable is actually DISPLAYED at.
The same as drawableAspect() 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.