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 ()
 Close window and unload OpenGL context.
 
WindowBeginDrawing ()
 Setup canvas (framebuffer) to start drawing.
 
WindowClearBackground (const ::Color &color=BLACK)
 Clear window with given color.
 
WindowClearState (unsigned int flag)
 Clear window configuration state flags.
 
void Close ()
 Close window and unload OpenGL context.
 
WindowDrawFPS (int posX=10, int posY=10)
 Draw current FPS.
 
WindowEndDrawing ()
 End canvas drawing and swap buffers (double buffering)
 
int GetFPS () const
 Returns current FPS.
 
float GetFrameTime () const
 Returns time in seconds for last frame drawn.
 
void * GetHandle () const
 Get native window handle.
 
int GetHeight () const
 Get current screen height.
 
inline ::Vector2 GetPosition () const
 Get window position XY on monitor.
 
inline ::Vector2 GetScaleDPI () const
 Get window scale DPI factor.
 
Vector2 GetSize () const
 Get the screen's width and height.
 
double GetTime () const
 Returns elapsed time in seconds since InitWindow()
 
int GetWidth () const
 Get current screen width.
 
bool Init (int width=800, int height=450, const std::string &title="raylib")
 Initializes the window. More...
 
bool IsCursorOnScreen () const
 Check if cursor is on the current screen.
 
bool IsFocused () const
 Check if window is currently focused.
 
bool IsFullscreen () const
 Check if window is currently fullscreen.
 
bool IsHidden () const
 Check if window is currently hidden.
 
bool IsMaximized () const
 Check if window is currently minimized.
 
bool IsMinimized () const
 Check if window is currently minimized.
 
bool IsResized () const
 Check if window has been resized last frame.
 
bool IsState (unsigned int flag) const
 Check if one specific window flag is enabled.
 
WindowMaximize ()
 Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
 
WindowMinimize ()
 Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
 
WindowRestore ()
 Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
 
WindowSetFullscreen (bool fullscreen)
 Set whether or not the application should be fullscreen.
 
WindowSetIcon (const ::Image &image)
 Set icon for window.
 
WindowSetMinSize (const ::Vector2 &size)
 Set window minimum dimensions.
 
WindowSetMinSize (int width, int height)
 Set window minimum dimensions.
 
WindowSetMonitor (int monitor)
 Set monitor for the current window.
 
WindowSetPosition (const ::Vector2 &position)
 Set window position on screen.
 
WindowSetPosition (int x, int y)
 Set window position on screen.
 
WindowSetSize (const ::Vector2 &size)
 Set window dimensions.
 
WindowSetSize (int width, int height)
 Set window dimensions.
 
WindowSetState (unsigned int flag)
 Set window configuration state using flags.
 
WindowSetTargetFPS (int fps)
 Set target FPS (maximum)
 
WindowSetTitle (const std::string &title)
 Set title for window.
 
bool ShouldClose () const
 Check if KEY_ESCAPE pressed or Close icon pressed.
 
WindowToggleFullscreen ()
 Toggle window state: fullscreen/windowed.
 

Static Public Member Functions

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

Detailed Description

Window and Graphics Device Functions.

Definition at line 13 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.

Exceptions
raylib::RaylibExceptionThrown if the window failed to initiate.

Definition at line 20 of file Window.hpp.

References Init().

Member Function Documentation

◆ Init()

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

Initializes the window.

Returns
True or false, depending on if the Window initialized properly.

Definition at line 41 of file Window.hpp.

References raylib::InitWindow().

Referenced by Window().