LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::Display Class Referenceabstract

Display interface to query the attributes of all connected displays/monitors. More...

#include <Display.h>

Inheritance diagram for LLGL::Display:
LLGL::Interface LLGL::NonCopyable

Public Member Functions

virtual bool IsPrimary () const =0
 Returns true if this is the primary display, as configured by the host system.
virtual UTF8String GetDeviceName () const =0
 Returns the device name of this display in UTF-8 encoding. This may also be empty, if the platform does not support display names.
virtual Offset2D GetOffset () const =0
 Returns the 2D offset relative to the primary display.
virtual float GetScale () const =0
 Returns the scale factor for this display.
virtual bool ResetDisplayMode ()=0
 Resets the display mode to its default value depending on the host system configuration.
virtual bool SetDisplayMode (const DisplayMode &displayMode)=0
 Sets the new display mode for this display.
virtual DisplayMode GetDisplayMode () const =0
 Returns the current display mode of this display.
virtual std::vector< DisplayMode > GetSupportedDisplayModes () const =0
 Returns a list of all modes that are supported by this display.
Public Member Functions inherited from LLGL::Interface
virtual bool IsInstanceOf (int id) const
 Returns true if this object is an instance of the specified interface.
Public Member Functions inherited from LLGL::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete
virtual ~NonCopyable ()=default

Static Public Member Functions

static std::size_t Count ()
 Returns the number of available displays.
static Display *const * GetList ()
 Returns a null-terminated array of all displays.
static Display * Get (std::size_t index)
 Returns the specified display or null if the index is out of bounds.
static Display * GetPrimary ()
 Returns the primary display or null if no display can be found.
static bool ShowCursor (bool show)
 Shows or hides the cursor for the running application from all displays.
static bool IsCursorShown ()
 Returns true if the cursor is currently being shown on any display.
static bool SetCursorPosition (const Offset2D &position)
 Sets the cursor to the specified screen coordinate and returns true on success. Otherwise, cursor relocation is not supported.
static Offset2D GetCursorPosition ()
 Returns the screen coordinate of the cursor.

Static Protected Member Functions

static void FinalizeDisplayModes (std::vector< DisplayMode > &displayMode)
 Sorts the specified list of display modes as described in the GetSupportedDisplayModes function, and removes duplicate entries.

Additional Inherited Members

Protected Member Functions inherited from LLGL::NonCopyable
 NonCopyable ()=default

Detailed Description

Display interface to query the attributes of all connected displays/monitors.

Remarks
Here is an example to print the attributes of all displays:
for (Display* const * myDisplayList = LLGL::Display::GetList(); Display* myDisplay = *myDisplayList; ++myDisplayList) {
LLGL::Offset2D myDisplayOffset = myDisplay->GetOffset();
LLGL::DisplayMode myDisplayMode = myDisplay->GetDisplayMode();
printf("Display: \"%s\"\n", myDisplay->GetDeviceName().c_str());
printf("|-Primary = %s\n", myDisplay->IsPrimary() ? "yes" : "no");
printf("|-X = %d\n", myDisplayOffset.x);
printf("|-Y = %d\n", myDisplayOffset.y);
printf("|-Width = %u\n", myDisplayMode.resolution.width);
printf("|-Height = %u\n", myDisplayMode.resolution.height);
printf("`-Hz = %u\n", myDisplayMode.refreshRate);
}
Display interface to query the attributes of all connected displays/monitors.
Definition Display.h:40
virtual Offset2D GetOffset() const =0
Returns the 2D offset relative to the primary display.
virtual UTF8String GetDeviceName() const =0
Returns the device name of this display in UTF-8 encoding. This may also be empty,...
virtual DisplayMode GetDisplayMode() const =0
Returns the current display mode of this display.
static Display *const * GetList()
Returns a null-terminated array of all displays.
virtual bool IsPrimary() const =0
Returns true if this is the primary display, as configured by the host system.
const_pointer c_str() const noexcept
Definition UTF8String.h:109
Display mode structure.
Definition DisplayFlags.h:28
std::uint32_t refreshRate
Display refresh rate (in Hz).
Definition DisplayFlags.h:33
Extent2D resolution
Display resolution (in pixels).
Definition DisplayFlags.h:30
std::uint32_t width
Extent X axis, i.e. width.
Definition Types.h:36
std::uint32_t height
Extent Y axis, i.e. height.
Definition Types.h:37
2-Dimensional offset structure.
Definition Types.h:65
std::int32_t x
Offset X axis.
Definition Types.h:74
std::int32_t y
Offset Y axis.
Definition Types.h:75

Member Function Documentation

◆ Count()

std::size_t LLGL::Display::Count ( )
static

Returns the number of available displays.

Remarks
This function always checks for updates in the display list.
See also
Get

◆ FinalizeDisplayModes()

void LLGL::Display::FinalizeDisplayModes ( std::vector< DisplayMode > & displayMode)
staticprotected

Sorts the specified list of display modes as described in the GetSupportedDisplayModes function, and removes duplicate entries.

See also
GetSupportedDisplayModes

◆ Get()

Display * LLGL::Display::Get ( std::size_t index)
static

Returns the specified display or null if the index is out of bounds.

Parameters
[in]indexSpecifies the zero-based index for the display to be returned. This should be in the half-open range [0, Count) or null will be returned.
Remarks
This function always checks for updates in the display list.
See also
Count
GetPrimary

◆ GetCursorPosition()

Offset2D LLGL::Display::GetCursorPosition ( )
static

Returns the screen coordinate of the cursor.

◆ GetDeviceName()

virtual UTF8String LLGL::Display::GetDeviceName ( ) const
pure virtual

Returns the device name of this display in UTF-8 encoding. This may also be empty, if the platform does not support display names.

◆ GetDisplayMode()

virtual DisplayMode LLGL::Display::GetDisplayMode ( ) const
pure virtual

Returns the current display mode of this display.

See also
SetDisplayMode

◆ GetList()

Display *const * LLGL::Display::GetList ( )
static

Returns a null-terminated array of all displays.

Returns
Pointer to an array of Display pointers with Count()+1 elements and the last element being null.
Remarks
This function always checks for updates in the display list.
See also
Count

◆ GetOffset()

virtual Offset2D LLGL::Display::GetOffset ( ) const
pure virtual

Returns the 2D offset relative to the primary display.

Remarks
This can be used to position your windows accordingly to your displays.
See also
Window::SetPosition

◆ GetPrimary()

Display * LLGL::Display::GetPrimary ( )
static

Returns the primary display or null if no display can be found.

See also
Get

◆ GetScale()

virtual float LLGL::Display::GetScale ( ) const
pure virtual

Returns the scale factor for this display.

Remarks
This value is used to convert between screen resolution coordinates (see SwapChainDescriptor::resolution) and window coordinates (see WindowDescriptor::size).
For high resolution displays, this may have a value of 3 or 2. Otherwise, 1 is the most common value if no extra scaling is necessary.
See also
SwapChainDescriptor::resolution
WindowDescriptor::size

◆ GetSupportedDisplayModes()

virtual std::vector< DisplayMode > LLGL::Display::GetSupportedDisplayModes ( ) const
pure virtual

Returns a list of all modes that are supported by this display.

Remarks
This list is always sorted in the following manner: The first sorting criterion is the number of pixels (resolution width times resolution height) in ascending order, and the second sorting criterion is the refresh rate in ascending order. To get only the currently active display mode, use GetDisplayMode.
See also
GetDisplayMode

◆ IsCursorShown()

bool LLGL::Display::IsCursorShown ( )
static

Returns true if the cursor is currently being shown on any display.

See also
ShowCursor

◆ IsPrimary()

virtual bool LLGL::Display::IsPrimary ( ) const
pure virtual

Returns true if this is the primary display, as configured by the host system.

◆ ResetDisplayMode()

virtual bool LLGL::Display::ResetDisplayMode ( )
pure virtual

Resets the display mode to its default value depending on the host system configuration.

See also
SetDisplayMode

◆ SetCursorPosition()

bool LLGL::Display::SetCursorPosition ( const Offset2D & position)
static

Sets the cursor to the specified screen coordinate and returns true on success. Otherwise, cursor relocation is not supported.

◆ SetDisplayMode()

virtual bool LLGL::Display::SetDisplayMode ( const DisplayMode & displayMode)
pure virtual

Sets the new display mode for this display.

Parameters
[in]displayModeSpecifies the new display mode.
Returns
True on success, otherwise the specified display mode is not supported by this display and the function has no effect.
See also
GetDisplayMode

◆ ShowCursor()

bool LLGL::Display::ShowCursor ( bool show)
static

Shows or hides the cursor for the running application from all displays.

Parameters
[in]showSpecifies whether to show or hide the cursor.
Remarks
In contrast to the Win32 API, this function only shows or hides the cursor, while the Win32 API function with the same name either increments or decrements an internal visibility counter for the cursor.
Returns
True on success, otherwise cursor visibility changes are not supported.
See also
IsCursorShown

The documentation for this class was generated from the following file: