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);
46 inline void Init(
int width = 800,
int height = 450,
const std::string& title =
"raylib") {
48 if (!IsWindowReady()) {
57 return ::WindowShouldClose();
64 if (::IsWindowReady()) {
73 return ::IsCursorOnScreen();
80 return ::IsWindowReady();
87 return ::IsWindowFullscreen();
94 return ::IsWindowHidden();
101 return ::IsWindowMinimized();
108 return ::IsWindowMaximized();
115 return ::IsWindowFocused();
122 return ::IsWindowResized();
128 inline bool IsState(
unsigned int flag)
const {
129 return ::IsWindowState(flag);
136 ::SetWindowState(flag);
144 ::ClearWindowState(flag);
209 ::SetWindowIcon(image);
225 ::SetWindowPosition(x, y);
233 return SetPosition(
static_cast<int>(position.x),
static_cast<int>(position.y));
240 ::SetWindowMonitor(monitor);
248 ::SetWindowMinSize(width, height);
256 ::SetWindowMinSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
264 ::SetWindowSize(width, height);
272 ::SetWindowOpacity(opacity);
280 return SetSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
294 return ::GetWindowHandle();
317 return ::GetScreenWidth();
324 return ::GetScreenHeight();
331 return ::GetRenderWidth();
338 return ::GetRenderHeight();
345 return ::GetWindowPosition();
352 return ::GetWindowScaleDPI();
387 inline void DrawFPS(
int posX = 10,
int posY = 10)
const {
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 & 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.
void DrawFPS(int posX=10, int posY=10) const
Draw current FPS.
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.