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

Window and Graphics Device Functions. More...

Public Member Functions

 Window (int width=800, int height=450, const std::string &title="raylib", bool lateInit=false)
 Initialize window and OpenGL context. More...
 
 ~Window ()
 
Window & BeginDrawing ()
 Setup canvas (framebuffer) to start drawing. More...
 
Window & ClearState (unsigned int flag)
 Clear window configuration state flags. More...
 
void Close ()
 Close window and unload OpenGL context. More...
 
Window & EndDrawing ()
 End canvas drawing and swap buffers (double buffering) More...
 
std::string GetClipboardText () const
 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...
 
std::string GetMonitorName (int monitor) const
 Get the human-readable, UTF-8 encoded name of the primary monitor. More...
 
Vector2 GetPosition () const
 Get window position XY on monitor. More...
 
Vector2 GetScaleDPI () const
 Get window scale DPI factor. More...
 
int GetScreenHeight () const
 Get current screen height. More...
 
int GetScreenWidth () const
 Get current screen width. More...
 
double GetTime () const
 Returns elapsed time in seconds since InitWindow() More...
 
void Init (int width, int height, const std::string &title)
 
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...
 
Window & Maximize ()
 Set window state: maximized, if resizable (only PLATFORM_DESKTOP) More...
 
Window & Minimize ()
 Set window state: minimized, if resizable (only PLATFORM_DESKTOP) More...
 
Window & Restore ()
 Set window state: not minimized/maximized (only PLATFORM_DESKTOP) More...
 
Window & SetClipboardText (const std::string &text)
 Set clipboard text content. More...
 
Window & SetIcon (::Image image)
 Set icon for window. More...
 
Window & SetMinSize (int width, int height)
 Set window minimum dimensions. More...
 
Window & SetMonitor (int monitor)
 Set monitor for the current window. More...
 
Window & SetPosition (int x, int y)
 Set window position on screen. More...
 
Window & SetSize (int width, int height)
 Set window dimensions. More...
 
Window & SetState (unsigned int flag)
 Set window configuration state using flags. More...
 
Window & SetTargetFPS (int fps)
 Set target FPS (maximum) More...
 
Window & SetTitle (const std::string &title)
 Set title for window. More...
 
bool ShouldClose () const
 Check if KEY_ESCAPE pressed or Close icon pressed. More...
 
Window & ToggleFullscreen ()
 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.

raylib::Window w(640, 480, "raylib-cpp");
while (!w.ShouldClose()) {
// Update
}

Definition at line 44 of file Window.hpp.

Constructor & Destructor Documentation

◆ Window()

raylib::Window::Window ( int  width = 800,
int  height = 450,
const std::string &  title = "raylib",
bool  lateInit = false 
)
inline

Initialize window and OpenGL context.

Definition at line 49 of file Window.hpp.

References Init().

◆ ~Window()

raylib::Window::~Window ( )
inline

Definition at line 56 of file Window.hpp.

References Close().

Member Function Documentation

◆ BeginDrawing()

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

Setup canvas (framebuffer) to start drawing.

Definition at line 247 of file Window.hpp.

◆ ClearState()

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

Clear window configuration state flags.

Definition at line 152 of file Window.hpp.

◆ Close()

void raylib::Window::Close ( )
inline

Close window and unload OpenGL context.

Definition at line 74 of file Window.hpp.

Referenced by ~Window().

◆ EndDrawing()

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

End canvas drawing and swap buffers (double buffering)

Definition at line 255 of file Window.hpp.

◆ GetClipboardText()

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

Get clipboard text content.

Definition at line 298 of file Window.hpp.

◆ GetFPS()

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

Returns current FPS.

Definition at line 321 of file Window.hpp.

◆ GetFrameTime()

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

Returns time in seconds for last frame drawn.

Definition at line 328 of file Window.hpp.

◆ GetHandle()

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

Get native window handle.

Definition at line 240 of file Window.hpp.

◆ GetMonitorName()

std::string raylib::Window::GetMonitorName ( int  monitor) const
inline

Get the human-readable, UTF-8 encoded name of the primary monitor.

Definition at line 291 of file Window.hpp.

◆ GetPosition()

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

Get window position XY on monitor.

Definition at line 277 of file Window.hpp.

◆ GetScaleDPI()

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

Get window scale DPI factor.

Definition at line 284 of file Window.hpp.

◆ GetScreenHeight()

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

Get current screen height.

Definition at line 270 of file Window.hpp.

◆ GetScreenWidth()

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

Get current screen width.

Definition at line 263 of file Window.hpp.

◆ GetTime()

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

Returns elapsed time in seconds since InitWindow()

Definition at line 335 of file Window.hpp.

◆ Init()

void raylib::Window::Init ( int  width,
int  height,
const std::string &  title 
)
inline

Definition at line 60 of file Window.hpp.

Referenced by Window().

◆ IsCursorOnScreen()

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

Check if cursor is on the current screen.

Definition at line 81 of file Window.hpp.

◆ IsFocused()

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

Check if window is currently focused.

Definition at line 123 of file Window.hpp.

◆ IsFullscreen()

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

Check if window is currently fullscreen.

Definition at line 95 of file Window.hpp.

◆ IsHidden()

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

Check if window is currently hidden.

Definition at line 102 of file Window.hpp.

◆ IsMaximized()

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

Check if window is currently minimized.

Definition at line 116 of file Window.hpp.

◆ IsMinimized()

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

Check if window is currently minimized.

Definition at line 109 of file Window.hpp.

◆ IsReady()

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

Check if window has been initialized successfully.

Definition at line 88 of file Window.hpp.

◆ IsResized()

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

Check if window has been resized last frame.

Definition at line 130 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 137 of file Window.hpp.

◆ Maximize()

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

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

Definition at line 168 of file Window.hpp.

◆ Minimize()

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

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

Definition at line 176 of file Window.hpp.

◆ Restore()

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

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

Definition at line 184 of file Window.hpp.

◆ SetClipboardText()

Window& raylib::Window::SetClipboardText ( const std::string &  text)
inline

Set clipboard text content.

Definition at line 305 of file Window.hpp.

◆ SetIcon()

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

Set icon for window.

Definition at line 192 of file Window.hpp.

◆ SetMinSize()

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

Set window minimum dimensions.

Definition at line 224 of file Window.hpp.

◆ SetMonitor()

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

Set monitor for the current window.

Definition at line 216 of file Window.hpp.

◆ SetPosition()

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

Set window position on screen.

Definition at line 208 of file Window.hpp.

◆ SetSize()

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

Set window dimensions.

Definition at line 232 of file Window.hpp.

◆ SetState()

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

Set window configuration state using flags.

Definition at line 144 of file Window.hpp.

◆ SetTargetFPS()

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

Set target FPS (maximum)

Definition at line 313 of file Window.hpp.

◆ SetTitle()

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

Set title for window.

Definition at line 200 of file Window.hpp.

◆ ShouldClose()

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

Check if KEY_ESCAPE pressed or Close icon pressed.

Definition at line 67 of file Window.hpp.

◆ ToggleFullscreen()

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

Toggle window state: fullscreen/windowed.

Definition at line 160 of file Window.hpp.

raylib::Window
Window and Graphics Device Functions.
Definition: Window.hpp:44