1#ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
2#define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
9#include "./RaylibException.hpp"
10#include "./Vector2.hpp"
40 Window(
int width,
int height,
const std::string_view title =
"raylib",
unsigned int flags = 0) {
41 Init(width, height, title, flags);
64 void Init(
int width = 800,
int height = 450,
const std::string_view title =
"raylib",
unsigned int flags = 0) {
68 ::InitWindow(width, height, title.data());
69 if (!::IsWindowReady()) {
78 return ::WindowShouldClose();
92 if (::IsWindowReady()) {
101 return ::IsCursorOnScreen();
108 return ::IsWindowFullscreen();
115 return ::IsWindowHidden();
122 return ::IsWindowMinimized();
129 return ::IsWindowMaximized();
136 return ::IsWindowFocused();
143 return ::IsWindowResized();
150 return ::IsWindowState(flag);
157 ::SetWindowState(flag);
165 ::ClearWindowState(flag);
206 ::ToggleBorderlessWindowed();
238 ::SetWindowIcon(image);
246 ::SetWindowIcons(images, count);
254 ::SetWindowIcons(images.data(),
static_cast<int>(images.size()));
262 ::SetWindowTitle(title.data());
270 ::SetWindowPosition(x, y);
278 return SetPosition(
static_cast<int>(position.x),
static_cast<int>(position.y));
285 ::SetWindowMonitor(monitor);
293 ::SetWindowMinSize(width, height);
301 ::SetWindowMinSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
309 ::SetWindowSize(width, height);
317 ::SetWindowOpacity(opacity);
325 ::SetWindowFocused();
333 return SetSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
347 return ::GetWindowHandle();
370 return ::GetScreenWidth();
377 return ::GetScreenHeight();
384 return ::GetRenderWidth();
391 return ::GetRenderHeight();
398 return ::GetWindowPosition();
405 return ::GetWindowScaleDPI();
419 return ::GetClipboardText();
440 void DrawFPS(
int posX = 10,
int posY = 10)
const {
448 return ::GetFrameTime();
462 return ::IsWindowReady();
Image type, bpp always RGBA (32bit)
Exception used for most raylib-related exceptions.
Window and Graphics Device Functions.
int GetHeight() const
Get current screen height.
void SetClipboardText(const std::string_view text)
Set clipboard text content.
int GetRenderWidth() const
Get current render width (it considers HiDPI)
Window & ToggleFullscreen()
Toggle window state: fullscreen/windowed.
int GetRenderHeight() const
Get current render height (it considers HiDPI)
Window & SetPosition(int x, int y)
Set window position on screen.
int GetWidth() const
Get current screen width.
Window & SetFocused()
Set window focused (only PLATFORM_DESKTOP)
Window & ClearState(unsigned int flag)
Clear window configuration state flags.
Window & SetTitle(const std::string_view title)
Set title for window.
Vector2 GetScaleDPI() const
Get window scale DPI factor.
Window & Restore()
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
Window & SetSize(const ::Vector2 &size)
Set window dimensions.
Vector2 GetPosition() const
Get window position XY on monitor.
Window & SetState(unsigned int flag)
Set window configuration state using flags.
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.
bool IsFullscreen() const
Check if window is currently fullscreen.
void SetConfigFlags(unsigned int flags)
Sets the configuration flags for raylib.
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()
void Init(int width=800, int height=450, const std::string_view title="raylib", unsigned int flags=0)
Initializes the window.
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.
void SetExitKey(int key)
Set a custom key to exit program (default is ESC)
void DrawFPS(int posX=10, int posY=10) const
Draw current FPS.
const std::string GetClipboardText()
Get clipboard text content.
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.
Window & ToggleBorderless()
Toggle window state: borderless/windowed.
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.
Window & SetIcons(Image *images, int count)
Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
Window & EndDrawing()
End canvas drawing and swap buffers (double buffering)
bool IsResized() const
Check if window has been resized last frame.
Window()
Build a Window object, but defer the initialization.
Window & SetOpacity(float opacity)
Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
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.
Window(int width, int height, const std::string_view title="raylib", unsigned int flags=0)
Initialize window and OpenGL context.
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.
Window & SetIcons(std::span< Image > images)
Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
void * GetHandle() const
Get native window handle.