 |
raylib-cpp
C++ object-oriented wrapper library for raylib.
|
1 #ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
2 #define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
6 #include "./raylib.hpp"
7 #include "./RaylibException.hpp"
20 Window(
int width = 800,
int height = 450,
const std::string& title =
"raylib",
21 bool lateInit =
false) {
23 if (!
Init(width, height, title)) {
41 bool Init(
int width = 800,
int height = 450,
const std::string& title =
"raylib") {
43 return 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();
363 #endif // RAYLIB_CPP_INCLUDE_WINDOW_HPP_
int GetWidth() const
Get current screen width.
void * GetHandle() const
Get native window handle.
All raylib-cpp classes and functions appear in the raylib namespace.
Window & SetMonitor(int monitor)
Set monitor for the current window.
double GetTime() const
Returns elapsed time in seconds since InitWindow()
~Window()
Close window and unload OpenGL context.
bool IsHidden() const
Check if window is currently hidden.
static void SetWindowTitle(const std::string &title)
Set title for window.
void Close()
Close window and unload OpenGL context.
Window & ClearBackground(const ::Color &color=BLACK)
Clear window with given color.
Window & SetMinSize(int width, int height)
Set window minimum dimensions.
Window & SetState(unsigned int flag)
Set window configuration state using flags.
float GetFrameTime() const
Returns time in seconds for last frame drawn.
bool ShouldClose() const
Check if KEY_ESCAPE pressed or Close icon pressed.
static void InitWindow(int width, int height, const std::string &title="raylib")
Initialize window and OpenGL context.
Window & SetFullscreen(bool fullscreen)
Set whether or not the application should be fullscreen.
Window & SetPosition(int x, int y)
Set window position on screen.
Window & SetSize(const ::Vector2 &size)
Set window dimensions.
bool IsMaximized() const
Check if window is currently minimized.
inline ::Vector2 GetScaleDPI() const
Get window scale DPI factor.
Window(int width=800, int height=450, const std::string &title="raylib", bool lateInit=false)
Initialize window and OpenGL context.
bool IsFocused() const
Check if window is currently focused.
bool IsResized() const
Check if window has been resized last frame.
int GetHeight() const
Get current screen height.
bool Init(int width=800, int height=450, const std::string &title="raylib")
Initializes the window.
Window & EndDrawing()
End canvas drawing and swap buffers (double buffering)
Window & SetSize(int width, int height)
Set window dimensions.
int GetFPS() const
Returns current FPS.
Window & Minimize()
Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
Window & ToggleFullscreen()
Toggle window state: fullscreen/windowed.
Window & Maximize()
Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
Window & SetMinSize(const ::Vector2 &size)
Set window minimum dimensions.
Window & SetTitle(const std::string &title)
Set title for window.
bool IsCursorOnScreen() const
Check if cursor is on the current screen.
bool IsFullscreen() const
Check if window is currently fullscreen.
static bool IsReady()
Check if window has been initialized successfully.
Window & BeginDrawing()
Setup canvas (framebuffer) to start drawing.
Window & ClearState(unsigned int flag)
Clear window configuration state flags.
Window & DrawFPS(int posX=10, int posY=10)
Draw current FPS.
Vector2 GetSize() const
Get the screen's width and height.
bool IsState(unsigned int flag) const
Check if one specific window flag is enabled.
Window & SetPosition(const ::Vector2 &position)
Set window position on screen.
Exception used for most raylib-related exceptions.
Window & SetTargetFPS(int fps)
Set target FPS (maximum)
inline ::Vector2 GetPosition() const
Get window position XY on monitor.
bool IsMinimized() const
Check if window is currently minimized.
Window & Restore()
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
Window & SetIcon(const ::Image &image)
Set icon for window.
Window and Graphics Device Functions.