1 #ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
2 #define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
6 #include "./raylib.hpp"
7 #include "./RaylibException.hpp"
8 #include "./Vector2.hpp"
30 Window(
int width,
int height,
const std::string& title =
"raylib") {
31 Init(width, height, title);
47 void Init(
int width = 800,
int height = 450,
const std::string& title =
"raylib") {
49 if (!IsWindowReady()) {
58 return ::WindowShouldClose();
72 return ::IsCursorOnScreen();
79 return ::IsWindowReady();
86 return ::IsWindowFullscreen();
93 return ::IsWindowHidden();
100 return ::IsWindowMinimized();
107 return ::IsWindowMaximized();
114 return ::IsWindowFocused();
121 return ::IsWindowResized();
127 inline bool IsState(
unsigned int flag)
const {
128 return ::IsWindowState(flag);
135 ::SetWindowState(flag);
143 ::ClearWindowState(flag);
208 ::SetWindowIcon(image);
224 ::SetWindowPosition(x, y);
232 return SetPosition(
static_cast<int>(position.x),
static_cast<int>(position.y));
239 ::SetWindowMonitor(monitor);
247 ::SetWindowMinSize(width, height);
255 ::SetWindowMinSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
263 ::SetWindowSize(width, height);
271 ::SetWindowOpacity(opacity);
279 return SetSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
293 return ::GetWindowHandle();
316 return ::GetScreenWidth();
323 return ::GetScreenHeight();
330 return ::GetRenderWidth();
337 return ::GetRenderHeight();
344 return ::GetWindowPosition();
351 return ::GetWindowScaleDPI();
395 return ::GetFrameTime();
Exception used for most raylib-related exceptions.
Window and Graphics Device Functions.
int GetHeight() const
Get current screen height.
int GetRenderWidth() const
Get current render width (it considers HiDPI)
void * GetHandle() const
Get native window handle.
Window(int width, int height, const std::string &title="raylib")
Initialize window and OpenGL context.
int GetRenderHeight() const
Get current render height (it considers HiDPI)
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.
Vector2 GetScaleDPI() const
Get window scale DPI factor.
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()
const std::string & GetClipboardText()
Get clipboard text content.
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 & 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.
bool IsResized() const
Check if window has been resized last frame.
Window & SetMinSize(int width, int height)
Set window minimum dimensions.
Window()
Build a Window object, but defer the initialization.
Window & SetMinSize(const ::Vector2 &size)
Set window minimum dimensions.
Window & SetOpacity(float opacity)
Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
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.
void SetClipboardText(const std::string &text)
Set clipboard text content.
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.