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 {
18  class Window {
19  public:
23  Window(int width = 800, int height = 450, const std::string& title = "raylib", bool lateInit = false) {
24  if (!lateInit) {
25  Init(width, height, title);
26  }
27  };
28 
29  ~Window() {
30  Close();
31  };
32 
33  void Init(int width, int height, const std::string& title) {
34  ::InitWindow(width, height, title.c_str());
35  }
36 
40  inline bool ShouldClose() {
41  return ::WindowShouldClose();
42  };
43 
47  inline void Close() {
48  ::CloseWindow();
49  };
50 
54  inline static bool IsReady() {
55  return ::IsWindowReady();
56  };
57  inline bool IsMinimized() {
58  return ::IsWindowMinimized();
59  }
60  inline bool IsResized() {
61  return ::IsWindowResized();
62  }
63  inline bool IsHidden() {
64  return ::IsWindowHidden();
65  }
66 
67  inline bool IsFullscreen() {
68  return ::IsWindowFullscreen();
69  }
72  return *this;
73  }
74  inline Window& Unhide() {
75  ::UnhideWindow();
76  return *this;
77  }
78  inline Window& Hide() {
79  ::HideWindow();
80  return *this;
81  }
82  inline Window& SetIcon(Image image) {
83  ::SetWindowIcon(image);
84  return *this;
85  }
86  inline Window& SetTitle(const std::string& title) {
87  ::SetWindowTitle(title.c_str());
88  return *this;
89  }
90  inline Window& SetPosition(int x, int y) {
91  ::SetWindowPosition(x, y);
92  return *this;
93  }
94  inline Window& SetMonitor(int monitor) {
95  ::SetWindowMonitor(monitor);
96  return *this;
97  }
98  inline Window& SetMinSize(int width, int height) {
99  ::SetWindowMinSize(width, height);
100  return *this;
101  }
102  inline Window& SetSize(int width, int height) {
103  ::SetWindowSize(width, height);
104  return *this;
105  }
106  inline void* GetHandle() {
107  return ::GetWindowHandle();
108  }
109 
110  inline Window& BeginDrawing() {
111  ::BeginDrawing();
112  return *this;
113  }
114  inline Window& EndDrawing() {
115  ::EndDrawing();
116  return *this;
117  }
118 
119  inline int GetScreenWidth() {
120  return ::GetScreenWidth();
121  }
122 
123  inline int GetScreenHeight() {
124  return ::GetScreenHeight();
125  }
126 
128  return ::GetWindowPosition();
129  }
130 
131  std::string GetMonitorName(int monitor) {
132  return std::string(::GetMonitorName(monitor));
133  }
134 
135  std::string GetClipboardText() {
136  return std::string(::GetClipboardText());
137  }
138 
139  inline Window& SetClipboardText(const std::string& text) {
140  ::SetClipboardText(text.c_str());
141  return *this;
142  }
143 
144  inline Window& SetTargetFPS(int fps) {
145  ::SetTargetFPS(fps);
146  return *this;
147  }
148  inline int GetFPS() {
149  return ::GetFPS();
150  }
151  inline float GetFrameTime() {
152  return ::GetFrameTime();
153  }
154  inline double GetTime() {
155  return ::GetTime();
156  }
157  };
158 }
159 
160 #endif
Window & Hide()
Definition: Window.hpp:78
Vector2 GetWindowPosition()
Definition: Window.hpp:127
void Close()
Close window and unload OpenGL context.
Definition: Window.hpp:47
Window & SetMonitor(int monitor)
Definition: Window.hpp:94
bool IsHidden()
Definition: Window.hpp:63
Window & SetMinSize(int width, int height)
Definition: Window.hpp:98
float GetFrameTime()
Definition: Window.hpp:151
bool IsResized()
Definition: Window.hpp:60
double GetTime()
Definition: Window.hpp:154
bool IsMinimized()
Definition: Window.hpp:57
Window(int width=800, int height=450, const std::string &title="raylib", bool lateInit=false)
Initialize window and OpenGL context.
Definition: Window.hpp:23
Window & EndDrawing()
Definition: Window.hpp:114
void Init(int width, int height, const std::string &title)
Definition: Window.hpp:33
Window & SetPosition(int x, int y)
Definition: Window.hpp:90
Window & ToggleFullscreen()
Definition: Window.hpp:70
Window & SetTitle(const std::string &title)
Definition: Window.hpp:86
std::string GetClipboardText()
Definition: Window.hpp:135
Window & SetSize(int width, int height)
Definition: Window.hpp:102
static bool IsReady()
Check if window has been initialized successfully.
Definition: Window.hpp:54
int GetScreenWidth()
Definition: Window.hpp:119
Window and Graphics Device Functions.
Definition: Window.hpp:18
void * GetHandle()
Definition: Window.hpp:106
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
Window & BeginDrawing()
Definition: Window.hpp:110
Window & SetClipboardText(const std::string &text)
Definition: Window.hpp:139
bool IsFullscreen()
Definition: Window.hpp:67
std::string GetMonitorName(int monitor)
Definition: Window.hpp:131
int GetScreenHeight()
Definition: Window.hpp:123
Window & SetTargetFPS(int fps)
Definition: Window.hpp:144
Window & SetIcon(Image image)
Definition: Window.hpp:82
int GetFPS()
Definition: Window.hpp:148
bool ShouldClose()
Check if KEY_ESCAPE pressed or Close icon pressed.
Definition: Window.hpp:40
Window & Unhide()
Definition: Window.hpp:74