59 #if defined(IMGL3W_SCUMMVM_LOADER) 60 #define FORBIDDEN_SYMBOL_ALLOW_ALL 61 #include "common/system.h" 65 #ifndef __khrplatform_h_ 66 typedef float khronos_float_t;
67 typedef signed char khronos_int8_t;
68 typedef unsigned char khronos_uint8_t;
69 typedef signed short int khronos_int16_t;
70 typedef unsigned short int khronos_uint16_t;
72 typedef signed long long int khronos_intptr_t;
73 typedef signed long long int khronos_ssize_t;
75 typedef signed long int khronos_intptr_t;
76 typedef signed long int khronos_ssize_t;
79 #if defined(_MSC_VER) && !defined(__clang__) 80 typedef signed __int64 khronos_int64_t;
81 typedef unsigned __int64 khronos_uint64_t;
82 #elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) 84 typedef int64_t khronos_int64_t;
85 typedef uint64_t khronos_uint64_t;
87 typedef signed long long khronos_int64_t;
88 typedef unsigned long long khronos_uint64_t;
90 #endif // __khrplatform_h_ 92 #ifndef __gl_glcorearb_h_ 93 #define __gl_glcorearb_h_ 1 106 #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) 107 #ifndef WIN32_LEAN_AND_MEAN 108 #define WIN32_LEAN_AND_MEAN 1 116 #define APIENTRYP APIENTRY * 143 #ifndef GL_VERSION_1_0 145 typedef unsigned int GLenum;
147 typedef khronos_float_t GLfloat;
150 typedef unsigned int GLbitfield;
151 typedef double GLdouble;
152 typedef unsigned int GLuint;
153 typedef unsigned char GLboolean;
154 typedef khronos_uint8_t GLubyte;
155 #define GL_COLOR_BUFFER_BIT 0x00004000 158 #define GL_TRIANGLES 0x0004 160 #define GL_SRC_ALPHA 0x0302 161 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 162 #define GL_FRONT 0x0404 163 #define GL_BACK 0x0405 164 #define GL_FRONT_AND_BACK 0x0408 165 #define GL_POLYGON_MODE 0x0B40 166 #define GL_CULL_FACE 0x0B44 167 #define GL_DEPTH_TEST 0x0B71 168 #define GL_STENCIL_TEST 0x0B90 169 #define GL_VIEWPORT 0x0BA2 170 #define GL_BLEND 0x0BE2 171 #define GL_SCISSOR_BOX 0x0C10 172 #define GL_SCISSOR_TEST 0x0C11 173 #define GL_UNPACK_ROW_LENGTH 0x0CF2 174 #define GL_PACK_ALIGNMENT 0x0D05 175 #define GL_TEXTURE_2D 0x0DE1 176 #define GL_UNSIGNED_BYTE 0x1401 177 #define GL_UNSIGNED_SHORT 0x1403 178 #define GL_UNSIGNED_INT 0x1405 179 #define GL_FLOAT 0x1406 180 #define GL_RGBA 0x1908 181 #define GL_FILL 0x1B02 182 #define GL_VENDOR 0x1F00 183 #define GL_RENDERER 0x1F01 184 #define GL_VERSION 0x1F02 185 #define GL_EXTENSIONS 0x1F03 186 #define GL_LINEAR 0x2601 187 #define GL_TEXTURE_MAG_FILTER 0x2800 188 #define GL_TEXTURE_MIN_FILTER 0x2801 189 typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode);
190 typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
191 typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
192 typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
const void *pixels);
193 typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
194 typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
195 typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
196 typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap);
197 typedef void (APIENTRYP PFNGLFLUSHPROC) (void);
198 typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
199 typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
void *pixels);
200 typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void);
201 typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data);
202 typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
203 typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap);
204 typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
205 #ifdef GL_GLEXT_PROTOTYPES 206 GLAPI
void APIENTRY glPolygonMode (GLenum face, GLenum mode);
207 GLAPI
void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
208 GLAPI
void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
209 GLAPI
void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
const void *pixels);
210 GLAPI
void APIENTRY glClear (GLbitfield mask);
211 GLAPI
void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
212 GLAPI
void APIENTRY glDisable (GLenum cap);
213 GLAPI
void APIENTRY glEnable (GLenum cap);
214 GLAPI
void APIENTRY glFlush (
void);
215 GLAPI
void APIENTRY glPixelStorei (GLenum pname, GLint param);
216 GLAPI
void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
void *pixels);
217 GLAPI GLenum APIENTRY glGetError (
void);
218 GLAPI
void APIENTRY glGetIntegerv (GLenum pname, GLint *data);
219 GLAPI
const GLubyte *APIENTRY glGetString (GLenum name);
220 GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap);
221 GLAPI
void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
224 #ifndef GL_VERSION_1_1 225 typedef khronos_float_t GLclampf;
226 typedef double GLclampd;
227 #define GL_TEXTURE_BINDING_2D 0x8069 228 typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type,
const void *indices);
229 typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
230 typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n,
const GLuint *textures);
231 typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
232 #ifdef GL_GLEXT_PROTOTYPES 233 GLAPI
void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type,
const void *indices);
234 GLAPI
void APIENTRY glBindTexture (GLenum target, GLuint texture);
235 GLAPI
void APIENTRY glDeleteTextures (GLsizei n,
const GLuint *textures);
236 GLAPI
void APIENTRY glGenTextures (GLsizei n, GLuint *textures);
239 #ifndef GL_VERSION_1_3 240 #define GL_TEXTURE0 0x84C0 241 #define GL_ACTIVE_TEXTURE 0x84E0 242 typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
243 #ifdef GL_GLEXT_PROTOTYPES 244 GLAPI
void APIENTRY glActiveTexture (GLenum texture);
247 #ifndef GL_VERSION_1_4 248 #define GL_BLEND_DST_RGB 0x80C8 249 #define GL_BLEND_SRC_RGB 0x80C9 250 #define GL_BLEND_DST_ALPHA 0x80CA 251 #define GL_BLEND_SRC_ALPHA 0x80CB 252 #define GL_FUNC_ADD 0x8006 253 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
254 typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
255 #ifdef GL_GLEXT_PROTOTYPES 256 GLAPI
void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
257 GLAPI
void APIENTRY glBlendEquation (GLenum mode);
260 #ifndef GL_VERSION_1_5 261 typedef khronos_ssize_t GLsizeiptr;
262 typedef khronos_intptr_t GLintptr;
263 #define GL_ARRAY_BUFFER 0x8892 264 #define GL_ELEMENT_ARRAY_BUFFER 0x8893 265 #define GL_ARRAY_BUFFER_BINDING 0x8894 266 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 267 #define GL_STREAM_DRAW 0x88E0 268 typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
269 typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n,
const GLuint *buffers);
270 typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
271 typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size,
const void *data, GLenum usage);
272 typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size,
const void *data);
273 #ifdef GL_GLEXT_PROTOTYPES 274 GLAPI
void APIENTRY glBindBuffer (GLenum target, GLuint buffer);
275 GLAPI
void APIENTRY glDeleteBuffers (GLsizei n,
const GLuint *buffers);
276 GLAPI
void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
277 GLAPI
void APIENTRY glBufferData (GLenum target, GLsizeiptr size,
const void *data, GLenum usage);
278 GLAPI
void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size,
const void *data);
281 #ifndef GL_VERSION_2_0 283 typedef khronos_int16_t GLshort;
284 typedef khronos_int8_t GLbyte;
285 typedef khronos_uint16_t GLushort;
286 #define GL_BLEND_EQUATION_RGB 0x8009 287 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 288 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 289 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 290 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 291 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 292 #define GL_BLEND_EQUATION_ALPHA 0x883D 293 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A 294 #define GL_FRAGMENT_SHADER 0x8B30 295 #define GL_VERTEX_SHADER 0x8B31 296 #define GL_COMPILE_STATUS 0x8B81 297 #define GL_LINK_STATUS 0x8B82 298 #define GL_INFO_LOG_LENGTH 0x8B84 299 #define GL_CURRENT_PROGRAM 0x8B8D 300 #define GL_UPPER_LEFT 0x8CA2 301 typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
302 typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
303 typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
304 typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
305 typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
306 typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
307 typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
308 typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
309 typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
310 typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
311 typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program,
const GLchar *name);
312 typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
313 typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
314 typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
315 typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
316 typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program,
const GLchar *name);
317 typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
318 typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname,
void **pointer);
319 typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
320 typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
321 typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count,
const GLchar *
const*string,
const GLint *length);
322 typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
323 typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
324 typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value);
325 typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
const void *pointer);
326 #ifdef GL_GLEXT_PROTOTYPES 327 GLAPI
void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
328 GLAPI
void APIENTRY glAttachShader (GLuint program, GLuint shader);
329 GLAPI
void APIENTRY glCompileShader (GLuint shader);
330 GLAPI GLuint APIENTRY glCreateProgram (
void);
331 GLAPI GLuint APIENTRY glCreateShader (GLenum type);
332 GLAPI
void APIENTRY glDeleteProgram (GLuint program);
333 GLAPI
void APIENTRY glDeleteShader (GLuint shader);
334 GLAPI
void APIENTRY glDetachShader (GLuint program, GLuint shader);
335 GLAPI
void APIENTRY glDisableVertexAttribArray (GLuint index);
336 GLAPI
void APIENTRY glEnableVertexAttribArray (GLuint index);
337 GLAPI GLint APIENTRY glGetAttribLocation (GLuint program,
const GLchar *name);
338 GLAPI
void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
339 GLAPI
void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
340 GLAPI
void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
341 GLAPI
void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
342 GLAPI GLint APIENTRY glGetUniformLocation (GLuint program,
const GLchar *name);
343 GLAPI
void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
344 GLAPI
void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname,
void **pointer);
345 GLAPI GLboolean APIENTRY glIsProgram (GLuint program);
346 GLAPI
void APIENTRY glLinkProgram (GLuint program);
347 GLAPI
void APIENTRY glShaderSource (GLuint shader, GLsizei count,
const GLchar *
const*
string,
const GLint *length);
348 GLAPI
void APIENTRY glUseProgram (GLuint program);
349 GLAPI
void APIENTRY glUniform1i (GLint location, GLint v0);
350 GLAPI
void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value);
351 GLAPI
void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
const void *pointer);
354 #ifndef GL_VERSION_2_1 355 #define GL_PIXEL_UNPACK_BUFFER 0x88EC 356 #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF 358 #ifndef GL_VERSION_3_0 359 typedef khronos_uint16_t GLhalf;
360 #define GL_MAJOR_VERSION 0x821B 361 #define GL_MINOR_VERSION 0x821C 362 #define GL_NUM_EXTENSIONS 0x821D 363 #define GL_FRAMEBUFFER_SRGB 0x8DB9 364 #define GL_VERTEX_ARRAY_BINDING 0x85B5 365 typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
366 typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
367 typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
368 typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
369 typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n,
const GLuint *arrays);
370 typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
371 #ifdef GL_GLEXT_PROTOTYPES 372 GLAPI
const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index);
373 GLAPI
void APIENTRY glBindVertexArray (GLuint array);
374 GLAPI
void APIENTRY glDeleteVertexArrays (GLsizei n,
const GLuint *arrays);
375 GLAPI
void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
378 #ifndef GL_VERSION_3_1 379 #define GL_VERSION_3_1 1 380 #define GL_PRIMITIVE_RESTART 0x8F9D 382 #ifndef GL_VERSION_3_2 383 #define GL_VERSION_3_2 1 384 typedef struct __GLsync *GLsync;
385 typedef khronos_uint64_t GLuint64;
386 typedef khronos_int64_t GLint64;
387 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 388 #define GL_CONTEXT_PROFILE_MASK 0x9126 389 typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type,
const void *indices, GLint basevertex);
390 typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
391 #ifdef GL_GLEXT_PROTOTYPES 392 GLAPI
void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type,
const void *indices, GLint basevertex);
395 #ifndef GL_VERSION_3_3 396 #define GL_VERSION_3_3 1 397 #define GL_SAMPLER_BINDING 0x8919 398 typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
399 #ifdef GL_GLEXT_PROTOTYPES 400 GLAPI
void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
403 #ifndef GL_VERSION_4_1 404 typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);
405 typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);
407 #ifndef GL_VERSION_4_3 408 typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,
const GLchar *message,
const void *userParam);
410 #ifndef GL_VERSION_4_5 411 #define GL_CLIP_ORIGIN 0x935C 412 typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param);
413 typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param);
415 #ifndef GL_ARB_bindless_texture 416 typedef khronos_uint64_t GLuint64EXT;
418 #ifndef GL_ARB_cl_event 422 #ifndef GL_ARB_clip_control 423 #define GL_ARB_clip_control 1 425 #ifndef GL_ARB_debug_output 426 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,
const GLchar *message,
const void *userParam);
428 #ifndef GL_EXT_EGL_image_storage 429 typedef void *GLeglImageOES;
431 #ifndef GL_EXT_direct_state_access 432 typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params);
433 typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params);
434 typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index,
void **params);
435 typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param);
436 typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname,
void **param);
438 #ifndef GL_NV_draw_vulkan_image 439 typedef void (APIENTRY *GLVULKANPROCNV)(void);
441 #ifndef GL_NV_gpu_shader5 442 typedef khronos_int64_t GLint64EXT;
444 #ifndef GL_NV_vertex_buffer_unified_memory 445 typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
465 #define GL3W_ERROR_INIT -1 466 #define GL3W_ERROR_LIBRARY_OPEN -2 467 #define GL3W_ERROR_OPENGL_VERSION -3 469 typedef void (*GL3WglProc)(void);
470 typedef GL3WglProc (*GL3WGetProcAddressProc)(
const char *proc);
473 GL3W_API
int imgl3wInit(
void);
474 GL3W_API
int imgl3wInit2(GL3WGetProcAddressProc proc);
475 GL3W_API
int imgl3wIsSupported(
int major,
int minor);
476 GL3W_API GL3WglProc imgl3wGetProcAddress(
const char *proc);
482 PFNGLACTIVETEXTUREPROC ActiveTexture;
483 PFNGLATTACHSHADERPROC AttachShader;
484 PFNGLBINDBUFFERPROC BindBuffer;
485 PFNGLBINDSAMPLERPROC BindSampler;
486 PFNGLBINDTEXTUREPROC BindTexture;
487 PFNGLBINDVERTEXARRAYPROC BindVertexArray;
488 PFNGLBLENDEQUATIONPROC BlendEquation;
489 PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate;
490 PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate;
491 PFNGLBUFFERDATAPROC BufferData;
492 PFNGLBUFFERSUBDATAPROC BufferSubData;
493 PFNGLCLEARPROC Clear;
494 PFNGLCLEARCOLORPROC ClearColor;
495 PFNGLCOMPILESHADERPROC CompileShader;
496 PFNGLCREATEPROGRAMPROC CreateProgram;
497 PFNGLCREATESHADERPROC CreateShader;
498 PFNGLDELETEBUFFERSPROC DeleteBuffers;
499 PFNGLDELETEPROGRAMPROC DeleteProgram;
500 PFNGLDELETESHADERPROC DeleteShader;
501 PFNGLDELETETEXTURESPROC DeleteTextures;
502 PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
503 PFNGLDETACHSHADERPROC DetachShader;
504 PFNGLDISABLEPROC Disable;
505 PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray;
506 PFNGLDRAWELEMENTSPROC DrawElements;
507 PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex;
508 PFNGLENABLEPROC Enable;
509 PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
510 PFNGLFLUSHPROC Flush;
511 PFNGLGENBUFFERSPROC GenBuffers;
512 PFNGLGENTEXTURESPROC GenTextures;
513 PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
514 PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
515 PFNGLGETERRORPROC GetError;
516 PFNGLGETINTEGERVPROC GetIntegerv;
517 PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
518 PFNGLGETPROGRAMIVPROC GetProgramiv;
519 PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
520 PFNGLGETSHADERIVPROC GetShaderiv;
521 PFNGLGETSTRINGPROC GetString;
522 PFNGLGETSTRINGIPROC GetStringi;
523 PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation;
524 PFNGLGETVERTEXATTRIBPOINTERVPROC GetVertexAttribPointerv;
525 PFNGLGETVERTEXATTRIBIVPROC GetVertexAttribiv;
526 PFNGLISENABLEDPROC IsEnabled;
527 PFNGLISPROGRAMPROC IsProgram;
528 PFNGLLINKPROGRAMPROC LinkProgram;
529 PFNGLPIXELSTOREIPROC PixelStorei;
530 PFNGLPOLYGONMODEPROC PolygonMode;
531 PFNGLREADPIXELSPROC ReadPixels;
532 PFNGLSCISSORPROC Scissor;
533 PFNGLSHADERSOURCEPROC ShaderSource;
534 PFNGLTEXIMAGE2DPROC TexImage2D;
535 PFNGLTEXPARAMETERIPROC TexParameteri;
536 PFNGLUNIFORM1IPROC Uniform1i;
537 PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv;
538 PFNGLUSEPROGRAMPROC UseProgram;
539 PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer;
540 PFNGLVIEWPORTPROC Viewport;
547 #define glActiveTexture imgl3wProcs.gl.ActiveTexture 548 #define glAttachShader imgl3wProcs.gl.AttachShader 549 #define glBindBuffer imgl3wProcs.gl.BindBuffer 550 #define glBindSampler imgl3wProcs.gl.BindSampler 551 #define glBindTexture imgl3wProcs.gl.BindTexture 552 #define glBindVertexArray imgl3wProcs.gl.BindVertexArray 553 #define glBlendEquation imgl3wProcs.gl.BlendEquation 554 #define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate 555 #define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate 556 #define glBufferData imgl3wProcs.gl.BufferData 557 #define glBufferSubData imgl3wProcs.gl.BufferSubData 558 #define glClear imgl3wProcs.gl.Clear 559 #define glClearColor imgl3wProcs.gl.ClearColor 560 #define glCompileShader imgl3wProcs.gl.CompileShader 561 #define glCreateProgram imgl3wProcs.gl.CreateProgram 562 #define glCreateShader imgl3wProcs.gl.CreateShader 563 #define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers 564 #define glDeleteProgram imgl3wProcs.gl.DeleteProgram 565 #define glDeleteShader imgl3wProcs.gl.DeleteShader 566 #define glDeleteTextures imgl3wProcs.gl.DeleteTextures 567 #define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays 568 #define glDetachShader imgl3wProcs.gl.DetachShader 569 #define glDisable imgl3wProcs.gl.Disable 570 #define glDisableVertexAttribArray imgl3wProcs.gl.DisableVertexAttribArray 571 #define glDrawElements imgl3wProcs.gl.DrawElements 572 #define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex 573 #define glEnable imgl3wProcs.gl.Enable 574 #define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray 575 #define glFlush imgl3wProcs.gl.Flush 576 #define glGenBuffers imgl3wProcs.gl.GenBuffers 577 #define glGenTextures imgl3wProcs.gl.GenTextures 578 #define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays 579 #define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation 580 #define glGetError imgl3wProcs.gl.GetError 581 #define glGetIntegerv imgl3wProcs.gl.GetIntegerv 582 #define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog 583 #define glGetProgramiv imgl3wProcs.gl.GetProgramiv 584 #define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog 585 #define glGetShaderiv imgl3wProcs.gl.GetShaderiv 586 #define glGetString imgl3wProcs.gl.GetString 587 #define glGetStringi imgl3wProcs.gl.GetStringi 588 #define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation 589 #define glGetVertexAttribPointerv imgl3wProcs.gl.GetVertexAttribPointerv 590 #define glGetVertexAttribiv imgl3wProcs.gl.GetVertexAttribiv 591 #define glIsEnabled imgl3wProcs.gl.IsEnabled 592 #define glIsProgram imgl3wProcs.gl.IsProgram 593 #define glLinkProgram imgl3wProcs.gl.LinkProgram 594 #define glPixelStorei imgl3wProcs.gl.PixelStorei 595 #define glPolygonMode imgl3wProcs.gl.PolygonMode 596 #define glReadPixels imgl3wProcs.gl.ReadPixels 597 #define glScissor imgl3wProcs.gl.Scissor 598 #define glShaderSource imgl3wProcs.gl.ShaderSource 599 #define glTexImage2D imgl3wProcs.gl.TexImage2D 600 #define glTexParameteri imgl3wProcs.gl.TexParameteri 601 #define glUniform1i imgl3wProcs.gl.Uniform1i 602 #define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv 603 #define glUseProgram imgl3wProcs.gl.UseProgram 604 #define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer 605 #define glViewport imgl3wProcs.gl.Viewport 620 #define GL3W_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 622 #if defined(IMGL3W_SCUMMVM_LOADER) 623 static int open_libgl(
void)
628 static void close_libgl(
void) { }
630 static GL3WglProc get_proc(
const char *proc)
632 return (GL3WglProc)
g_system->getOpenGLProcAddress(proc);
635 #elif defined(_WIN32) 636 #ifndef WIN32_LEAN_AND_MEAN 637 #define WIN32_LEAN_AND_MEAN 1 641 static HMODULE libgl;
642 typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
643 static GL3WglGetProcAddr wgl_get_proc_address;
645 static int open_libgl(
void)
647 libgl = LoadLibraryA(
"opengl32.dll");
649 return GL3W_ERROR_LIBRARY_OPEN;
650 wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl,
"wglGetProcAddress");
654 static void close_libgl(
void) { FreeLibrary(libgl); }
655 static GL3WglProc get_proc(
const char *proc)
658 res = (GL3WglProc)wgl_get_proc_address(proc);
660 res = (GL3WglProc)GetProcAddress(libgl, proc);
663 #elif defined(__APPLE__) 667 static int open_libgl(
void)
669 libgl = dlopen(
"/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
671 return GL3W_ERROR_LIBRARY_OPEN;
675 static void close_libgl(
void) { dlclose(libgl); }
677 static GL3WglProc get_proc(
const char *proc)
680 *(
void **)(&res) = dlsym(libgl, proc);
689 static GL3WGetProcAddressProc gl_get_proc_address;
691 static void close_libgl(
void)
707 static int is_library_loaded(
const char* name,
void** lib)
709 *lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
713 static int open_libs(
void)
725 if (is_library_loaded(
"libEGL.so.1", &libegl) ||
726 is_library_loaded(
"libGLX.so.0", &libglx)) {
727 libgl = dlopen(
"libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
734 if (is_library_loaded(
"libGL.so", &libgl))
736 if (is_library_loaded(
"libGL.so.1", &libgl))
738 if (is_library_loaded(
"libGL.so.3", &libgl))
745 libgl = dlopen(
"libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
746 libegl = dlopen(
"libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
754 libgl = dlopen(
"libGL.so", RTLD_LAZY | RTLD_LOCAL);
756 libgl = dlopen(
"libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
758 libgl = dlopen(
"libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
763 return GL3W_ERROR_LIBRARY_OPEN;
766 static int open_libgl(
void)
768 int res = open_libs();
773 *(
void**)(&gl_get_proc_address) = dlsym(libegl,
"eglGetProcAddress");
775 *(
void**)(&gl_get_proc_address) = dlsym(libglx,
"glXGetProcAddressARB");
777 *(
void**)(&gl_get_proc_address) = dlsym(libgl,
"glXGetProcAddressARB");
779 if (!gl_get_proc_address) {
781 return GL3W_ERROR_LIBRARY_OPEN;
787 static GL3WglProc get_proc(
const char* proc)
789 GL3WglProc res = NULL;
795 *(
void**)(&res) = dlsym(libgl, proc);
798 res = gl_get_proc_address(proc);
801 *(
void**)(&res) = dlsym(libgl, proc);
807 static struct {
int major, minor; } version;
809 static int parse_version(
void)
812 return GL3W_ERROR_INIT;
813 glGetIntegerv(GL_MAJOR_VERSION, &version.major);
814 glGetIntegerv(GL_MINOR_VERSION, &version.minor);
815 if (version.major == 0 && version.minor == 0)
818 if (
const char* gl_version = (
const char*)glGetString(GL_VERSION))
819 sscanf(gl_version,
"%d.%d", &version.major, &version.minor);
821 if (version.major < 2)
822 return GL3W_ERROR_OPENGL_VERSION;
826 static void load_procs(GL3WGetProcAddressProc proc);
830 int res = open_libgl();
834 return imgl3wInit2(get_proc);
837 int imgl3wInit2(GL3WGetProcAddressProc proc)
840 return parse_version();
843 int imgl3wIsSupported(
int major,
int minor)
847 if (version.major == major)
848 return version.minor >= minor;
849 return version.major >= major;
852 GL3WglProc imgl3wGetProcAddress(
const char *proc) {
return get_proc(proc); }
854 static const char *proc_names[] = {
862 "glBlendEquationSeparate",
863 "glBlendFuncSeparate",
875 "glDeleteVertexArrays",
878 "glDisableVertexAttribArray",
880 "glDrawElementsBaseVertex",
882 "glEnableVertexAttribArray",
887 "glGetAttribLocation",
890 "glGetProgramInfoLog",
892 "glGetShaderInfoLog",
896 "glGetUniformLocation",
897 "glGetVertexAttribPointerv",
898 "glGetVertexAttribiv",
910 "glUniformMatrix4fv",
912 "glVertexAttribPointer",
918 static void load_procs(GL3WGetProcAddressProc proc)
921 for (i = 0; i < GL3W_ARRAY_SIZE(proc_names); i++)
922 imgl3wProcs.ptr[i] = proc(proc_names[i]);
Definition: imgui_impl_opengl3_loader.h:479