Covellite++  Version: 2.3.0 Revision: ??? Platform: x64 Build: 23:13 04.01.2025
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
GLExt.hpp
1
2#pragma once
3
4#define GL_CLAMP_TO_EDGE 0x812F
5#define GL_FRAGMENT_SHADER 0x8B30
6#define GL_VERTEX_SHADER 0x8B31
7#define GL_COMPILE_STATUS 0x8B81
8#define GL_LINK_STATUS 0x8B82
9#define GL_INFO_LOG_LENGTH 0x8B84
10#define GL_CURRENT_PROGRAM 0x8B8D
11#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
12#define GL_NUM_EXTENSIONS 0x821D
13#define GL_INVALID_INDEX 0xFFFFFFFFu
14#define GL_FLOAT_VEC2 0x8B50
15#define GL_FLOAT_VEC3 0x8B51
16#define GL_FLOAT_VEC4 0x8B52
17#define GL_INT_VEC2 0x8B53
18#define GL_INT_VEC3 0x8B54
19#define GL_INT_VEC4 0x8B55
20
21/* TextureUnit */
22#define GL_TEXTURE0 0x84C0
23#define GL_TEXTURE1 0x84C1
24#define GL_TEXTURE2 0x84C2
25#define GL_TEXTURE3 0x84C3
26#define GL_TEXTURE4 0x84C4
27#define GL_TEXTURE5 0x84C5
28#define GL_TEXTURE6 0x84C6
29#define GL_TEXTURE7 0x84C7
30#define GL_TEXTURE8 0x84C8
31#define GL_TEXTURE9 0x84C9
32#define GL_TEXTURE10 0x84CA
33#define GL_TEXTURE11 0x84CB
34#define GL_TEXTURE12 0x84CC
35#define GL_TEXTURE13 0x84CD
36#define GL_TEXTURE14 0x84CE
37#define GL_TEXTURE15 0x84CF
38#define GL_TEXTURE16 0x84D0
39#define GL_TEXTURE17 0x84D1
40#define GL_TEXTURE18 0x84D2
41#define GL_TEXTURE19 0x84D3
42#define GL_TEXTURE20 0x84D4
43#define GL_TEXTURE21 0x84D5
44#define GL_TEXTURE22 0x84D6
45#define GL_TEXTURE23 0x84D7
46#define GL_TEXTURE24 0x84D8
47#define GL_TEXTURE25 0x84D9
48#define GL_TEXTURE26 0x84DA
49#define GL_TEXTURE27 0x84DB
50#define GL_TEXTURE28 0x84DC
51#define GL_TEXTURE29 0x84DD
52#define GL_TEXTURE30 0x84DE
53#define GL_TEXTURE31 0x84DF
54#define GL_ACTIVE_TEXTURE 0x84E0
55
56/* Buffer Objects */
57#define GL_ARRAY_BUFFER 0x8892
58#define GL_ELEMENT_ARRAY_BUFFER 0x8893
59#define GL_ARRAY_BUFFER_BINDING 0x8894
60#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
61#define GL_UNIFORM_BUFFER 0x8A11
62#define GL_ACTIVE_ATTRIBUTES 0x8B89
63
64#define GL_STREAM_DRAW 0x88E0
65#define GL_STATIC_DRAW 0x88E4
66#define GL_DYNAMIC_DRAW 0x88E8
67
68#define GL_FRAMEBUFFER 0x8D40
69#define GL_RENDERBUFFER 0x8D41
70#define GL_FRAMEBUFFER_BINDING 0x8CA6
71#define GL_DRAW_FRAMEBUFFER 0x8CA9
72#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
73#define GL_COLOR_ATTACHMENT0 0x8CE0
74#define GL_DEPTH_ATTACHMENT 0x8D00
75#define GL_STENCIL_ATTACHMENT 0x8D20
76#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
77#define GL_DEPTH_STENCIL 0x84F9
78#define GL_UNSIGNED_INT_24_8 0x84FA
79#define GL_DEPTH24_STENCIL8 0x88F0
80#define GL_DEPTH_COMPONENT 0x1902
81#define GL_DEPTH_COMPONENT16 0x81A5
82#define GL_DEPTH_COMPONENT24 0x81A6
83#define GL_DEPTH_COMPONENT32F 0x8CAC
84#define GL_TEXTURE_COMPARE_MODE 0x884C
85#define GL_TEXTURE_COMPARE_FUNC 0x884D
86#define GL_COMPARE_REF_TO_TEXTURE 0x884E
87
88#define GL_RGBA32F 0x8814
89#define GL_RGBA16F 0x881A
90#define GL_HALF_FLOAT 0x140B
91
92using GLchar = char;
93typedef signed long int khronos_ssize_t;
94typedef khronos_ssize_t GLsizeiptr;
95typedef signed long int khronos_intptr_t;
96typedef khronos_intptr_t GLintptr;
97
98inline void glOrtho(GLfloat _Left, GLfloat _Right, GLfloat _Bottom,
99 GLfloat _Top, GLfloat _zNear, GLfloat _zFar)
100{
101 glOrtho((GLdouble)_Left, (GLdouble)_Right, (GLdouble)_Bottom, (GLdouble)_Top,
102 (GLdouble)_zNear, (GLdouble)_zFar);
103}
104
105template<class TCall>
106inline TCall GetProcAddress(LPSTR _Name)
107{
108 auto Result = wglGetProcAddress(_Name);
109 if (Result == nullptr) throw ::std::exception{ _Name };
110
111 return reinterpret_cast<TCall>(Result);
112}
113
114inline GLuint glCreateShader(GLenum shaderType)
115{
116 using Call_t = GLuint(*)(GLenum);
117 static auto glCall = GetProcAddress<Call_t>("glCreateShader");
118
119 return glCall(shaderType);
120}
121
122inline void glShaderSource(GLuint shader, GLsizei count, const GLchar ** string,
123 const GLint * length)
124{
125 using Call_t = void(*)(GLuint, GLsizei, const GLchar **, const GLint *);
126 static auto glCall = GetProcAddress<Call_t>("glShaderSource");
127
128 glCall(shader, count, string, length);
129}
130
131inline void glCompileShader(GLuint shader)
132{
133 using Call_t = void(*)(GLuint);
134 static auto glCall = GetProcAddress<Call_t>("glCompileShader");
135
136 glCall(shader);
137}
138
139inline void glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
140{
141 using Call_t = void(*)(GLuint, GLenum, GLint *);
142 static auto glCall = GetProcAddress<Call_t>("glGetShaderiv");
143
144 glCall(shader, pname, params);
145}
146
147inline void glGetShaderInfoLog(GLuint shader, GLsizei maxLength,
148 GLsizei *length, GLchar *infoLog)
149{
150 using Call_t = void(*)(GLuint, GLsizei, GLsizei *, GLchar *);
151 static auto glCall = GetProcAddress<Call_t>("glGetShaderInfoLog");
152
153 glCall(shader, maxLength, length, infoLog);
154}
155
156inline void glDeleteShader(GLuint shader)
157{
158 using Call_t = void(*)(GLuint);
159 static auto glCall = GetProcAddress<Call_t>("glDeleteShader");
160
161 glCall(shader);
162}
163
164inline GLuint glCreateProgram(void)
165{
166 using Call_t = GLuint(*)(void);
167 static auto glCall = GetProcAddress<Call_t>("glCreateProgram");
168
169 return glCall();
170}
171
172inline void glDeleteProgram(GLuint program)
173{
174 using Call_t = void(*)(GLuint);
175 static auto glCall = GetProcAddress<Call_t>("glDeleteProgram");
176
177 glCall(program);
178}
179
180inline void glAttachShader(GLuint program, GLuint shader)
181{
182 using Call_t = void(*)(GLuint, GLuint);
183 static auto glCall = GetProcAddress<Call_t>("glAttachShader");
184
185 glCall(program, shader);
186}
187
188inline void glLinkProgram(GLuint program)
189{
190 using Call_t = void(*)(GLuint);
191 static auto glCall = GetProcAddress<Call_t>("glLinkProgram");
192
193 glCall(program);
194}
195
196inline void glGetProgramiv(GLuint program, GLenum pname, GLint *params)
197{
198 using Call_t = void(*)(GLuint, GLenum, GLint *);
199 static auto glCall = GetProcAddress<Call_t>("glGetProgramiv");
200
201 glCall(program, pname, params);
202}
203
204inline void glGetProgramInfoLog(GLuint program, GLsizei maxLength,
205 GLsizei *length, GLchar *infoLog)
206{
207 using Call_t = void(*)(GLuint, GLsizei, GLsizei *, GLchar *);
208 static auto glCall = GetProcAddress<Call_t>("glGetProgramInfoLog");
209
210 glCall(program, maxLength, length, infoLog);
211}
212
213inline void glUseProgram(GLuint program)
214{
215 using Call_t = void(*)(GLuint);
216 static auto glCall = GetProcAddress<Call_t>("glUseProgram");
217
218 glCall(program);
219}
220
221inline void glActiveTexture(GLenum texture)
222{
223 using Call_t = void(*)(GLenum);
224 static auto glCall = GetProcAddress<Call_t>("glActiveTexture");
225
226 glCall(texture);
227}
228
229inline void glBindBuffer(GLenum target, GLuint buffer)
230{
231 using Call_t = void(*)(GLenum, GLuint);
232 static auto glCall = GetProcAddress<Call_t>("glBindBuffer");
233
234 glCall(target, buffer);
235}
236
237inline void glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
238{
239 using Call_t = void(*)(GLenum, GLuint, GLuint);
240 static auto glCall = GetProcAddress<Call_t>("glBindBufferBase");
241
242 glCall(target, index, buffer);
243}
244
245inline void glGenBuffers(GLsizei n, GLuint * buffers)
246{
247 using Call_t = void(*)(GLsizei, GLuint *);
248 static auto glCall = GetProcAddress<Call_t>("glGenBuffers");
249
250 glCall(n, buffers);
251}
252
253inline void glDeleteBuffers(GLsizei n, const GLuint * buffers)
254{
255 using Call_t = void(*)(GLsizei, const GLuint *);
256 static auto glCall = GetProcAddress<Call_t>("glDeleteBuffers");
257
258 glCall(n, buffers);
259}
260
261inline void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
262 GLenum usage)
263{
264 using Call_t = void(*)(GLenum, GLsizeiptr, const GLvoid *, GLenum);
265 static auto glCall = GetProcAddress<Call_t>("glBufferData");
266
267 glCall(target, size, data, usage);
268}
269
270inline void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
271 const GLvoid* data)
272{
273 using Call_t = void(*)(GLenum, GLintptr, GLsizeiptr, const GLvoid *);
274 static auto glCall = GetProcAddress<Call_t>("glBufferSubData");
275
276 glCall(target, offset, size, data);
277}
278
279inline GLint glGetAttribLocation(GLuint program, const GLchar *name)
280{
281 using Call_t = GLint(*)(GLuint, const GLchar *);
282 static auto glCall = GetProcAddress<Call_t>("glGetAttribLocation");
283
284 return glCall(program, name);
285}
286
287inline void glVertexAttribPointer(GLuint index, GLint size, GLenum type,
288 GLboolean normalized, GLsizei stride, const GLvoid * pointer)
289{
290 using Call_t = void(*)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
291 static auto glCall = GetProcAddress<Call_t>("glVertexAttribPointer");
292
293 glCall(index, size, type, normalized, stride, pointer);
294}
295
296inline void glEnableVertexAttribArray(GLuint index)
297{
298 using Call_t = void(*)(GLuint);
299 static auto glCall = GetProcAddress<Call_t>("glEnableVertexAttribArray");
300
301 glCall(index);
302}
303
304inline GLint glGetUniformLocation(GLuint program, const GLchar *name)
305{
306 using Call_t = GLint(*)(GLuint, const GLchar *);
307 static auto glCall = GetProcAddress<Call_t>("glGetUniformLocation");
308
309 return glCall(program, name);
310}
311
312inline void glUniform1i(GLint location, GLint v0)
313{
314 using Call_t = void(*)(GLint, GLint);
315 static auto glCall = GetProcAddress<Call_t>("glUniform1i");
316
317 glCall(location, v0);
318}
319
320inline void glUniform1f(GLint location, GLfloat x)
321{
322 using Call_t = void(*)(GLint, GLfloat);
323 static auto glCall = GetProcAddress<Call_t>("glUniform1f");
324
325 glCall(location, x);
326}
327
328inline void glUniform4fv(GLint location, GLsizei count, const GLfloat *value)
329{
330 using Call_t = void(*)(GLint, GLsizei, const GLfloat *);
331 static auto glCall = GetProcAddress<Call_t>("glUniform4fv");
332
333 glCall(location, count, value);
334}
335
336inline void glUniformMatrix4fv(GLint location, GLsizei count,
337 GLboolean transpose, const GLfloat *value)
338{
339 using Call_t = void(*)(GLint, GLsizei, GLboolean, const GLfloat *);
340 static auto glCall = GetProcAddress<Call_t>("glUniformMatrix4fv");
341
342 glCall(location, count, transpose, value);
343}
344
345inline GLuint glGetUniformBlockIndex(GLuint program, const GLchar *uniformBlockName)
346{
347 using Call_t = GLuint(*)(GLuint, const GLchar *);
348 static auto glCall = GetProcAddress<Call_t>("glGetUniformBlockIndex");
349
350 return glCall(program, uniformBlockName);
351}
352
353inline void glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex,
354 GLuint uniformBlockBinding)
355{
356 using Call_t = void(*)(GLuint, GLuint, GLuint);
357 static auto glCall = GetProcAddress<Call_t>("glUniformBlockBinding");
358
359 glCall(program, uniformBlockIndex, uniformBlockBinding);
360}
361
362inline const GLubyte * glGetStringi(GLenum name, GLuint index)
363{
364 using Call_t = const GLubyte *(*)(GLenum, GLuint);
365 static auto glCall = GetProcAddress<Call_t>("glGetStringi");
366
367 return glCall(name, index);
368}
369
370inline void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
371 GLsizei instancecount)
372{
373 using Call_t = void(*)(GLenum, GLint, GLsizei, GLsizei);
374 static auto glCall = GetProcAddress<Call_t>("glDrawArraysInstanced");
375
376 glCall(mode, first, count, instancecount);
377}
378
379inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
380 const void * indices, GLsizei instancecount)
381{
382 using Call_t = void(*)(GLenum, GLsizei, GLenum, const void *, GLsizei);
383 static auto glCall = GetProcAddress<Call_t>("glDrawElementsInstanced");
384
385 glCall(mode, count, type, indices, instancecount);
386}
387
388inline void glVertexAttribDivisor(GLuint index, GLuint divisor)
389{
390 using Call_t = void(*)(GLuint, GLuint);
391 static auto glCall = GetProcAddress<Call_t>("glVertexAttribDivisor");
392
393 glCall(index, divisor);
394}
395
396inline void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize,
397 GLsizei *length, GLint *size, GLenum *type, GLchar *name)
398{
399 using Call_t = void(*)(GLuint, GLuint, GLsizei, GLsizei *, GLint *,
400 GLenum *, GLchar *);
401 static auto glCall = GetProcAddress<Call_t>("glGetActiveAttrib");
402
403 glCall(program, index, bufSize, length, size, type, name);
404}
405
406inline void glGenFramebuffers(GLsizei n, GLuint *ids)
407{
408 using Call_t = void(*)(GLsizei, GLuint *);
409 static auto glCall = GetProcAddress<Call_t>("glGenFramebuffers");
410
411 glCall(n, ids);
412}
413
414inline void glBindFramebuffer(GLenum target, GLuint framebuffer)
415{
416 using Call_t = void(*)(GLenum, GLuint);
417 static auto glCall = GetProcAddress<Call_t>("glBindFramebuffer");
418
419 glCall(target, framebuffer);
420}
421
422inline GLenum glCheckFramebufferStatus(GLenum target)
423{
424 using Call_t = GLenum(*)(GLenum);
425 static auto glCall = GetProcAddress<Call_t>("glCheckFramebufferStatus");
426
427 return glCall(target);
428}
429
430inline void glDeleteFramebuffers(GLsizei n, const GLuint * framebuffers)
431{
432 using Call_t = void(*)(GLsizei, const GLuint *);
433 static auto glCall = GetProcAddress<Call_t>("glDeleteFramebuffers");
434
435 glCall(n, framebuffers);
436}
437
438inline void glFramebufferTexture2D(GLenum target, GLenum attachment,
439 GLenum textarget, GLuint texture, GLint level)
440{
441 using Call_t = void(*)(GLenum, GLenum, GLenum, GLuint, GLint);
442 static auto glCall = GetProcAddress<Call_t>("glFramebufferTexture2D");
443
444 glCall(target, attachment, textarget, texture, level);
445}
446
447inline void glDepthRangef(GLfloat n, GLfloat f)
448{
449 using Call_t = void(*)(GLfloat, GLfloat);
450 static auto glCall = GetProcAddress<Call_t>("glDepthRangef");
451
452 glCall(n, f);
453}
454
455inline void glDrawBuffers(GLsizei n, const GLenum *bufs)
456{
457 using Call_t = void(*)(GLsizei, const GLenum *);
458 static auto glCall = GetProcAddress<Call_t>("glDrawBuffers");
459
460 glCall(n, bufs);
461}
462
463inline void glGenerateMipmap(GLenum target)
464{
465 using Call_t = void(*)(GLenum);
466 static auto glCall = GetProcAddress<Call_t>("glGenerateMipmap");
467
468 glCall(target);
469}
470
471#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
472#define GL_DEBUG_OUTPUT 0x92E0
473
474#define GL_DEBUG_TYPE_ERROR 0x824C
475#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
476#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
477#define GL_DEBUG_TYPE_PORTABILITY 0x824F
478#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
479#define GL_DEBUG_TYPE_OTHER 0x8251
480#define GL_DEBUG_TYPE_MARKER 0x8268
481#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
482#define GL_DEBUG_TYPE_POP_GROUP 0x826A
483
484#define GL_DEBUG_SEVERITY_HIGH 0x9146
485#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
486#define GL_DEBUG_SEVERITY_LOW 0x9148
487#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
488
489typedef void (APIENTRY * DEBUGPROC)(GLenum source, GLenum type, GLuint id,
490 GLenum severity, GLsizei length, const GLchar *message, const void *userParam);
491
492inline void glDebugMessageCallback(DEBUGPROC callback, const void * userParam)
493{
494 using Call_t = void(*)(DEBUGPROC, const void *);
495 static auto glCall = GetProcAddress<Call_t>("glDebugMessageCallback");
496
497 glCall(callback, userParam);
498}
499
500inline void glDebugMessageControl(GLenum source, GLenum type, GLenum severity,
501 GLsizei count, const GLuint *ids, GLboolean enabled)
502{
503 using Call_t = void(*)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean);
504 static auto glCall = GetProcAddress<Call_t>("glDebugMessageControl");
505
506 glCall(source, type, severity, count, ids, enabled);
507}