raylib-cpp
C++ object-oriented wrapper library for raylib.
Window.hpp
1 #ifndef RAYLIB_CPP_WINDOW_HPP_
2 #define RAYLIB_CPP_WINDOW_HPP_
3 
4 #include <string>
5 
6 #ifdef __cplusplus
7 extern "C"{
8 #endif
9 #include "raylib.h"
10 #ifdef __cplusplus
11 }
12 #endif
13 
14 namespace raylib {
26  class Window {
27  public:
31  Window(int width = 800, int height = 450, const std::string& title = "raylib", bool lateInit = false) {
32  if (!lateInit) {
33  Init(width, height, title);
34  }
35  };
36 
37  ~Window() {
38  Close();
39  };
40 
41  void Init(int width, int height, const std::string& title) {
42  ::InitWindow(width, height, title.c_str());
43  }
44 
48  inline bool ShouldClose() {
49  return ::WindowShouldClose();
50  };
51 
55  inline void Close() {
56  ::CloseWindow();
57  };
58 
59  inline bool IsCursorOnScreen() {
60  return ::IsCursorOnScreen();
61  }
62 
66  inline static bool IsReady() {
67  return ::IsWindowReady();
68  };
69  inline bool IsMinimized() {
70  return ::IsWindowMinimized();
71  }
72  inline bool IsFocused() {
73  return ::IsWindowFocused();
74  }
75  inline bool IsResized() {
76  return ::IsWindowResized();
77  }
78  inline bool IsHidden() {
79  return ::IsWindowHidden();
80  }
81 
82  inline bool IsFullscreen() {
83  return ::IsWindowFullscreen();
84  }
87  return *this;
88  }
89  inline Window& Unhide() {
90  ::UnhideWindow();
91  return *this;
92  }
93  inline Window& Hide() {
94  ::HideWindow();
95  return *this;
96  }
97  inline Window& SetIcon(Image image) {
98  ::SetWindowIcon(image);
99  return *this;
100  }
101  inline Window& SetTitle(const std::string& title) {
102  ::SetWindowTitle(title.c_str());
103  return *this;
104  }
105  inline Window& SetPosition(int x, int y) {
106  ::SetWindowPosition(x, y);
107  return *this;
108  }
109  inline Window& SetMonitor(int monitor) {
110  ::SetWindowMonitor(monitor);
111  return *this;
112  }
113  inline Window& SetMinSize(int width, int height) {
114  ::SetWindowMinSize(width, height);
115  return *this;
116  }
117  inline Window& SetSize(int width, int height) {
118  ::SetWindowSize(width, height);
119  return *this;
120  }
121  inline void* GetHandle() {
122  return ::GetWindowHandle();
123  }
124 
125  inline Window& BeginDrawing() {
126  ::BeginDrawing();
127  return *this;
128  }
129  inline Window& EndDrawing() {
130  ::EndDrawing();
131  return *this;
132  }
133 
134  inline int GetScreenWidth() {
135  return ::GetScreenWidth();
136  }
137 
138  inline int GetScreenHeight() {
139  return ::GetScreenHeight();
140  }
141 
142  inline Vector2 GetPosition() {
143  return ::GetWindowPosition();
144  }
145 
146  inline Vector2 GetScaleDPI() {
147  return ::GetWindowScaleDPI();
148  }
149 
150  std::string GetMonitorName(int monitor) {
151  return std::string(::GetMonitorName(monitor));
152  }
153 
154  std::string GetClipboardText() {
155  return std::string(::GetClipboardText());
156  }
157 
158  inline Window& SetClipboardText(const std::string& text) {
159  ::SetClipboardText(text.c_str());
160  return *this;
161  }
162 
163  inline Window& SetTargetFPS(int fps) {
164  ::SetTargetFPS(fps);
165  return *this;
166  }
167  inline int GetFPS() {
168  return ::GetFPS();
169  }
170  inline float GetFrameTime() {
171  return ::GetFrameTime();
172  }
173  inline double GetTime() {
174  return ::GetTime();
175  }
176  };
177 }
178 
179 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Window::Unhide
Window & Unhide()
Definition: Window.hpp:89
raylib::Window::Hide
Window & Hide()
Definition: Window.hpp:93
raylib::Window::SetMonitor
Window & SetMonitor(int monitor)
Definition: Window.hpp:109
raylib::Window::IsHidden
bool IsHidden()
Definition: Window.hpp:78
raylib::Window::~Window
~Window()
Definition: Window.hpp:37
raylib::Window::Close
void Close()
Close window and unload OpenGL context.
Definition: Window.hpp:55
raylib::Image
Definition: Image.hpp:16
raylib::Window::IsCursorOnScreen
bool IsCursorOnScreen()
Definition: Window.hpp:59
raylib::Window::IsResized
bool IsResized()
Definition: Window.hpp:75
raylib::Window::GetTime
double GetTime()
Definition: Window.hpp:173
raylib::Window::GetFrameTime
float GetFrameTime()
Definition: Window.hpp:170
raylib::Window::SetMinSize
Window & SetMinSize(int width, int height)
Definition: Window.hpp:113
raylib::Window::IsMinimized
bool IsMinimized()
Definition: Window.hpp:69
raylib::Window::Init
void Init(int width, int height, const std::string &title)
Definition: Window.hpp:41
raylib::Window::SetPosition
Window & SetPosition(int x, int y)
Definition: Window.hpp:105
raylib::Window::Window
Window(int width=800, int height=450, const std::string &title="raylib", bool lateInit=false)
Initialize window and OpenGL context.
Definition: Window.hpp:31
raylib::Window::GetClipboardText
std::string GetClipboardText()
Definition: Window.hpp:154
raylib::Window::EndDrawing
Window & EndDrawing()
Definition: Window.hpp:129
raylib::Window::SetSize
Window & SetSize(int width, int height)
Definition: Window.hpp:117
raylib::Vector2
Definition: Vector2.hpp:22
raylib::Window::ToggleFullscreen
Window & ToggleFullscreen()
Definition: Window.hpp:85
raylib::Window::SetTitle
Window & SetTitle(const std::string &title)
Definition: Window.hpp:101
raylib::Window::GetPosition
Vector2 GetPosition()
Definition: Window.hpp:142
raylib::Window::GetScreenWidth
int GetScreenWidth()
Definition: Window.hpp:134
raylib::Window::IsReady
static bool IsReady()
Check if window has been initialized successfully.
Definition: Window.hpp:66
raylib::Window::BeginDrawing
Window & BeginDrawing()
Definition: Window.hpp:125
raylib::Window::SetClipboardText
Window & SetClipboardText(const std::string &text)
Definition: Window.hpp:158
raylib::Window::GetHandle
void * GetHandle()
Definition: Window.hpp:121
raylib::Window::GetMonitorName
std::string GetMonitorName(int monitor)
Definition: Window.hpp:150
raylib::Window::GetScreenHeight
int GetScreenHeight()
Definition: Window.hpp:138
raylib::Window::SetIcon
Window & SetIcon(Image image)
Definition: Window.hpp:97
raylib::Window::ShouldClose
bool ShouldClose()
Check if KEY_ESCAPE pressed or Close icon pressed.
Definition: Window.hpp:48
raylib::Window::GetScaleDPI
Vector2 GetScaleDPI()
Definition: Window.hpp:146
raylib::Window::IsFocused
bool IsFocused()
Definition: Window.hpp:72
raylib::Window::IsFullscreen
bool IsFullscreen()
Definition: Window.hpp:82
raylib::Window::SetTargetFPS
Window & SetTargetFPS(int fps)
Definition: Window.hpp:163
raylib::Window::GetFPS
int GetFPS()
Definition: Window.hpp:167
raylib::Window
Window and Graphics Device Functions.
Definition: Window.hpp:26