1#ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
2#define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
8#include "./RaylibException.hpp"
9#include "./Vector2.hpp"
10#include "./raylib.hpp"
39 Window(
int width,
int height,
const std::string_view title =
"raylib",
unsigned int flags = 0) {
40 Init(width, height, title, flags);
61 void Init(
int width = 800,
int height = 450,
const std::string_view title =
"raylib",
unsigned int flags = 0) {
66 if (!::IsWindowReady()) {
85 if (::IsWindowReady()) {
118 static bool IsHidden() { return ::IsWindowHidden(); }
143 static bool IsState(
unsigned int flag) { return ::IsWindowState(flag); }
149 ::SetWindowState(flag);
157 ::ClearWindowState(flag);
199 ::ToggleBorderlessWindowed();
231 ::SetWindowIcon(image);
239 ::SetWindowIcons(images, count);
247 ::SetWindowIcons(images.data(),
static_cast<int>(images.size()));
263 ::SetWindowPosition(x, y);
271 return SetPosition(
static_cast<int>(position.x),
static_cast<int>(position.y));
278 ::SetWindowMonitor(monitor);
286 ::SetWindowMinSize(width, height);
294 ::SetWindowMinSize(
static_cast<int>(size.x),
static_cast<int>(size.y));
302 ::SetWindowSize(width, height);
310 ::SetWindowOpacity(opacity);
318 ::SetWindowFocused();
335 static void*
GetHandle() { return ::GetWindowHandle(); }
356 static int GetWidth() { return ::GetScreenWidth(); }
381 static int GetMonitor() { return ::GetCurrentMonitor(); }
411 static int GetFPS() { return ::GetFPS(); }
426 static double GetTime() { return ::GetTime(); }
431 static bool IsValid() { return ::IsWindowReady(); }
Image type, bpp always RGBA (32bit)
Exception used for most raylib-related exceptions.
Window and Graphics Device Functions.
void SetClipboardText(const std::string_view text)
Set clipboard text content.
Window & ToggleFullscreen()
Toggle window state: fullscreen/windowed.
static bool IsMaximized()
Check if window is currently minimized.
static int GetRenderWidth()
Get current render width (it considers HiDPI)
static bool IsCursorOnScreen()
Check if cursor is on the current screen.
static int GetHeight()
Get current screen height.
static bool IsHidden()
Check if window is currently hidden.
static int GetFPS()
Returns current FPS.
Window & SetPosition(int x, int y)
Set window position on screen.
static Vector2 GetPosition()
Get window position XY on monitor.
bool m_drawing
Handles the internal drawing state for calling either BeginDrawing() or EndDrawing() from the Drawing...
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.
static void * GetHandle()
Get native window handle.
Window & Restore()
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
static Vector2 GetScaleDPI()
Get window scale DPI factor.
Window & SetSize(const ::Vector2 &size)
Set window dimensions.
static bool IsValid()
Check if window has been initialized successfully.
Window & SetState(unsigned int flag)
Set window configuration state using flags.
Window & SetMonitor(int monitor)
Set monitor for the current window.
static bool IsResized()
Check if window has been resized last frame.
Window & BeginDrawing()
Setup canvas (framebuffer) to start drawing.
Window & SetMinSize(const ::Vector2 &size)
Set window minimum dimensions.
static void DrawFPS(int posX=10, int posY=10)
Draw current FPS.
static bool IsState(unsigned int flag)
Check if one specific window flag is enabled.
Window & Maximize()
Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
~Window()
Close window and unload OpenGL context.
static bool ShouldClose()
Check if KEY_ESCAPE pressed or Close icon pressed.
static std::string GetClipboardText()
Get clipboard text content.
static void HideCursor()
Hides cursor.
static bool IsMinimized()
Check if window is currently minimized.
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.
static bool IsCursorHidden()
Check if cursor is not visible.
static Vector2 GetSize()
Get the screen's width and height.
Window & SetTargetFPS(int fps)
Set target FPS (maximum)
Window & SetSize(int width, int height)
Set window dimensions.
static int GetWidth()
Get current screen width.
static int GetRenderHeight()
Get current render height (it considers HiDPI)
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 IsFullscreen()
Check if window is currently fullscreen.
Window & ToggleBorderless()
Toggle window state: borderless/windowed.
static void Close()
Close window and unload OpenGL context.
static double GetTime()
Returns elapsed time in seconds since InitWindow()
Window & SetIcons(Image *images, int count)
Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
bool Drawing()
Alternates between calling BeginDrawing() and EndDrawing().
Window & EndDrawing()
End canvas drawing and swap buffers (double buffering)
static void SetExitKey(int key)
Set a custom key to exit program (default is ESC)
Window & SetOpacity(float opacity)
Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
Window()=default
Build a Window object, but defer the initialization.
static bool IsFocused()
Check if window is currently focused.
Window & SetIcon(const ::Image &image)
Set icon for window.
Window & Minimize()
Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
static float GetFrameTime()
Returns time in seconds for last frame drawn.
static void SetConfigFlags(unsigned int flags)
Sets the configuration flags for raylib.
Window(int width, int height, const std::string_view title="raylib", unsigned int flags=0)
Initialize window and OpenGL context.
static void ShowCursor()
Shows cursor.
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)
All raylib-cpp classes and functions appear in the raylib namespace.
static void SetWindowTitle(const std::string_view title)
Set title for window.
static void InitWindow(int width, int height, const std::string_view title="raylib")
Initialize window and OpenGL context.