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 ()
 Build a Window object, but defer the initialization. More...
 
 Window (int width, int height, const std::string &title="raylib", unsigned int flags=0)
 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.
 
void DrawFPS (int posX=10, int posY=10) const
 Draw current FPS.
 
WindowEndDrawing ()
 End canvas drawing and swap buffers (double buffering)
 
const std::string GetClipboardText ()
 Get clipboard text content.
 
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.
 
Vector2 GetPosition () const
 Get window position XY on monitor.
 
int GetRenderHeight () const
 Get current render height (it considers HiDPI)
 
int GetRenderWidth () const
 Get current render width (it considers HiDPI)
 
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.
 
void Init (int width=800, int height=450, const std::string &title="raylib", unsigned int flags=0)
 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)
 
void SetClipboardText (const std::string &text)
 Set clipboard text content.
 
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)
 
WindowSetFocused ()
 Set window focused (only PLATFORM_DESKTOP)
 
WindowSetFullscreen (bool fullscreen)
 Set whether or not the application should be fullscreen.
 
WindowSetIcon (const ::Image &image)
 Set icon for window.
 
WindowSetIcons (Image *images, int count)
 Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
 
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.
 
WindowSetOpacity (float opacity)
 Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
 
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.
 
WindowToggleBorderless ()
 Toggle window state: borderless/windowed.
 
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 14 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 21 of file Window.hpp.

◆ Window() [2/2]

raylib::Window::Window ( int  width,
int  height,
const std::string &  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 38 of file Window.hpp.

References Init().

Member Function Documentation

◆ Init()

void raylib::Window::Init ( int  width = 800,
int  height = 450,
const std::string &  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 60 of file Window.hpp.

References raylib::InitWindow(), and SetConfigFlags().

Referenced by Window().

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

Referenced by Init().