CUGL 4.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
cugl::Display Class Reference

#include <CUDisplay.h>

Public Types

enum class  Orientation : unsigned int {
  UNKNOWN = 0 , LANDSCAPE = 1 , PORTRAIT = 2 , LANDSCAPE_REVERSED = 3 ,
  UPSIDE_DOWN = 4
}
 
typedef std::function< void(Orientation previous, Orientation current)> Listener
 

Public Member Functions

std::string getTitle () const
 
void setTitle (const std::string title)
 
void show ()
 
void hide ()
 
Vec2 getMouseWindowPosition (float x, float y)
 
Vec2 getMouseScreenPosition (float x, float y)
 
Vec2 getTouchWindowPosition (float x, float y)
 
Vec2 getTouchScreenPosition (float x, float y)
 
Vec2 getTouchWindowValue (float x, float y)
 
Vec2 getTouchScreenValue (float x, float y)
 
const std::string getGraphicsDescription () const
 
GraphicsContext * getGraphicsContext () const
 
float getRefreshRate () const
 
const RectgetFrameBounds () const
 
bool setFrameBounds (const Rect &bounds)
 
bool setFrameSize (Uint32 width, Uint32 height)
 
bool setFrameSize (const Size &size)
 
bool setFrameOrigin (Uint32 x, Uint32 y)
 
bool setFrameOrigin (const Vec2 &origin)
 
const RectgetViewBounds () const
 
const RectgetSafeBounds () const
 
float getPixelDensity () const
 
const Mat4getTransform () const
 
bool hasNotch () const
 
Orientation getConfiguredOrientation () const
 
Orientation getInitialOrientation () const
 
Orientation getDisplayOrientation () const
 
Orientation getDeviceOrientation () const
 
Orientation getNaturalOrientation () const
 
bool hasSwappedAxes () const
 
bool isLandscape () const
 
bool isPortrait () const
 
bool hasOrientationListener () const
 
const Listener getOrientationListener () const
 
void setOrientationListener (Listener listener)
 
bool removeOrientationListener ()
 
bool startTextEvents ()
 
bool stopTextEvents ()
 
void lock ()
 
void unlock ()
 
void clear (Color4f color)
 
void config ()
 
void resync ()
 
void refresh ()
 

Static Public Member Functions

static bool start (std::string title, Rect bounds, Uint32 flags)
 
static void stop ()
 
static Displayget ()
 

Static Public Attributes

static Uint32 INIT_FULLSCREEN
 
static Uint32 INIT_CENTERED
 
static Uint32 INIT_RESIZABLE
 
static Uint32 INIT_HIGH_DPI
 
static Uint32 INIT_CAMERA
 
static Uint32 INIT_VSYNC
 
static Uint32 INIT_MULTISAMPLED
 
static Uint32 INIT_LARGE_POINTS
 
static Uint32 INIT_WIDE_LINES
 

Protected Member Functions

 Display ()
 
bool init (std::string title, Rect bounds, Uint32 flags)
 
void dispose ()
 
 ~Display ()
 

Protected Attributes

std::string _title
 
SDL_Window * _window
 
SDL_DisplayID _display
 
GraphicsContext * _context
 
bool _fullscreen
 
Rect _frame
 
Rect _drawable
 
Rect _usable
 
float _scale
 
Mat4 _transform
 
bool _notched
 
Listener _orientationListener
 
Orientation _initialOrientation
 
Orientation _configOrientation
 
Orientation _windowOrientation
 
Orientation _deviceOrientation
 

Static Protected Attributes

static Display_thedisplay
 

Friends

class Application
 

Detailed Description

This class is a singleton representing the native display.

The static methods of this class start() and stop() the SDL video system. Without it, you cannot draw anything. This should be the first and last methods called in any application. The Application class does this for you automatically.

The primary purpose of the display object is to initialize (and dispose) the graphics context. Any start-up features for your graphics system (e.g. OpenGL or Vulkan) should go in this class. They are set via the flags sent to the method start().

The singleton display object also has several methods to get the (current) screen resolution and aspect ratio. The most important of these two is the the aspect ratio. Aspect ratio is one of the most unportable parts of cross-platform development. Everything else can be scaled to the screen, but the aspect ratio is fixed from the very beginning. With that said, applications on desktop platforms may support window resizing.

The singleton display also has information about the display and device orientation for mobile devices. In fact, is is possible to assign a listener to the object to respond to changes in device orientation.

If the device has multiple displays, this singleton will only refer to the main display.

Member Typedef Documentation

◆ Listener

This type represents a listener for an orientation change.

In CUGL, listeners are implemented as a set of callback functions, not as objects. For simplicity, Displays only have a single listener that handles both display and device changes (see getDisplayOrientation() and getDeviceOrientation().) If you wish for more than one listener, then your listener should handle its own dispatch.

Unlike other events, this callback will be invoked at the end of an animation frame, after the screen has been drawn. So it will be processed before any input events waiting for the next frame. If you wish for more than one listener, then your listener should handle its own dispatch.

The function type is equivalent to

 std::function<void(Orientation previous, Orientation current)>
Parameters
previousThe previous device orientation (before the change)
currentThe current device orientation (after the change)

Member Enumeration Documentation

◆ Orientation

enum class cugl::Display::Orientation : unsigned int
strong

The possible device/display orientations.

We use the same orientations for device and display even though these may not always agree (such as when the user has locked the display)

Enumerator
UNKNOWN 

The orientation is unknown.

This is rarely ever reported, and may mean an issue with the accelerometer in the case of a mobile device.

LANDSCAPE 

Landscape orientation with the right side up.

One notched devices, this will put the notch to the left. On devices with a home button, the button will be to the right.

PORTRAIT 

Standard portrait orientation

One notched devices, this will put the notch to the top. On devices with a home button, the button will be to the bottom.

LANDSCAPE_REVERSED 

Landscape orientation with the left side up.

One notched devices, this will put the notch to the right. On devices with a home button, the button will be to the left.

UPSIDE_DOWN 

Reversed portrait orientation

One notched devices, this will put the notch to the bottom. On devices with a home button, the button will be to the top.

Many devices (e.g. iPhones) do not allow this mode as it interferes with the camera and incoming calls.

Constructor & Destructor Documentation

◆ Display()

cugl::Display::Display ( )
protected

Creates a new, unitialized Display.

All of the values are set to 0 or UNKNOWN, depending on their type. You must initialize the Display to access its values.

WARNING: This class is a singleton. You should never access this constructor directly. Use the start() method instead.

◆ ~Display()

cugl::Display::~Display ( )
inlineprotected

Deletes this object, releasing all resources.

This method quits the SDL video system and disposes the graphics context, effectively exitting and shutting down the entire program.

WARNING: This class is a singleton. You should never access this destructor directly. Use the stop() method instead.

Member Function Documentation

◆ clear()

void cugl::Display::clear ( Color4f  color)

Clears the screen to the given clear color.

This method should be called before any user drawing happens.

Parameters
colorThe clear color

◆ config()

void cugl::Display::config ( )

Sets up the initial transform.

This helper is called by init to determine the transform.

◆ dispose()

void cugl::Display::dispose ( )
protected

Uninitializes this object, releasing all resources.

This method quits the SDL video system and disposes the graphics context, effectively exitting and shutting down the entire program.

WARNING: This class is a singleton. You should never access this method directly. Use the stop() method instead.

◆ get()

static Display * cugl::Display::get ( )
inlinestatic

Returns the singleton instance for the display

You must call this static method first to get information about your specific display. This method will return nullptr until start() is called first.

Returns
the singleton instance for the display

◆ getConfiguredOrientation()

Orientation cugl::Display::getConfiguredOrientation ( ) const
inline

Returns the display configuration orientation.

Typically, this value is the display orientation at startup. The display orientation is the orientation of the coordinate space for drawing on a mobile device. In other words, the origin is at the bottom left of the screen in this device orientation.

In some rare cases this value can change. In particular, it can change on Android devices using large screen behavior in Android 15+. Those devices cannot lock orientation, and autorotation may cause the configuration (and window size!) to change.

The display orientation may or may not agree with the device orientation.
In particular, it will not agree if the display orientation is locked (to say portrait or landscape only). However, this is the orientation that is important for drawing to the screen. To get the device orientation, call getDeviceOrientation().

Returns
the initial display orientation.

◆ getDeviceOrientation()

Orientation cugl::Display::getDeviceOrientation ( ) const
inline

Returns the current device orientation.

The device orientation is the orientation of a mobile device, as held by the user. It may or may not agree with the display orientation, which is how the screen is drawn. For example, if the screen is locked to landscape orientation, it is still possible for the device to have portrait orientation when it is held on its side.

This method is useful when you want to switch game modes for a different orientation (e.g. Powerpuff Girls Flipped Out).

Returns
the current device orientation.

◆ getDisplayOrientation()

Orientation cugl::Display::getDisplayOrientation ( ) const
inline

Returns the current display orientation.

This value is the current display orientation. The display orientation is the orientation of the coordinate space for drawing on a mobile device. In other words, the origin is at the bottom left of the screen in this device orientation.

The display orientation may or may not agree with the device orientation.
In particular, it will not agree if the display orientation is locked (to say portrait or landscape only). However, this is the orientation that is important for drawing to the screen. To get the device orientation, call getDeviceOrientation().

Returns
the current display orientation.

◆ getFrameBounds()

const Rect & cugl::Display::getFrameBounds ( ) const
inline

Returns the bounds of the external frame for this display.

If the display is windowed (as opposed to fullscreen), this method will return the bounds of that window on the screen itself. For fullscreen Display objects, this will return the dimensions of the screen.

Note that the units reported by this method are often in points, not pixels. So on Retina display Apple devices, the dimensions of this frame could be half, or even a third, of the getViewBounds.

In addition, this value is reported using the screen coordinate system. In this coordinate system, the origin is often the top-right.

Returns
the bounds of the external frame for this display.

◆ getGraphicsContext()

GraphicsContext * cugl::Display::getGraphicsContext ( ) const
inline

Returns the graphics context for this display.

The graphics context is an opaque type storing the information that is needed for the active graphics API (e.g. OpenGL, Vulkan, or Headless) This is only exposed for internal debugging purposes.

Returns
athe graphics context for this display.

◆ getGraphicsDescription()

const std::string cugl::Display::getGraphicsDescription ( ) const

Returns a description of the graphics API for this display.

For example, if this application is backed by OpenGL, this method returns the OpenGL version. For Vulkan, it returns the Vulkan version. If it is a headless client, it returns "Headless".

Returns
a description of the graphics API for this display.

◆ getInitialOrientation()

Orientation cugl::Display::getInitialOrientation ( ) const
inline

Returns the initial display orientation.

This value is the display orientation at startup. The display orientation is the orientation of the coordinate space for drawing on a mobile device. In other words, the origin is at the bottom left of the screen in this device orientation.

The display orientation may or may not agree with the device orientation.
In particular, it will not agree if the display orientation is locked (to say portrait or landscape only). However, this is the orientation that is important for drawing to the screen. To get the device orientation, call getDeviceOrientation().

Returns
the initial display orientation.

◆ getMouseScreenPosition()

Vec2 cugl::Display::getMouseScreenPosition ( float  x,
float  y 
)

Returns the screen position for the given mouse location.

This method transforms (x,y) via getTransform. A screen position is always with respect to an origin in the top-left corner.

Parameters
xThe mouse x-coordinate
yThe mouse y-coordinate
Returns
the screen position for the given mouse location.

◆ getMouseWindowPosition()

Vec2 cugl::Display::getMouseWindowPosition ( float  x,
float  y 
)

Returns the window position for the given mouse location.

This method transforms (x,y) via getTransform. A window position is always with respect to an origin in the bottom-left corner.

Parameters
xThe mouse x-coordinate
yThe mouse y-coordinate
Returns
the window position for the given mouse location.

◆ getNaturalOrientation()

Orientation cugl::Display::getNaturalOrientation ( ) const

Returns the natural orientation of this device.

The natural orientation corresponds to the intended orientiation that this mobile device should be held. For devices with home buttons, this home button is always expected at the bottom. For the vast majority of devices, this means the intended orientation is Portrait. However, some Samsung tablets have the home button oriented for Landscape.

This is important because the accelerometer axis is oriented relative to the natural orientation. So a natural landscape device will have a different accelerometer orientation than a portrait device. Unfortunately, this method can have unexpected results on Android 15+ devices with large-screen behavior. If you wish to actually determine if the accelerometer axes are swapped, use hasSwappedAxes

Returns
the natural orientation of this device.

◆ getOrientationListener()

const Listener cugl::Display::getOrientationListener ( ) const
inline

Returns the listener for the display orientation.

This listener handles changes in either the device orientation (see getDeviceOrientation() or the display orientation (see getDeviceOrientation(). Since the device orientation will always change when the display orientation does, this callback can easily safely handle both. The boolean parameter in the callback indicates whether or not a display orientation change has happened as well.

Unlike other events, this listener will be invoked at the end of an animation frame, after the screen has been drawn. So it will be processed before any input events waiting for the next frame.

The display may only have one orientation listener at a time. If there is no listener, this method returns nullptr.

Returns
the orientation listener (if any) for this display

◆ getPixelDensity()

float cugl::Display::getPixelDensity ( ) const
inline

Returns the number of pixels for each point.

A point is a logical screen pixel. If you are using a traditional display, points and pixels are the same. However, on Retina displays and other high dpi monitors, they may be different. In particular, the number of pixels per point is a scaling factor times the point.

This value is defined as the ratio of getViewBounds to getFrameBounds. In practice, you should not need to use this scaling factor for anything other than determining if the high dpi setting is in use.

Returns
the number of pixels for each point.

◆ getRefreshRate()

float cugl::Display::getRefreshRate ( ) const

Returns the refresh rate of the display.

If the rate is unspecified, this will return 0.

Returns
the refresh rate of the display.

◆ getSafeBounds()

const Rect & cugl::Display::getSafeBounds ( ) const
inline

Returns the usable bounds of this display in pixels.

Usable is a subjective term defined by the operating system. In general, it means the full screen minus any space used by important user interface elements, like a status bar (iPhone), menu bar (macOS), or task bar (Windows), or a notch (modern phones).

The value returned will always be a (potentially unproper) subrectangle of getViewBounds.

Returns
the usable bounds of this display in pixels.

◆ getTitle()

std::string cugl::Display::getTitle ( ) const
inline

Returns the title of this display

On a desktop, this title will be displayed at the top of the window.

Returns
the title of this display

◆ getTouchScreenPosition()

Vec2 cugl::Display::getTouchScreenPosition ( float  x,
float  y 
)

Returns the screen position for the given touch location.

This method converts (x,y) from normalized coordinates to pixel coordinates and then transforms the result via getTransform. A screen position is always with respect to an origin in the top-left corner.

Parameters
xThe touch x-coordinate
yThe touch y-coordinate
Returns
the screen position for the given touch location.

◆ getTouchScreenValue()

Vec2 cugl::Display::getTouchScreenValue ( float  x,
float  y 
)

Returns the normalized window position for the given touch location.

This method keeps (x,y) in normalized coordinate and transforms the result via getTransform. A screen position is always with respect to an origin in the top-left corner.

Parameters
xThe touch x-coordinate
yThe touch y-coordinate
Returns
the window position for the given touch location.

◆ getTouchWindowPosition()

Vec2 cugl::Display::getTouchWindowPosition ( float  x,
float  y 
)

Returns the window position for the given touch location.

This method converts (x,y) from normalized coordinates to pixel coordinates and then transforms the result via getTransform. A window position is always with respect to an origin in the bottom-left corner.

Parameters
xThe touch x-coordinate
yThe touch y-coordinate
Returns
the window position for the given touch location.

◆ getTouchWindowValue()

Vec2 cugl::Display::getTouchWindowValue ( float  x,
float  y 
)

Returns the normalized window position for the given touch location.

This method keeps (x,y) in normalized coordinate and transforms the result via getTransform. A window position is always with respect to an origin in the bottom-left corner.

Parameters
xThe touch x-coordinate
yThe touch y-coordinate
Returns
the window position for the given touch location.

◆ getTransform()

const Mat4 & cugl::Display::getTransform ( ) const
inline

Returns the transform for this display.

Some graphics APIs use an internal coordinate system that is rotated according to the coordinate system that we want. The returned transform should be applied AFTER apply any camera transforms to a scene before executing any drawing commands.

Returns
the transform for this display.

◆ getViewBounds()

const Rect & cugl::Display::getViewBounds ( ) const
inline

Returns the drawable bounds of this display in pixels.

This method returns the internal pixel bounds of the Display window. The origin of this rectangle will always be at (0,0), indicating the bottom left corner of the window. Note the getPixelDensity is the ratio of this size relative to the size of getFrameBounds.

Returns
the drawable bounds of this display in pixels.

◆ hasNotch()

bool cugl::Display::hasNotch ( ) const
inline

Returns true if this device has a notch.

Notched devices are edgeless smartphones or tablets that include at dedicated area in the screen for a camera. Examples include the iPhone X.

If a device is notched you should call getSafeBounds() before laying out UI elements. It is acceptable to animate and draw backgrounds behind the notch, but it is not acceptable to place UI elements outside of these bounds.

Returns
true if this device has a notch.

◆ hasOrientationListener()

bool cugl::Display::hasOrientationListener ( ) const
inline

Returns true if this display has an orientation listener

This listener handles changes in either the device orientation (see getDeviceOrientation() or the display orientation (see getDeviceOrientation(). Since the device orientation will always change when the display orientation does, this callback can easily safely handle both. The boolean parameter in the callback indicates whether or not a display orientation change has happened as well.

Unlike other events, this listener will be invoked at the end of an animation frame, after the screen has been drawn. So it will be processed before any input events waiting for the next frame.

The display may only have one orientation listener at a time.

Returns
true if this display has an orientation listener

◆ hasSwappedAxes()

bool cugl::Display::hasSwappedAxes ( ) const

Returns true if the accelerometer axes as swapped.

By default, accelerometer axes assume that the user is holding the device in portrait mode. So the x-axis is the short edge, while the y-axis is the long edge. If this function returns true, these axes are swapped so that the x-axis is the long edge, while the y-axis is the short edge.

Returns
true if the accelerometer axes as swapped.

◆ hide()

void cugl::Display::hide ( )

Hides the window for this display (assuming it was visible).

This method does nothing if the window was not visible.

◆ init()

bool cugl::Display::init ( std::string  title,
Rect  bounds,
Uint32  flags 
)
protected

Initializes the display with the current screen information.

This method creates a display with the given title and bounds. As part of this initialization, it will create the graphics context, using the flags provided. The bounds are ignored if the display is fullscreen. In that case, it will use the bounds of the display.

This method gathers the native resolution bounds, pixel density, and orientation using platform-specific tools.

WARNING: This class is a singleton. You should never access this initializer directly. Use the start() method instead.

Parameters
titleThe window/display title
boundsThe window/display bounds
flagsThe initialization flags
Returns
true if initialization was successful.

◆ isLandscape()

bool cugl::Display::isLandscape ( ) const

Returns true if this display (not device) has a landscape orientation

Returns
true if this display (not device) has a landscape orientation

◆ isPortrait()

bool cugl::Display::isPortrait ( ) const

Returns true if this display (not device) has a portrait orientation

Returns
true if this display (not device) has a portrait orientation

◆ lock()

void cugl::Display::lock ( )

Locks the display, preventing any drawing commands.

This method provides some safety with regard to shader usage.

◆ refresh()

void cugl::Display::refresh ( )

Refreshes the display.

This method will swap the framebuffers, drawing the screen. This method should be called after any user drawing happens.

It will also reassess the orientation state and call the listener as necessary

◆ removeOrientationListener()

bool cugl::Display::removeOrientationListener ( )

Removes the display orientation listener for this display.

This listener handles changes in either the device orientation (see getDeviceOrientation() or the display orientation (see getDeviceOrientation(). Since the device orientation will always change when the display orientation does, this callback can easily safely handle both. The boolean parameter in the callback indicates whether or not a display orientation change has happened as well.

Unlike other events, this listener will be invoked at the end of an animation frame, after the screen has been drawn. So it will be processed before any input events waiting for the next frame.

A display may only have one orientation listener at a time. If this display does not have an orientation listener, this method will fail.

Returns
true if the listener was succesfully removed

◆ resync()

void cugl::Display::resync ( )

Resynchronizes this object with the physical display.

This method is called in response to a resizing event for windows that can be resized. This may also adjust the configuration orientation.

◆ setFrameBounds()

bool cugl::Display::setFrameBounds ( const Rect bounds)

Resets the the bounds of the external frame of this display.

This method will do nothing if the display is fullscreen. Otherwise, it will attempt to resize the window to the given dimensions. Not that the units used by this method are often in points, not pixels. So on Retina display Apple devices, the dimensions of this frame could be half, or even a third, of the getViewBounds.

In addition, the bounds are specified using the screen coordinate system. In this coordinate system, the origin is often the top-right.

Parameters
boundsThe new frame bounds
Returns
true if the bound were successfully updated.

◆ setFrameOrigin() [1/2]

bool cugl::Display::setFrameOrigin ( const Vec2 origin)
inline

Repositions the external frame of this display

This method will do nothing if the display is fullscreen. Otherwise, it will attempt to reposition the window to the given coordinates. Note that the units used by this method are often in points, not pixels. So on Retina display Apple devices, the dimensions of this frame could be half, or even a third, of the getViewBounds. In addition, in the screen coordinate system, the origin is often the top-right.

Parameters
originThe frame origin
Returns
true if the window was successfully repositioned

◆ setFrameOrigin() [2/2]

bool cugl::Display::setFrameOrigin ( Uint32  x,
Uint32  y 
)

Repositions the external frame of this display

This method will do nothing if the display is fullscreen. Otherwise, it will attempt to reposition the window to the given coordinates. Note that the units used by this method are often in points, not pixels. So on Retina display Apple devices, the dimensions of this frame could be half, or even a third, of the getViewBounds. In addition, in the screen coordinate system, the origin is often the top-right.

Parameters
xThe x-coordinate of the frame
yThe x-coordinate of the frame
Returns
true if the window was successfully repositioned

◆ setFrameSize() [1/2]

bool cugl::Display::setFrameSize ( const Size size)
inline

Resizes the external frame of this display.

This method will do nothing if the display is fullscreen. Otherwise, it will attempt to resize the window to the given dimensions. Not that the units used by this method are often in points, not pixels. So on Retina display Apple devices, the dimensions of this frame could be half, or even a third, of the getViewBounds.

Parameters
sizeThe new frame size
Returns
true if the window was successfully resized

◆ setFrameSize() [2/2]

bool cugl::Display::setFrameSize ( Uint32  width,
Uint32  height 
)

Resizes the external frame of this display.

This method will do nothing if the display is fullscreen. Otherwise, it will attempt to resize the window to the given dimensions. Not that the units used by this method are often in points, not pixels. So on Retina display Apple devices, the dimensions of this frame could be half, or even a third, of the getViewBounds.

Parameters
widthThe new frame width
heightThe new frame height
Returns
true if the window was successfully resized

◆ setOrientationListener()

void cugl::Display::setOrientationListener ( Listener  listener)
inline

Sets the orientation listener for this display.

This listener handles changes in either the device orientation (see getDeviceOrientation() or the display orientation (see getDeviceOrientation(). Since the device orientation will always change when the display orientation does, this callback can easily safely handle both. The boolean parameter in the callback indicates whether or not a display orientation change has happened as well.

A display may only have one orientation listener at a time. If this display already has an orientation listener, this method will replace it for the once specified.

Unlike other events, this listener will be invoked at the end of an animation frame, after the screen has been drawn. So it will be processed before any input events waiting for the next frame.

Parameters
listenerThe listener to use

◆ setTitle()

void cugl::Display::setTitle ( const std::string  title)

Sets the title of this display

On a desktop, the title will be displayed at the top of the window.

Parameters
titleThe title of this display

◆ show()

void cugl::Display::show ( )

Shows the window for this display (assuming it was hidden).

This method does nothing if the window was not hidden.

◆ start()

static bool cugl::Display::start ( std::string  title,
Rect  bounds,
Uint32  flags 
)
static

Starts up the SDL display and video system.

This static method needs to be the first line of any application, though it is handled automatically in the Application class.

This method creates the display with the given title and bounds. As part of this initialization, it will create the graphics context, using the flags provided. The bounds are ignored if the display is fullscreen. In that case, it will use the bounds of the display.

Once this method is called, the get() method will no longer return a null value.

Parameters
titleThe window/display title
boundsThe window/display bounds
flagsThe initialization flags
Returns
true if the display was successfully initialized

◆ startTextEvents()

bool cugl::Display::startTextEvents ( )

Enable text events on the given display.

The method is used by TextInput to activate text input events. On devices without keyboards, calling this method will typically create a virtual keyboard on the display. You can dismiss it by calling stopTextEvents

Returns
true if events were successfully enabled

◆ stop()

static void cugl::Display::stop ( )
static

Shuts down the SDL display and video system.

This static method needs to be the last line of any application, though it is handled automatically in the Application class. It will dipose of the display and the graphics context.

Once this method is called, the get() method will return nullptr. More importantly, no SDL function calls will work anymore.

◆ stopTextEvents()

bool cugl::Display::stopTextEvents ( )

Disables text events on the given display.

The method is used by TextInput to deactivate text input events. If startTextEvents created a virtual keyboard, this method will dismiss it.

Returns
true if events were successfully disabled

◆ unlock()

void cugl::Display::unlock ( )

Unlocks the display, allowing drawing commands to proceed

This method provides some safety with regard to shader usage.

Friends And Related Symbol Documentation

◆ Application

friend class Application
friend

This is called by the application loop

Member Data Documentation

◆ _configOrientation

Orientation cugl::Display::_configOrientation
protected

The value of the configuration orientation

◆ _context

GraphicsContext* cugl::Display::_context
protected

The associated graphics context

◆ _deviceOrientation

Orientation cugl::Display::_deviceOrientation
protected

The value of the device orientation

◆ _display

SDL_DisplayID cugl::Display::_display
protected

The display index (for multiscreen displays)

◆ _drawable

Rect cugl::Display::_drawable
protected

The drawable bounds in pixels

◆ _frame

Rect cugl::Display::_frame
protected

The bounds for this display with respect to the device

◆ _fullscreen

bool cugl::Display::_fullscreen
protected

Whether we are using full screen

◆ _initialOrientation

Orientation cugl::Display::_initialOrientation
protected

The value of the initial orientation

◆ _notched

bool cugl::Display::_notched
protected

Whether this device has a notch in it

◆ _orientationListener

Listener cugl::Display::_orientationListener
protected

A listener for the orientation

◆ _scale

float cugl::Display::_scale
protected

The pixel density of the device

This value is the ratio of the display size to the drawable size.

◆ _thedisplay

Display* cugl::Display::_thedisplay
staticprotected

The display singleton

◆ _title

std::string cugl::Display::_title
protected

The title (Window name) of the display

◆ _transform

Mat4 cugl::Display::_transform
protected

A pre-transform to fix orientation issues on Android

◆ _usable

Rect cugl::Display::_usable
protected

The safe area bounds in pixels

The safe area consist of the drawing area minus regions that should not be drawn over, like notches, menu bars, and home regions.

◆ _window

SDL_Window* cugl::Display::_window
protected

The SDL window, which provides the OpenGL drawing context

◆ _windowOrientation

Orientation cugl::Display::_windowOrientation
protected

The value of the display orientation

◆ INIT_CAMERA

Uint32 cugl::Display::INIT_CAMERA
static

Whether this display should support the camera (EXPERIMENTAL)

◆ INIT_CENTERED

Uint32 cugl::Display::INIT_CENTERED
static

Whether this display should be centered (on windowed screens)

◆ INIT_FULLSCREEN

Uint32 cugl::Display::INIT_FULLSCREEN
static

Whether this display should use the fullscreen

◆ INIT_HIGH_DPI

Uint32 cugl::Display::INIT_HIGH_DPI
static

Whether this display should support a High DPI screen

◆ INIT_LARGE_POINTS

Uint32 cugl::Display::INIT_LARGE_POINTS
static

Whether to support points larger than one pixel (Vulkan only)

◆ INIT_MULTISAMPLED

Uint32 cugl::Display::INIT_MULTISAMPLED
static

Whether this display should be multisampled

◆ INIT_RESIZABLE

Uint32 cugl::Display::INIT_RESIZABLE
static

Whether this display resizable (incompatible with full screen)

◆ INIT_VSYNC

Uint32 cugl::Display::INIT_VSYNC
static

Whether this display should have VSync enabled

◆ INIT_WIDE_LINES

Uint32 cugl::Display::INIT_WIDE_LINES
static

Whether to support points lines wider than one pixel (Vulkan only)


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