-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics.h
More file actions
212 lines (203 loc) · 7.27 KB
/
Copy pathGraphics.h
File metadata and controls
212 lines (203 loc) · 7.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#ifndef GRAPHICS_HEADER
#define GRAPHICS_HEADER
#include <iostream>
#include <any>
#include <array>
#ifdef GL_API_GLAD_OPENGL_3
#include <glad/glad.h>
#endif
#ifdef WINDOW_API_GLFW
#include <GLFW/glfw3.h>
#endif
#include"Camera.h"
#define arrsize(arr) sizeof(arr) / sizeof(arr[0])
class Graphics {
public:
#ifdef WINDOW_API_GLFW
GLFWwindow* window;
#endif
const char* title;
int width, height;
#ifdef WINDOW_API_GLFW
#endif
Camera camera;
std::any data;
Graphics();
#ifdef WINDOW_API_GLFW
Graphics(const char* title, int width, int height, GLFWmonitor* fullDisplay, void(*GraphicsCode)(Graphics*), std::any data);
#endif
~Graphics();
#ifdef WINDOW_API_GLFW
void Init(const char* title, int width, int height, GLFWmonitor* fullDisplay, void(*GraphicsCode)(Graphics*), std::any data);
static void StaticInit(Graphics* graphics, const char* title, int width, int height, GLFWmonitor* fullDisplay, void(*GraphicsCode)(Graphics*), std::any data, GLFWwindow** windowVar, const char** titleVar, int* widthVar, int* heightVar, std::any* dataVar);
#endif
static bool WindowLibInit();
#ifdef GL_API_GLAD_OPENGL_3
static void Draw(GLenum mode, GLsizei size, GLenum type);
static void DrawInstanced(GLenum mode, GLsizei size, GLenum type, GLsizei numInstances);
#endif
static void PollEvents();
#ifdef WINDOW_API_GLFW
void OnResizeEvent(GLFWwindowsizefun onResize);
static void OnResizeEvent(GLFWwindow* window, GLFWwindowsizefun onResize);
#endif
void SwapBuffers();
#ifdef WINDOW_API_GLFW
static void SwapBuffers(GLFWwindow* window);
#endif
#ifdef GL_API_GLAD_OPENGL_3
static void Enable(GLenum toEnable);
static void Disable(GLenum toDisable);
static void ClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
static void Clear(GLbitfield toClear);
static void Blend(GLenum toBlend, GLenum howBlend);
#endif
static void WindowHint(int toHint, int value);
#ifdef WINDOW_API_GLFW
void CreateWindow(const char* title, int width, int height, GLFWmonitor* fullDisplay);
static void CreateWindow(const char* title, int width, int height, GLFWmonitor* fullDisplay, GLFWwindow** windowVar, const char** titleVar, int* widthVar, int* heightVar);
#endif
void MakeContextCurrent();
#ifdef WINDOW_API_GLFW
static void MakeContextCurrent(GLFWwindow* window);
#endif
static void LoadGL();
#ifdef GL_API_GLAD_OPENGL_3
static void Viewport(GLsizei topLeftX, GLsizei topLeftY, GLsizei bottomRightX, GLsizei bottomRightY);
#endif
void DestroyWindow();
#ifdef WINDOW_API_GLFW
static void DestroyWindow(GLFWwindow* window);
#endif
void SetTitle(const char* title);
#ifdef WINDOW_API_GLFW
static void SetTitle(GLFWwindow* window, const char* title);
#endif
int WindowShouldClose();
#ifdef WINDOW_API_GLFW
static int WindowShouldClose(GLFWwindow* window);
#endif
static void Terminate();
template <typename type>
type GetData();
template <typename type>
static type GetData(std::any data);
template <typename type>
void SetWindowPointer(type* ptr);
#ifdef WINDOW_API_GLFW
template <typename type>
static void SetWindowPointer(GLFWwindow* window, type* ptr);
#endif
template <typename type>
type* GetWindowPointer();
#ifdef WINDOW_API_GLFW
template <typename type>
static type* GetWindowPointer(GLFWwindow* window);
#endif
void SetWindowSize(int width, int height);
#ifdef WINDOW_API_GLFW
static void SetWindowSize(GLFWwindow* window, int width, int height);
#endif
std::array<float, 2> GetContentScale(float xScale, float yScale);
#ifdef WINDOW_API_GLFW
static std::array<float, 2> GetContentScale(GLFWwindow* window, float xScale, float yScale);
#endif
void SetWindowSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight);
#ifdef WINDOW_API_GLFW
static void SetWindowSizeLimits(GLFWwindow* window, int minWidth, int minHeight, int maxWidth, int maxHeight);
#endif
void SetWindowPos(int xPos, int yPos);
#ifdef WINDOW_API_GLFW
static void SetWindowPos(GLFWwindow* window, int xPos, int yPos);
#endif
void OnWindowMoveEvent(GLFWwindowposfun onMove);
#ifdef WINDOW_API_GLFW
static void OnWindowMoveEvent(GLFWwindow* window, GLFWwindowposfun onMove);
#endif
void SetWindowIcon(int size, GLFWimage images[]);
#ifdef WINDOW_API_GLFW
static void SetWindowIcon(GLFWwindow* window, int size, GLFWimage images[]);
#endif
GLFWmonitor* GetWindowMonitor();
#ifdef WINDOW_API_GLFW
static GLFWmonitor* GetWindowMonitor(GLFWwindow* windoww);
#endif
void SetWindowMonitor(GLFWmonitor* monitor, int xPos, int yPos, int width, int height, int refreshRate);
#ifdef WINDOW_API_GLFW
static void GetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xPos, int yPos, int width, int height, int refreshRate);
#endif
void IconifyWindow();
#ifdef WINDOW_API_GLFW
static void IconifyWindow(GLFWwindow* window);
#endif
void RestoreWindow();
#ifdef WINDOW_API_GLFW
static void RestoreWindow(GLFWwindow* window);
#endif
void OnSetWindowIconificationEvent(GLFWwindowiconifyfun onIconification);
#ifdef WINDOW_API_GLFW
static void OnSetWindowIconificationEvent(GLFWwindow* window, GLFWwindowiconifyfun onIconification);
#endif
void MaximizeWindow();
#ifdef WINDOW_API_GLFW
static void MaximizeWindow(GLFWwindow* window);
#endif
void OnSetWindowwMaxificationEvent(GLFWwindowmaximizefun onMaxification);
#ifdef WINDOW_API_GLFW
static void OnSetWindowMaxificationEvent(GLFWwindow* window, GLFWwindowmaximizefun onMaxification);
#endif
void HideWindow();
#ifdef WINDOW_API_GLFW
static void HideWindow(GLFWwindow* window);
#endif
void ShowWindow();
#ifdef WINDOW_API_GLFW
static void ShowWindow(GLFWwindow* window);
#endif
int GetWindowAttrib(int attrib);
#ifdef WINDOW_API_GLFW
static int GetWindowAttrib(GLFWwindow* window, int attrib);
#endif
void FocusWindow();
#ifdef WINDOW_API_GLFW
static void FocusWindow(GLFWwindow* window);
#endif
void OnSetWindowFocusEvent(GLFWwindowfocusfun onFocus);
#ifdef WINDOW_API_GLFW
static void OnSetWindowFocusEvent(GLFWwindow* window, GLFWwindowfocusfun onFocus);
#endif
void SetWindowAttrib(int attrib, int value);
#ifdef WINDOW_API_GLFW
static void SetWindowAttrib(GLFWwindow* window, int attrib, int value);
#endif
void RequestWindowAttention();
#ifdef WINDOW_API_GLFW
static void RequestWindowAttention(GLFWwindow* window);
#endif
static void SwapInterval(int interval);
void SetWindowOpacity(float opacity);
#ifdef WINDOW_API_GLFW
static void SetWindowOpacity(GLFWwindow* window, float opacity);
#endif
void OnWindowCloseEvent(GLFWwindowclosefun onClose);
#ifdef WINDOW_API_GLFW
static void OnWindowCloseEvent(GLFWwindow* window, GLFWwindowclosefun onClose);
#endif
void OnSetWindowRefreshEvent(GLFWwindowrefreshfun onRefresh);
#ifdef WINDOW_API_GLFW
void OnSetWindowRefreshEvent(GLFWwindow* window, GLFWwindowrefreshfun onRefresh);
#endif
static GLFWmonitor** GetMonitors(int* count);
static GLFWmonitor* GetPrimaryMonitor();
static const GLFWvidmode* GetVideoMode(GLFWmonitor* monitor);
static const GLFWvidmode* GetVideoModes(GLFWmonitor* monitor, int* count);
#ifdef WINDOW_API_GLFW
template <typename type>
static type* GetPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum pixelsType);
template <typename type>
static type* GetPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum pixelsType, GLsizei size);
static void ActiveTexture(GLenum texture);
#endif
};
#include "Graphics.tpp"
#endif