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

The Surface interface is the base interface for Window (on Desktop platforms) and Canvas (on mobile platforms). More...

#include <Surface.h>

Inheritance diagram for LLGL::Surface:
LLGL::Interface LLGL::NonCopyable LLGL::Canvas LLGL::Window

Public Member Functions

virtual bool GetNativeHandle (void *nativeHandle, std::size_t nativeHandleSize)=0
 Returns the native surface handle.
virtual Extent2D GetContentSize () const =0
 Returns the size (in pixels) of the surface content, i.e. the drawable area.
virtual bool AdaptForVideoMode (Extent2D *resolution, bool *fullscreen)=0
 Adapts the surface to satisfy the needs for the specified video mode.
virtual Display * FindResidentDisplay () const =0
 Returns the Display interface in which this surface is resident.
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 bool ProcessEvents ()
 Processes all windowing system events, i.e. input-, movement-, resize-, and other events for all surfaces associated with the host process.

Additional Inherited Members

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

Detailed Description

The Surface interface is the base interface for Window (on Desktop platforms) and Canvas (on mobile platforms).

Remarks
Surface provides the minimal required interface for a graphics rendering context, such as the access to the native handle, information about the content size (i.e. the size of the drawable area), and the ability to adapt for a new video mode.
This is the class custom windowing systems must inherit from either directly or indirectly through the Window or Canvas interface.
See also
Window
Canvas

Member Function Documentation

◆ AdaptForVideoMode()

virtual bool LLGL::Surface::AdaptForVideoMode ( Extent2D * resolution,
bool * fullscreen )
pure virtual

Adapts the surface to satisfy the needs for the specified video mode.

Parameters
[in,out]resolutionOptional pointer to the input and output resolution.
[in,out]fullscreenOptional pointer to the fullscreen bit.
Returns
If the video mode has been accepted with no modifications and this surface has been updated then the return value is true. Otherwise, resolution and/or fullscreen arguments have been modified to the value this surface supports and the return value is false.

Implemented in LLGL::Canvas, and LLGL::Window.

◆ FindResidentDisplay()

virtual Display * LLGL::Surface::FindResidentDisplay ( ) const
pure virtual

Returns the Display interface in which this surface is resident.

Remarks
A surface is considered resident in a display if more than the half of its client area is visible in that display.
Returns
Pointer to the Display in which this surface is resident or null if this surface is not resident in any display.

Implemented in LLGL::Canvas, and LLGL::Window.

◆ GetContentSize()

virtual Extent2D LLGL::Surface::GetContentSize ( ) const
pure virtual

Returns the size (in pixels) of the surface content, i.e. the drawable area.

Remarks
On platforms with high-resolution displays, this can be twice or even three times the size of the surface's frame, since the frame's size is given in window coordinates whereas this function provides pixel resolutions.
See also
Window::GetSize

◆ GetNativeHandle()

virtual bool LLGL::Surface::GetNativeHandle ( void * nativeHandle,
std::size_t nativeHandleSize )
pure virtual

Returns the native surface handle.

Parameters
[out]nativeHandleRaw pointer to the platform specific structure to store the native handle. This must be of type LLGL::NativeHandle.
[in]nativeHandleSizeSpecifies the size (in bytes) of the native handle structure for robustness. This must be sizeof(LLGL::NativeHandle).
Returns
True if the native handle was successfully retrieved. Otherwise, nativeHandleSize specifies an incompatible structure size.
Remarks
This must be casted to a platform specific structure:
// Example for a custom Win32 window class
//...
bool MyWindowClass::GetNativeHandle(void* nativeHandle, std::size_t nativeHandleSize) {
if (nativeHandle != nullptr && nativeHandleSize == sizeof(LLGL::NativeHandle)) {
auto handle = reinterpret_cast<LLGL::NativeHandle*>(nativeHandle);
//handle->window = 'some HWND window handle';
return true;
}
return false;
}
Android native handle structure.
Definition Platform/Android/AndroidNativeHandle.h:21
This is not a constant member function because it might modify internal reference counters. LLGL also has to assume that the returning handle will be used to modify the surface.

◆ ProcessEvents()

bool LLGL::Surface::ProcessEvents ( )
static

Processes all windowing system events, i.e. input-, movement-, resize-, and other events for all surfaces associated with the host process.

Remarks
This should be called once every frame to update all surfaces and their inputs.
Returns
True as long as events can be received. Otherwise, the connection to the window server might have been closed or an error occurred. The return value is mostly used to allow having this function inside a conditional expression to be called before any other event based conditions are invoked, like in the following example:
while (LLGL::Surface::ProcessEvent() && !myWindow->HasQuit()) {
...
}

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