1#ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
2#define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
7#include "./RaylibException.hpp"
20 Window(
int width = 800,
int height = 450,
const std::string& title =
"raylib",
21 bool lateInit =
false) {
23 if (!
Init(width, height, title)) {
41 bool Init(
int width = 800,
int height = 450,
const std::string& title =
"raylib") {
43 return IsWindowReady();
50 return ::WindowShouldClose();
64 return ::IsCursorOnScreen();
71 return ::IsWindowReady();
78 return ::IsWindowFullscreen();
85 return ::IsWindowHidden();
92 return ::IsWindowMinimized();
99 return ::IsWindowMaximized();
106 return ::IsWindowFocused();
113 return ::IsWindowResized();
119 inline bool IsState(
unsigned int flag)
const {
120 return ::IsWindowState(flag);
127 ::SetWindowState(flag);
135 ::ClearWindowState(flag);
200 ::SetWindowIcon(image);
216 ::SetWindowPosition(x, y);
224 return SetPosition(
static_cast<int>(position.x),
static_cast<int>(position.y));
231 ::SetWindowMonitor(monitor);
239 ::SetWindowMinSize(width, height);
247 ::SetWindowMinSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
255 ::SetWindowSize(width, height);
263 return SetSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
277 return ::GetWindowHandle();
300 return ::GetScreenWidth();
307 return ::GetScreenHeight();
314 return ::GetWindowPosition();
321 return ::GetWindowScaleDPI();
351 return ::GetFrameTime();
Exception used for most raylib-related exceptions.
Window and Graphics Device Functions.
int GetHeight() const
Get current screen height.
bool Init(int width=800, int height=450, const std::string &title="raylib")
Initializes the window.
Window & ToggleFullscreen()
Toggle window state: fullscreen/windowed.
Window & SetPosition(int x, int y)
Set window position on screen.
int GetWidth() const
Get current screen width.
Window & ClearState(unsigned int flag)
Clear window configuration state flags.
Window & Restore()
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
Window & SetSize(const ::Vector2 &size)
Set window dimensions.
inline ::Vector2 GetPosition() const
Get window position XY on monitor.
Window & SetState(unsigned int flag)
Set window configuration state using flags.
Window & SetTitle(const std::string &title)
Set title for window.
Window & SetMonitor(int monitor)
Set monitor for the current window.
Window & BeginDrawing()
Setup canvas (framebuffer) to start drawing.
Window & SetMinSize(const ::Vector2 &size)
Set window minimum dimensions.
Window(int width=800, int height=450, const std::string &title="raylib", bool lateInit=false)
Initialize window and OpenGL context.
bool IsFullscreen() const
Check if window is currently fullscreen.
Window & Maximize()
Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void Close()
Close window and unload OpenGL context.
bool IsState(unsigned int flag) const
Check if one specific window flag is enabled.
bool ShouldClose() const
Check if KEY_ESCAPE pressed or Close icon pressed.
~Window()
Close window and unload OpenGL context.
double GetTime() const
Returns elapsed time in seconds since InitWindow()
Window & ClearBackground(const ::Color &color=BLACK)
Clear window with given color.
Window & SetTargetFPS(int fps)
Set target FPS (maximum)
Window & SetSize(int width, int height)
Set window dimensions.
int GetFPS() const
Returns current FPS.
Window & SetPosition(const ::Vector2 &position)
Set window position on screen.
Window & SetFullscreen(bool fullscreen)
Set whether or not the application should be fullscreen.
static bool IsReady()
Check if window has been initialized successfully.
float GetFrameTime() const
Returns time in seconds for last frame drawn.
bool IsCursorOnScreen() const
Check if cursor is on the current screen.
Vector2 GetSize() const
Get the screen's width and height.
bool IsHidden() const
Check if window is currently hidden.
inline ::Vector2 GetScaleDPI() const
Get window scale DPI factor.
Window & DrawFPS(int posX=10, int posY=10)
Draw current FPS.
Window & EndDrawing()
End canvas drawing and swap buffers (double buffering)
bool IsResized() const
Check if window has been resized last frame.
Window & SetIcon(const ::Image &image)
Set icon for window.
Window & Minimize()
Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
bool IsFocused() const
Check if window is currently focused.
bool IsMaximized() const
Check if window is currently minimized.
bool IsMinimized() const
Check if window is currently minimized.
Window & SetMinSize(int width, int height)
Set window minimum dimensions.
void * GetHandle() const
Get native window handle.
All raylib-cpp classes and functions appear in the raylib namespace.
static void SetWindowTitle(const std::string &title)
Set title for window.
static void InitWindow(int width, int height, const std::string &title="raylib")
Initialize window and OpenGL context.