Covellite++  Version: 2.3.1 Revision: ??? Platform: x64 Build: 21:47 08.04.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#define GL_TEXTURE_2D_ARRAY 0x8C1A
56
57/* Buffer Objects */
58#define GL_ARRAY_BUFFER 0x8892
59#define GL_ELEMENT_ARRAY_BUFFER 0x8893
60#define GL_ARRAY_BUFFER_BINDING 0x8894
61#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
62#define GL_UNIFORM_BUFFER 0x8A11
63#define GL_ACTIVE_ATTRIBUTES 0x8B89
64
65#define GL_STREAM_DRAW 0x88E0
66#define GL_STATIC_DRAW 0x88E4
67#define GL_DYNAMIC_DRAW 0x88E8
68
69#define GL_FRAMEBUFFER 0x8D40
70#define GL_RENDERBUFFER 0x8D41
71#define GL_FRAMEBUFFER_BINDING 0x8CA6
72#define GL_DRAW_FRAMEBUFFER 0x8CA9
73#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
74#define GL_COLOR_ATTACHMENT0 0x8CE0
75#define GL_DEPTH_ATTACHMENT 0x8D00
76#define GL_STENCIL_ATTACHMENT 0x8D20
77#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
78#define GL_DEPTH_STENCIL 0x84F9
79#define GL_UNSIGNED_INT_24_8 0x84FA
80#define GL_DEPTH24_STENCIL8 0x88F0
81#define GL_DEPTH_COMPONENT 0x1902
82#define GL_DEPTH_COMPONENT16 0x81A5
83#define GL_DEPTH_COMPONENT24 0x81A6
84#define GL_DEPTH_COMPONENT32F 0x8CAC
85#define GL_TEXTURE_COMPARE_MODE 0x884C
86#define GL_TEXTURE_COMPARE_FUNC 0x884D
87#define GL_COMPARE_REF_TO_TEXTURE 0x884E
88
89#define GL_RGBA32F 0x8814
90#define GL_RGBA16F 0x881A
91#define GL_HALF_FLOAT 0x140B
92
93using GLchar = char;
94typedef signed long int khronos_ssize_t;
95typedef khronos_ssize_t GLsizeiptr;
96typedef signed long int khronos_intptr_t;
97typedef khronos_intptr_t GLintptr;
98
99inline void glOrtho(GLfloat _Left, GLfloat _Right, GLfloat _Bottom,
100 GLfloat _Top, GLfloat _zNear, GLfloat _zFar)
101{
102 glOrtho((GLdouble)_Left, (GLdouble)_Right, (GLdouble)_Bottom, (GLdouble)_Top,
103 (GLdouble)_zNear, (GLdouble)_zFar);
104}
105
106template<class TCall>
107inline TCall GetProcAddress(LPSTR _Name)
108{
109 auto Result = wglGetProcAddress(_Name);
110 if (Result == nullptr) throw ::std::exception{ _Name };
111
112 return reinterpret_cast<TCall>(Result);
113}
114
115inline GLuint glCreateShader(GLenum shaderType)
116{
117 using Call_t = GLuint(*)(GLenum);
118 static auto glCall = GetProcAddress<Call_t>("glCreateShader");
119
120 return glCall(shaderType);
121}
122
123inline void glShaderSource(GLuint shader, GLsizei count, const GLchar ** string,
124 const GLint * length)
125{
126 using Call_t = void(*)(GLuint, GLsizei, const GLchar **, const GLint *);
127 static auto glCall = GetProcAddress<Call_t>("glShaderSource");
128
129 glCall(shader, count, string, length);
130}
131
132inline void glCompileShader(GLuint shader)
133{
134 using Call_t = void(*)(GLuint);
135 static auto glCall = GetProcAddress<Call_t>("glCompileShader");
136
137 glCall(shader);
138}
139
140inline void glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
141{
142 using Call_t = void(*)(GLuint, GLenum, GLint *);
143 static auto glCall = GetProcAddress<Call_t>("glGetShaderiv");
144
145 glCall(shader, pname, params);
146}
147
148inline void glGetShaderInfoLog(GLuint shader, GLsizei maxLength,
149 GLsizei *length, GLchar *infoLog)
150{
151 using Call_t = void(*)(GLuint, GLsizei, GLsizei *, GLchar *);
152 static auto glCall = GetProcAddress<Call_t>("glGetShaderInfoLog");
153
154 glCall(shader, maxLength, length, infoLog);
155}
156
157inline void glDeleteShader(GLuint shader)
158{
159 using Call_t = void(*)(GLuint);
160 static auto glCall = GetProcAddress<Call_t>("glDeleteShader");
161
162 glCall(shader);
163}
164
165inline GLuint glCreateProgram(void)
166{
167 using Call_t = GLuint(*)(void);
168 static auto glCall = GetProcAddress<Call_t>("glCreateProgram");
169
170 return glCall();
171}
172
173inline void glDeleteProgram(GLuint program)
174{
175 using Call_t = void(*)(GLuint);
176 static auto glCall = GetProcAddress<Call_t>("glDeleteProgram");
177
178 glCall(program);
179}
180
181inline void glAttachShader(GLuint program, GLuint shader)
182{
183 using Call_t = void(*)(GLuint, GLuint);
184 static auto glCall = GetProcAddress<Call_t>("glAttachShader");
185
186 glCall(program, shader);
187}
188
189inline void glLinkProgram(GLuint program)
190{
191 using Call_t = void(*)(GLuint);
192 static auto glCall = GetProcAddress<Call_t>("glLinkProgram");
193
194 glCall(program);
195}
196
197inline void glGetProgramiv(GLuint program, GLenum pname, GLint *params)
198{
199 using Call_t = void(*)(GLuint, GLenum, GLint *);
200 static auto glCall = GetProcAddress<Call_t>("glGetProgramiv");
201
202 glCall(program, pname, params);
203}
204
205inline void glGetProgramInfoLog(GLuint program, GLsizei maxLength,
206 GLsizei *length, GLchar *infoLog)
207{
208 using Call_t = void(*)(GLuint, GLsizei, GLsizei *, GLchar *);
209 static auto glCall = GetProcAddress<Call_t>("glGetProgramInfoLog");
210
211 glCall(program, maxLength, length, infoLog);
212}
213
214inline void glUseProgram(GLuint program)
215{
216 using Call_t = void(*)(GLuint);
217 static auto glCall = GetProcAddress<Call_t>("glUseProgram");
218
219 glCall(program);
220}
221
222inline void glActiveTexture(GLenum texture)
223{
224 using Call_t = void(*)(GLenum);
225 static auto glCall = GetProcAddress<Call_t>("glActiveTexture");
226
227 glCall(texture);
228}
229
230inline void glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat,
231 GLsizei width, GLsizei height, GLsizei depth)
232{
233 using Call_t = void(*)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei);
234 static auto glCall = GetProcAddress<Call_t>("glTexStorage3D");
235
236 glCall(target, levels, internalformat, width, height, depth);
237}
238
239inline void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
240 GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format,
241 GLenum type, const void * pixels)
242{
243 using Call_t = void(*)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void *);
244 static auto glCall = GetProcAddress<Call_t>("glTexSubImage3D");
245
246 glCall(target, level, xoffset, yoffset, zoffset, width, height, depth, format,
247 type, pixels);
248}
249
250inline void glBindBuffer(GLenum target, GLuint buffer)
251{
252 using Call_t = void(*)(GLenum, GLuint);
253 static auto glCall = GetProcAddress<Call_t>("glBindBuffer");
254
255 glCall(target, buffer);
256}
257
258inline void glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
259{
260 using Call_t = void(*)(GLenum, GLuint, GLuint);
261 static auto glCall = GetProcAddress<Call_t>("glBindBufferBase");
262
263 glCall(target, index, buffer);
264}
265
266inline void glGenBuffers(GLsizei n, GLuint * buffers)
267{
268 using Call_t = void(*)(GLsizei, GLuint *);
269 static auto glCall = GetProcAddress<Call_t>("glGenBuffers");
270
271 glCall(n, buffers);
272}
273
274inline void glDeleteBuffers(GLsizei n, const GLuint * buffers)
275{
276 using Call_t = void(*)(GLsizei, const GLuint *);
277 static auto glCall = GetProcAddress<Call_t>("glDeleteBuffers");
278
279 glCall(n, buffers);
280}
281
282inline void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
283 GLenum usage)
284{
285 using Call_t = void(*)(GLenum, GLsizeiptr, const GLvoid *, GLenum);
286 static auto glCall = GetProcAddress<Call_t>("glBufferData");
287
288 glCall(target, size, data, usage);
289}
290
291inline void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
292 const GLvoid* data)
293{
294 using Call_t = void(*)(GLenum, GLintptr, GLsizeiptr, const GLvoid *);
295 static auto glCall = GetProcAddress<Call_t>("glBufferSubData");
296
297 glCall(target, offset, size, data);
298}
299
300inline GLint glGetAttribLocation(GLuint program, const GLchar *name)
301{
302 using Call_t = GLint(*)(GLuint, const GLchar *);
303 static auto glCall = GetProcAddress<Call_t>("glGetAttribLocation");
304
305 return glCall(program, name);
306}
307
308inline void glVertexAttribPointer(GLuint index, GLint size, GLenum type,
309 GLboolean normalized, GLsizei stride, const GLvoid * pointer)
310{
311 using Call_t = void(*)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
312 static auto glCall = GetProcAddress<Call_t>("glVertexAttribPointer");
313
314 glCall(index, size, type, normalized, stride, pointer);
315}
316
317inline void glEnableVertexAttribArray(GLuint index)
318{
319 using Call_t = void(*)(GLuint);
320 static auto glCall = GetProcAddress<Call_t>("glEnableVertexAttribArray");
321
322 glCall(index);
323}
324
325inline GLint glGetUniformLocation(GLuint program, const GLchar *name)
326{
327 using Call_t = GLint(*)(GLuint, const GLchar *);
328 static auto glCall = GetProcAddress<Call_t>("glGetUniformLocation");
329
330 return glCall(program, name);
331}
332
333inline void glUniform1i(GLint location, GLint v0)
334{
335 using Call_t = void(*)(GLint, GLint);
336 static auto glCall = GetProcAddress<Call_t>("glUniform1i");
337
338 glCall(location, v0);
339}
340
341inline void glUniform1f(GLint location, GLfloat x)
342{
343 using Call_t = void(*)(GLint, GLfloat);
344 static auto glCall = GetProcAddress<Call_t>("glUniform1f");
345
346 glCall(location, x);
347}
348
349inline void glUniform4fv(GLint location, GLsizei count, const GLfloat *value)
350{
351 using Call_t = void(*)(GLint, GLsizei, const GLfloat *);
352 static auto glCall = GetProcAddress<Call_t>("glUniform4fv");
353
354 glCall(location, count, value);
355}
356
357inline void glUniformMatrix4fv(GLint location, GLsizei count,
358 GLboolean transpose, const GLfloat *value)
359{
360 using Call_t = void(*)(GLint, GLsizei, GLboolean, const GLfloat *);
361 static auto glCall = GetProcAddress<Call_t>("glUniformMatrix4fv");
362
363 glCall(location, count, transpose, value);
364}
365
366inline GLuint glGetUniformBlockIndex(GLuint program, const GLchar *uniformBlockName)
367{
368 using Call_t = GLuint(*)(GLuint, const GLchar *);
369 static auto glCall = GetProcAddress<Call_t>("glGetUniformBlockIndex");
370
371 return glCall(program, uniformBlockName);
372}
373
374inline void glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex,
375 GLuint uniformBlockBinding)
376{
377 using Call_t = void(*)(GLuint, GLuint, GLuint);
378 static auto glCall = GetProcAddress<Call_t>("glUniformBlockBinding");
379
380 glCall(program, uniformBlockIndex, uniformBlockBinding);
381}
382
383inline const GLubyte * glGetStringi(GLenum name, GLuint index)
384{
385 using Call_t = const GLubyte *(*)(GLenum, GLuint);
386 static auto glCall = GetProcAddress<Call_t>("glGetStringi");
387
388 return glCall(name, index);
389}
390
391inline void glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
392 GLsizei instancecount)
393{
394 using Call_t = void(*)(GLenum, GLint, GLsizei, GLsizei);
395 static auto glCall = GetProcAddress<Call_t>("glDrawArraysInstanced");
396
397 glCall(mode, first, count, instancecount);
398}
399
400inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
401 const void * indices, GLsizei instancecount)
402{
403 using Call_t = void(*)(GLenum, GLsizei, GLenum, const void *, GLsizei);
404 static auto glCall = GetProcAddress<Call_t>("glDrawElementsInstanced");
405
406 glCall(mode, count, type, indices, instancecount);
407}
408
409inline void glVertexAttribDivisor(GLuint index, GLuint divisor)
410{
411 using Call_t = void(*)(GLuint, GLuint);
412 static auto glCall = GetProcAddress<Call_t>("glVertexAttribDivisor");
413
414 glCall(index, divisor);
415}
416
417inline void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize,
418 GLsizei *length, GLint *size, GLenum *type, GLchar *name)
419{
420 using Call_t = void(*)(GLuint, GLuint, GLsizei, GLsizei *, GLint *,
421 GLenum *, GLchar *);
422 static auto glCall = GetProcAddress<Call_t>("glGetActiveAttrib");
423
424 glCall(program, index, bufSize, length, size, type, name);
425}
426
427inline void glGenFramebuffers(GLsizei n, GLuint *ids)
428{
429 using Call_t = void(*)(GLsizei, GLuint *);
430 static auto glCall = GetProcAddress<Call_t>("glGenFramebuffers");
431
432 glCall(n, ids);
433}
434
435inline void glBindFramebuffer(GLenum target, GLuint framebuffer)
436{
437 using Call_t = void(*)(GLenum, GLuint);
438 static auto glCall = GetProcAddress<Call_t>("glBindFramebuffer");
439
440 glCall(target, framebuffer);
441}
442
443inline GLenum glCheckFramebufferStatus(GLenum target)
444{
445 using Call_t = GLenum(*)(GLenum);
446 static auto glCall = GetProcAddress<Call_t>("glCheckFramebufferStatus");
447
448 return glCall(target);
449}
450
451inline void glDeleteFramebuffers(GLsizei n, const GLuint * framebuffers)
452{
453 using Call_t = void(*)(GLsizei, const GLuint *);
454 static auto glCall = GetProcAddress<Call_t>("glDeleteFramebuffers");
455
456 glCall(n, framebuffers);
457}
458
459inline void glFramebufferTexture2D(GLenum target, GLenum attachment,
460 GLenum textarget, GLuint texture, GLint level)
461{
462 using Call_t = void(*)(GLenum, GLenum, GLenum, GLuint, GLint);
463 static auto glCall = GetProcAddress<Call_t>("glFramebufferTexture2D");
464
465 glCall(target, attachment, textarget, texture, level);
466}
467
468inline void glDepthRangef(GLfloat n, GLfloat f)
469{
470 using Call_t = void(*)(GLfloat, GLfloat);
471 static auto glCall = GetProcAddress<Call_t>("glDepthRangef");
472
473 glCall(n, f);
474}
475
476inline void glDrawBuffers(GLsizei n, const GLenum *bufs)
477{
478 using Call_t = void(*)(GLsizei, const GLenum *);
479 static auto glCall = GetProcAddress<Call_t>("glDrawBuffers");
480
481 glCall(n, bufs);
482}
483
484inline void glGenerateMipmap(GLenum target)
485{
486 using Call_t = void(*)(GLenum);
487 static auto glCall = GetProcAddress<Call_t>("glGenerateMipmap");
488
489 glCall(target);
490}
491
492#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
493#define GL_DEBUG_OUTPUT 0x92E0
494
495#define GL_DEBUG_TYPE_ERROR 0x824C
496#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
497#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
498#define GL_DEBUG_TYPE_PORTABILITY 0x824F
499#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
500#define GL_DEBUG_TYPE_OTHER 0x8251
501#define GL_DEBUG_TYPE_MARKER 0x8268
502#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
503#define GL_DEBUG_TYPE_POP_GROUP 0x826A
504
505#define GL_DEBUG_SEVERITY_HIGH 0x9146
506#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
507#define GL_DEBUG_SEVERITY_LOW 0x9148
508#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
509
510typedef void (APIENTRY * DEBUGPROC)(GLenum source, GLenum type, GLuint id,
511 GLenum severity, GLsizei length, const GLchar *message, const void *userParam);
512
513inline void glDebugMessageCallback(DEBUGPROC callback, const void * userParam)
514{
515 using Call_t = void(*)(DEBUGPROC, const void *);
516 static auto glCall = GetProcAddress<Call_t>("glDebugMessageCallback");
517
518 glCall(callback, userParam);
519}
520
521inline void glDebugMessageControl(GLenum source, GLenum type, GLenum severity,
522 GLsizei count, const GLuint *ids, GLboolean enabled)
523{
524 using Call_t = void(*)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean);
525 static auto glCall = GetProcAddress<Call_t>("glDebugMessageControl");
526
527 glCall(source, type, severity, count, ids, enabled);
528}