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...
 
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...
 
inline ::Vector2 GetPosition () const
 Get window position XY on monitor. More...
 
inline ::Vector2 GetScaleDPI () const
 Get window scale DPI factor. More...
 
inline ::Vector2 GetSize ()
 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 &title="raylib")
 
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 & SetFullscreen (bool fullscreen)
 Set whether or not the application should be fullscreen. More...
 
Window & SetIcon (const ::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 (const ::Vector2 &position)
 Set window position on screen. More...
 
Window & SetPosition (int x, int y)
 Set window position on screen. More...
 
Window & SetSize (const ::Vector2 &size)
 Set window dimensions. 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 285 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 293 of file Window.hpp.

◆ GetFPS()

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

Returns current FPS.

Definition at line 337 of file Window.hpp.

◆ GetFrameTime()

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

Returns time in seconds for last frame drawn.

Definition at line 344 of file Window.hpp.

◆ GetHandle()

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

Get native window handle.

Definition at line 278 of file Window.hpp.

◆ GetHeight()

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

Get current screen height.

Definition at line 308 of file Window.hpp.

Referenced by GetSize().

◆ GetPosition()

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

Get window position XY on monitor.

Definition at line 315 of file Window.hpp.

◆ GetScaleDPI()

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

Get window scale DPI factor.

Definition at line 322 of file Window.hpp.

◆ GetSize()

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

Get the screen's width and height.

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

◆ GetWidth()

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

Get current screen width.

Definition at line 301 of file Window.hpp.

Referenced by GetSize().

◆ Init()

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

Definition at line 60 of file Window.hpp.

References raylib::InitWindow().

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.

Referenced by SetFullscreen().

◆ 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 185 of file Window.hpp.

◆ Minimize()

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

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

Definition at line 193 of file Window.hpp.

◆ Restore()

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

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

Definition at line 201 of file Window.hpp.

◆ SetFullscreen()

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

Set whether or not the application should be fullscreen.

Definition at line 168 of file Window.hpp.

References IsFullscreen(), and ToggleFullscreen().

◆ SetIcon()

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

Set icon for window.

Definition at line 209 of file Window.hpp.

◆ SetMinSize()

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

Set window minimum dimensions.

Definition at line 248 of file Window.hpp.

◆ SetMonitor()

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

Set monitor for the current window.

Definition at line 240 of file Window.hpp.

◆ SetPosition() [1/2]

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

Set window position on screen.

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

Referenced by SetPosition().

◆ SetSize() [1/2]

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

Set window dimensions.

Definition at line 264 of file Window.hpp.

References SetSize().

◆ SetSize() [2/2]

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

Set window dimensions.

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

◆ SetTargetFPS()

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

Set target FPS (maximum)

Definition at line 329 of file Window.hpp.

◆ SetTitle()

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

Set title for window.

Definition at line 217 of file Window.hpp.

References raylib::SetWindowTitle().

◆ 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.

Referenced by SetFullscreen().

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