raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
raylib::Window Class Reference

Window and Graphics Device Functions. More...

#include <Window.hpp>

Public Member Functions

 Window ()
 Build a Window object, but defer the initialization. More...
 
 Window (int width, int height, const std::string_view title="raylib", unsigned int flags=0)
 Initialize window and OpenGL context. More...
 
 ~Window ()
 Close window and unload OpenGL context. More...
 
WindowBeginDrawing ()
 Setup canvas (framebuffer) to start drawing. More...
 
WindowClearBackground (const ::Color &color=BLACK)
 Clear window with given color. More...
 
WindowClearState (unsigned int flag)
 Clear window configuration state flags. More...
 
void Close ()
 Close window and unload OpenGL context. More...
 
void DrawFPS (int posX=10, int posY=10) const
 Draw current FPS. More...
 
WindowEndDrawing ()
 End canvas drawing and swap buffers (double buffering) More...
 
const std::string GetClipboardText ()
 Get clipboard text content. More...
 
int GetFPS () const
 Returns current FPS. More...
 
float GetFrameTime () const
 Returns time in seconds for last frame drawn. More...
 
void * GetHandle () const
 Get native window handle. More...
 
int GetHeight () const
 Get current screen height. More...
 
Vector2 GetPosition () const
 Get window position XY on monitor. More...
 
int GetRenderHeight () const
 Get current render height (it considers HiDPI) More...
 
int GetRenderWidth () const
 Get current render width (it considers HiDPI) More...
 
Vector2 GetScaleDPI () const
 Get window scale DPI factor. More...
 
Vector2 GetSize () const
 Get the screen's width and height. More...
 
double GetTime () const
 Returns elapsed time in seconds since InitWindow() More...
 
int GetWidth () const
 Get current screen width. More...
 
void Init (int width=800, int height=450, const std::string_view title="raylib", unsigned int flags=0)
 Initializes the window. More...
 
bool IsCursorOnScreen () const
 Check if cursor is on the current screen. More...
 
bool IsFocused () const
 Check if window is currently focused. More...
 
bool IsFullscreen () const
 Check if window is currently fullscreen. More...
 
bool IsHidden () const
 Check if window is currently hidden. More...
 
bool IsMaximized () const
 Check if window is currently minimized. More...
 
bool IsMinimized () const
 Check if window is currently minimized. More...
 
bool IsResized () const
 Check if window has been resized last frame. More...
 
bool IsState (unsigned int flag) const
 Check if one specific window flag is enabled. More...
 
WindowMaximize ()
 Set window state: maximized, if resizable (only PLATFORM_DESKTOP) More...
 
WindowMinimize ()
 Set window state: minimized, if resizable (only PLATFORM_DESKTOP) More...
 
WindowRestore ()
 Set window state: not minimized/maximized (only PLATFORM_DESKTOP) More...
 
void SetClipboardText (const std::string_view text)
 Set clipboard text content. More...
 
void SetConfigFlags (unsigned int flags)
 Sets the configuration flags for raylib. More...
 
void SetExitKey (int key)
 Set a custom key to exit program (default is ESC) More...
 
WindowSetFocused ()
 Set window focused (only PLATFORM_DESKTOP) More...
 
WindowSetFullscreen (bool fullscreen)
 Set whether or not the application should be fullscreen. More...
 
WindowSetIcon (const ::Image &image)
 Set icon for window. More...
 
WindowSetIcons (Image *images, int count)
 Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) More...
 
WindowSetIcons (std::span< Image > images)
 Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) More...
 
WindowSetMinSize (const ::Vector2 &size)
 Set window minimum dimensions. More...
 
WindowSetMinSize (int width, int height)
 Set window minimum dimensions. More...
 
WindowSetMonitor (int monitor)
 Set monitor for the current window. More...
 
WindowSetOpacity (float opacity)
 Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) More...
 
WindowSetPosition (const ::Vector2 &position)
 Set window position on screen. More...
 
WindowSetPosition (int x, int y)
 Set window position on screen. More...
 
WindowSetSize (const ::Vector2 &size)
 Set window dimensions. More...
 
WindowSetSize (int width, int height)
 Set window dimensions. More...
 
WindowSetState (unsigned int flag)
 Set window configuration state using flags. More...
 
WindowSetTargetFPS (int fps)
 Set target FPS (maximum) More...
 
WindowSetTitle (const std::string_view title)
 Set title for window. More...
 
bool ShouldClose () const
 Check if KEY_ESCAPE pressed or Close icon pressed. More...
 
WindowToggleBorderless ()
 Toggle window state: borderless/windowed. More...
 
WindowToggleFullscreen ()
 Toggle window state: fullscreen/windowed. More...
 

Static Public Member Functions

static bool IsReady ()
 Check if window has been initialized successfully. More...
 

Detailed Description

Window and Graphics Device Functions.

Definition at line 16 of file Window.hpp.

Constructor & Destructor Documentation

◆ Window() [1/2]

raylib::Window::Window ( )
inline

Build a Window object, but defer the initialization.

Ensure you call Init() manually.

See also
Init()

Definition at line 23 of file Window.hpp.

◆ Window() [2/2]

raylib::Window::Window ( int  width,
int  height,
const std::string_view  title = "raylib",
unsigned int  flags = 0 
)
inline

Initialize window and OpenGL context.

Parameters
widthThe width of the window.
heightThe height of the window.
titleThe desired title of the window.
flagsThe ConfigFlags to set prior to initializing the window. See SetConfigFlags for more details.
See also
SetConfigFlags()
ConfigFlags
Exceptions
raylib::RaylibExceptionThrown if the window failed to initiate.

Definition at line 40 of file Window.hpp.

References Init().

◆ ~Window()

raylib::Window::~Window ( )
inline

Close window and unload OpenGL context.

Definition at line 47 of file Window.hpp.

References Close().

Member Function Documentation

◆ BeginDrawing()

Window & raylib::Window::BeginDrawing ( )
inline

Setup canvas (framebuffer) to start drawing.

Definition at line 353 of file Window.hpp.

References BeginDrawing().

Referenced by BeginDrawing().

◆ ClearBackground()

Window & raylib::Window::ClearBackground ( const ::Color &  color = BLACK)
inline

Clear window with given color.

Definition at line 172 of file Window.hpp.

References ClearBackground().

Referenced by ClearBackground().

◆ ClearState()

Window & raylib::Window::ClearState ( unsigned int  flag)
inline

Clear window configuration state flags.

Definition at line 164 of file Window.hpp.

◆ Close()

void raylib::Window::Close ( )
inline

Close window and unload OpenGL context.

Definition at line 91 of file Window.hpp.

Referenced by ~Window().

◆ DrawFPS()

void raylib::Window::DrawFPS ( int  posX = 10,
int  posY = 10 
) const
inline

Draw current FPS.

Definition at line 440 of file Window.hpp.

References DrawFPS().

Referenced by DrawFPS().

◆ EndDrawing()

Window & raylib::Window::EndDrawing ( )
inline

End canvas drawing and swap buffers (double buffering)

Definition at line 361 of file Window.hpp.

References EndDrawing().

Referenced by EndDrawing().

◆ GetClipboardText()

const std::string raylib::Window::GetClipboardText ( )
inline

Get clipboard text content.

Definition at line 418 of file Window.hpp.

◆ GetFPS()

int raylib::Window::GetFPS ( ) const
inline

Returns current FPS.

Definition at line 433 of file Window.hpp.

◆ GetFrameTime()

float raylib::Window::GetFrameTime ( ) const
inline

Returns time in seconds for last frame drawn.

Definition at line 447 of file Window.hpp.

◆ GetHandle()

void * raylib::Window::GetHandle ( ) const
inline

Get native window handle.

Definition at line 346 of file Window.hpp.

◆ GetHeight()

int raylib::Window::GetHeight ( ) const
inline

Get current screen height.

Definition at line 376 of file Window.hpp.

Referenced by GetSize().

◆ GetPosition()

Vector2 raylib::Window::GetPosition ( ) const
inline

Get window position XY on monitor.

Definition at line 397 of file Window.hpp.

◆ GetRenderHeight()

int raylib::Window::GetRenderHeight ( ) const
inline

Get current render height (it considers HiDPI)

Definition at line 390 of file Window.hpp.

◆ GetRenderWidth()

int raylib::Window::GetRenderWidth ( ) const
inline

Get current render width (it considers HiDPI)

Definition at line 383 of file Window.hpp.

◆ GetScaleDPI()

Vector2 raylib::Window::GetScaleDPI ( ) const
inline

Get window scale DPI factor.

Definition at line 404 of file Window.hpp.

◆ GetSize()

Vector2 raylib::Window::GetSize ( ) const
inline

Get the screen's width and height.

Definition at line 339 of file Window.hpp.

References GetHeight(), and GetWidth().

◆ GetTime()

double raylib::Window::GetTime ( ) const
inline

Returns elapsed time in seconds since InitWindow()

Definition at line 454 of file Window.hpp.

◆ GetWidth()

int raylib::Window::GetWidth ( ) const
inline

Get current screen width.

Definition at line 369 of file Window.hpp.

Referenced by GetSize().

◆ Init()

void raylib::Window::Init ( int  width = 800,
int  height = 450,
const std::string_view  title = "raylib",
unsigned int  flags = 0 
)
inline

Initializes the window.

Parameters
widthThe width of the window.
heightThe height of the window.
titleThe desired title of the window.
flagsThe ConfigFlags to set prior to initializing the window. See SetConfigFlags for more details.
See also
SetConfigFlags()
ConfigFlags
Exceptions
raylib::RaylibExceptionThrown if the window failed to initiate.

Definition at line 64 of file Window.hpp.

References SetConfigFlags().

Referenced by Window().

◆ IsCursorOnScreen()

bool raylib::Window::IsCursorOnScreen ( ) const
inline

Check if cursor is on the current screen.

Definition at line 100 of file Window.hpp.

◆ IsFocused()

bool raylib::Window::IsFocused ( ) const
inline

Check if window is currently focused.

Definition at line 135 of file Window.hpp.

◆ IsFullscreen()

bool raylib::Window::IsFullscreen ( ) const
inline

Check if window is currently fullscreen.

Definition at line 107 of file Window.hpp.

Referenced by SetFullscreen().

◆ IsHidden()

bool raylib::Window::IsHidden ( ) const
inline

Check if window is currently hidden.

Definition at line 114 of file Window.hpp.

◆ IsMaximized()

bool raylib::Window::IsMaximized ( ) const
inline

Check if window is currently minimized.

Definition at line 128 of file Window.hpp.

◆ IsMinimized()

bool raylib::Window::IsMinimized ( ) const
inline

Check if window is currently minimized.

Definition at line 121 of file Window.hpp.

◆ IsReady()

static bool raylib::Window::IsReady ( )
inlinestatic

Check if window has been initialized successfully.

Definition at line 461 of file Window.hpp.

◆ IsResized()

bool raylib::Window::IsResized ( ) const
inline

Check if window has been resized last frame.

Definition at line 142 of file Window.hpp.

◆ IsState()

bool raylib::Window::IsState ( unsigned int  flag) const
inline

Check if one specific window flag is enabled.

Definition at line 149 of file Window.hpp.

◆ Maximize()

Window & raylib::Window::Maximize ( )
inline

Set window state: maximized, if resizable (only PLATFORM_DESKTOP)

Definition at line 213 of file Window.hpp.

◆ Minimize()

Window & raylib::Window::Minimize ( )
inline

Set window state: minimized, if resizable (only PLATFORM_DESKTOP)

Definition at line 221 of file Window.hpp.

◆ Restore()

Window & raylib::Window::Restore ( )
inline

Set window state: not minimized/maximized (only PLATFORM_DESKTOP)

Definition at line 229 of file Window.hpp.

◆ SetClipboardText()

void raylib::Window::SetClipboardText ( const std::string_view  text)
inline

Set clipboard text content.

Definition at line 411 of file Window.hpp.

References SetClipboardText().

Referenced by SetClipboardText().

◆ SetConfigFlags()

void raylib::Window::SetConfigFlags ( unsigned int  flags)
inline

Sets the configuration flags for raylib.

Parameters
flagsThe ConfigFlags to apply to the configuration.
See also
SetConfigFlags

Definition at line 472 of file Window.hpp.

References SetConfigFlags().

Referenced by Init(), and SetConfigFlags().

◆ SetExitKey()

void raylib::Window::SetExitKey ( int  key)
inline

Set a custom key to exit program (default is ESC)

Definition at line 84 of file Window.hpp.

References SetExitKey().

Referenced by SetExitKey().

◆ SetFocused()

Window & raylib::Window::SetFocused ( )
inline

Set window focused (only PLATFORM_DESKTOP)

Definition at line 324 of file Window.hpp.

◆ SetFullscreen()

Window & raylib::Window::SetFullscreen ( bool  fullscreen)
inline

Set whether or not the application should be fullscreen.

Definition at line 188 of file Window.hpp.

References IsFullscreen(), and ToggleFullscreen().

◆ SetIcon()

Window & raylib::Window::SetIcon ( const ::Image &  image)
inline

Set icon for window.

Definition at line 237 of file Window.hpp.

◆ SetIcons() [1/2]

Window & raylib::Window::SetIcons ( Image images,
int  count 
)
inline

Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)

Definition at line 245 of file Window.hpp.

◆ SetIcons() [2/2]

Window & raylib::Window::SetIcons ( std::span< Image images)
inline

Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)

Definition at line 253 of file Window.hpp.

◆ SetMinSize() [1/2]

Window & raylib::Window::SetMinSize ( const ::Vector2 &  size)
inline

Set window minimum dimensions.

Definition at line 300 of file Window.hpp.

◆ SetMinSize() [2/2]

Window & raylib::Window::SetMinSize ( int  width,
int  height 
)
inline

Set window minimum dimensions.

Definition at line 292 of file Window.hpp.

◆ SetMonitor()

Window & raylib::Window::SetMonitor ( int  monitor)
inline

Set monitor for the current window.

Definition at line 284 of file Window.hpp.

◆ SetOpacity()

Window & raylib::Window::SetOpacity ( float  opacity)
inline

Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)

Definition at line 316 of file Window.hpp.

◆ SetPosition() [1/2]

Window & raylib::Window::SetPosition ( const ::Vector2 &  position)
inline

Set window position on screen.

Definition at line 277 of file Window.hpp.

References SetPosition().

◆ SetPosition() [2/2]

Window & raylib::Window::SetPosition ( int  x,
int  y 
)
inline

Set window position on screen.

Definition at line 269 of file Window.hpp.

Referenced by SetPosition().

◆ SetSize() [1/2]

Window & raylib::Window::SetSize ( const ::Vector2 &  size)
inline

Set window dimensions.

Definition at line 332 of file Window.hpp.

References SetSize().

◆ SetSize() [2/2]

Window & raylib::Window::SetSize ( int  width,
int  height 
)
inline

Set window dimensions.

Definition at line 308 of file Window.hpp.

Referenced by SetSize().

◆ SetState()

Window & raylib::Window::SetState ( unsigned int  flag)
inline

Set window configuration state using flags.

Definition at line 156 of file Window.hpp.

◆ SetTargetFPS()

Window & raylib::Window::SetTargetFPS ( int  fps)
inline

Set target FPS (maximum)

Definition at line 425 of file Window.hpp.

References SetTargetFPS().

Referenced by SetTargetFPS().

◆ SetTitle()

Window & raylib::Window::SetTitle ( const std::string_view  title)
inline

Set title for window.

Definition at line 261 of file Window.hpp.

◆ ShouldClose()

bool raylib::Window::ShouldClose ( ) const
inline

Check if KEY_ESCAPE pressed or Close icon pressed.

Definition at line 77 of file Window.hpp.

◆ ToggleBorderless()

Window & raylib::Window::ToggleBorderless ( )
inline

Toggle window state: borderless/windowed.

Definition at line 205 of file Window.hpp.

◆ ToggleFullscreen()

Window & raylib::Window::ToggleFullscreen ( )
inline

Toggle window state: fullscreen/windowed.

Definition at line 180 of file Window.hpp.

References ToggleFullscreen().

Referenced by SetFullscreen(), and ToggleFullscreen().