1 #ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
2 #define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
6 #include "./raylib.hpp"
7 #include "./RaylibException.hpp"
22 Window(
int width,
int height,
const std::string& title) {
23 Init(width, height, title);
39 void Init(
int width = 800,
int height = 450,
const std::string& title =
"raylib") {
41 if (!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.
void * GetHandle() const
Get native window handle.
Window & Minimize()
Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
Window & SetTargetFPS(int fps)
Set target FPS (maximum)
int GetWidth() const
Get current screen width.
Window & SetTitle(const std::string &title)
Set title for window.
Window & ClearState(unsigned int flag)
Clear window configuration state flags.
inline ::Vector2 GetPosition() const
Get window position XY on monitor.
Window & DrawFPS(int posX=10, int posY=10)
Draw current FPS.
Window & EndDrawing()
End canvas drawing and swap buffers (double buffering)
Window & ToggleFullscreen()
Toggle window state: fullscreen/windowed.
Window & SetIcon(const ::Image &image)
Set icon for window.
Window & SetSize(const ::Vector2 &size)
Set window dimensions.
bool IsFullscreen() const
Check if window is currently fullscreen.
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 & SetPosition(int x, int y)
Set window position on screen.
Window & SetMonitor(int monitor)
Set monitor for the current window.
Window & ClearBackground(const ::Color &color=BLACK)
Clear window with given color.
Window(int width, int height, const std::string &title)
Initialize window and OpenGL context.
Window & SetPosition(const ::Vector2 &position)
Set window position on screen.
int GetFPS() const
Returns current FPS.
Window & BeginDrawing()
Setup canvas (framebuffer) to start drawing.
Window & SetState(unsigned int flag)
Set window configuration state using flags.
void Init(int width=800, int height=450, const std::string &title="raylib")
Initializes the window.
Window & Restore()
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
static bool IsReady()
Check if window has been initialized successfully.
Window & SetSize(int width, int height)
Set window dimensions.
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.
bool IsResized() const
Check if window has been resized last frame.
Window & SetMinSize(int width, int height)
Set window minimum dimensions.
Window & SetMinSize(const ::Vector2 &size)
Set window minimum dimensions.
bool IsFocused() const
Check if window is currently focused.
bool IsMaximized() const
Check if window is currently minimized.
Window & SetFullscreen(bool fullscreen)
Set whether or not the application should be fullscreen.
Window & Maximize()
Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
bool IsMinimized() const
Check if window is currently minimized.
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.