Update glad, add debug extensions

This commit is contained in:
Camilla Berglund 2016-09-21 18:12:00 +02:00
parent 1fc11c27e7
commit 38aae024cd
2 changed files with 521 additions and 380 deletions

116
deps/glad.c vendored
View File

@ -1,3 +1,25 @@
/*
OpenGL loader generated by glad 0.1.12a0 on Thu Sep 22 01:08:06 2016.
Language/Generator: C/C++
Specification: gl
APIs: gl=3.2
Profile: compatibility
Extensions:
GL_ARB_debug_output,
GL_ARB_multisample,
GL_ARB_robustness
Loader: False
Local files: False
Omit khrplatform: False
Commandline:
--profile="compatibility" --api="gl=3.2" --generator="c" --spec="gl" --no-loader --extensions="GL_ARB_debug_output,GL_ARB_multisample,GL_ARB_robustness"
Online:
http://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&api=gl%3D3.2&extensions=GL_ARB_debug_output&extensions=GL_ARB_multisample&extensions=GL_ARB_robustness
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -5,14 +27,59 @@
struct gladGLversionStruct GLVersion; struct gladGLversionStruct GLVersion;
#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
#define _GLAD_IS_SOME_NEW_VERSION 1
#endif
static int max_loaded_major;
static int max_loaded_minor;
static const char *exts = NULL;
static int num_exts_i = 0;
static const char **exts_i = NULL;
static int get_exts(void) {
#ifdef _GLAD_IS_SOME_NEW_VERSION
if(max_loaded_major < 3) {
#endif
exts = (const char *)glGetString(GL_EXTENSIONS);
#ifdef _GLAD_IS_SOME_NEW_VERSION
} else {
int index;
num_exts_i = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);
if (num_exts_i > 0) {
exts_i = (const char **)realloc((void *)exts_i, num_exts_i * sizeof *exts_i);
}
if (exts_i == NULL) {
return 0;
}
for(index = 0; index < num_exts_i; index++) {
exts_i[index] = (const char*)glGetStringi(GL_EXTENSIONS, index);
}
}
#endif
return 1;
}
static void free_exts(void) {
if (exts_i != NULL) {
free((char **)exts_i);
exts_i = NULL;
}
}
static int has_ext(const char *ext) { static int has_ext(const char *ext) {
#if defined(GL_VERSION_3_0) || defined(GL_ES_VERSION_3_0) #ifdef _GLAD_IS_SOME_NEW_VERSION
if(GLVersion.major < 3 || glGetStringi == NULL) { if(max_loaded_major < 3) {
#endif #endif
const char *extensions; const char *extensions;
const char *loc; const char *loc;
const char *terminator; const char *terminator;
extensions = (const char*) glGetString(GL_EXTENSIONS); extensions = exts;
if(extensions == NULL || ext == NULL) { if(extensions == NULL || ext == NULL) {
return 0; return 0;
} }
@ -30,13 +97,14 @@ static int has_ext(const char *ext) {
} }
extensions = terminator; extensions = terminator;
} }
#if defined(GL_VERSION_3_0) || defined(GL_ES_VERSION_3_0) #ifdef _GLAD_IS_SOME_NEW_VERSION
} else { } else {
GLint num_exts, index; int index;
glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts); for(index = 0; index < num_exts_i; index++) {
for(index = 0; index < num_exts; index++) { const char *e = exts_i[index];
if(strcmp((const char*) glGetStringi(GL_EXTENSIONS, index), ext) == 0) {
if(strcmp(e, ext) == 0) {
return 1; return 1;
} }
} }
@ -316,7 +384,7 @@ PFNGLRASTERPOS3FPROC glad_glRasterPos3f;
PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D; PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
PFNGLTEXCOORD3FPROC glad_glTexCoord3f; PFNGLTEXCOORD3FPROC glad_glTexCoord3f;
PFNGLDELETESYNCPROC glad_glDeleteSync; PFNGLDELETESYNCPROC glad_glDeleteSync;
PFNGLTEXCOORD3DPROC glad_glTexCoord3d; PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample; PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv; PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements; PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
@ -363,7 +431,7 @@ PFNGLVIEWPORTPROC glad_glViewport;
PFNGLUNIFORM1UIVPROC glad_glUniform1uiv; PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings; PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
PFNGLINDEXDVPROC glad_glIndexdv; PFNGLINDEXDVPROC glad_glIndexdv;
PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D; PFNGLTEXCOORD3DPROC glad_glTexCoord3d;
PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv; PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv;
PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i; PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
PFNGLCLEARDEPTHPROC glad_glClearDepth; PFNGLCLEARDEPTHPROC glad_glClearDepth;
@ -723,8 +791,12 @@ PFNGLFRONTFACEPROC glad_glFrontFace;
PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v; PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv; PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
int GLAD_GL_ARB_robustness; int GLAD_GL_ARB_robustness;
int GLAD_GL_ARB_debug_output;
int GLAD_GL_ARB_multisample; int GLAD_GL_ARB_multisample;
int GLAD_GL_EXT_separate_specular_color; PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB;
PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB; PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB; PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB;
PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB; PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB;
@ -1448,6 +1520,13 @@ static void load_GL_VERSION_3_2(GLADloadproc load) {
glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv"); glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski"); glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
} }
static void load_GL_ARB_debug_output(GLADloadproc load) {
if(!GLAD_GL_ARB_debug_output) return;
glad_glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)load("glDebugMessageControlARB");
glad_glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC)load("glDebugMessageInsertARB");
glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)load("glDebugMessageCallbackARB");
glad_glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)load("glGetDebugMessageLogARB");
}
static void load_GL_ARB_multisample(GLADloadproc load) { static void load_GL_ARB_multisample(GLADloadproc load) {
if(!GLAD_GL_ARB_multisample) return; if(!GLAD_GL_ARB_multisample) return;
glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)load("glSampleCoverageARB"); glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)load("glSampleCoverageARB");
@ -1475,10 +1554,13 @@ static void load_GL_ARB_robustness(GLADloadproc load) {
glad_glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC)load("glGetnHistogramARB"); glad_glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC)load("glGetnHistogramARB");
glad_glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC)load("glGetnMinmaxARB"); glad_glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC)load("glGetnMinmaxARB");
} }
static void find_extensionsGL(void) { static int find_extensionsGL(void) {
GLAD_GL_EXT_separate_specular_color = has_ext("GL_EXT_separate_specular_color"); if (!get_exts()) return 0;
GLAD_GL_ARB_debug_output = has_ext("GL_ARB_debug_output");
GLAD_GL_ARB_multisample = has_ext("GL_ARB_multisample"); GLAD_GL_ARB_multisample = has_ext("GL_ARB_multisample");
GLAD_GL_ARB_robustness = has_ext("GL_ARB_robustness"); GLAD_GL_ARB_robustness = has_ext("GL_ARB_robustness");
free_exts();
return 1;
} }
static void find_coreGL(void) { static void find_coreGL(void) {
@ -1516,6 +1598,7 @@ static void find_coreGL(void) {
#endif #endif
GLVersion.major = major; GLVersion.minor = minor; GLVersion.major = major; GLVersion.minor = minor;
max_loaded_major = major; max_loaded_minor = minor;
GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1; GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1; GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
@ -1527,6 +1610,10 @@ static void find_coreGL(void) {
GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3; GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3; GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3; GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
if (GLVersion.major > 3 || (GLVersion.major >= 3 && GLVersion.minor >= 2)) {
max_loaded_major = 3;
max_loaded_minor = 2;
}
} }
int gladLoadGLLoader(GLADloadproc load) { int gladLoadGLLoader(GLADloadproc load) {
@ -1547,7 +1634,8 @@ int gladLoadGLLoader(GLADloadproc load) {
load_GL_VERSION_3_1(load); load_GL_VERSION_3_1(load);
load_GL_VERSION_3_2(load); load_GL_VERSION_3_2(load);
find_extensionsGL(); if (!find_extensionsGL()) return 0;
load_GL_ARB_debug_output(load);
load_GL_ARB_multisample(load); load_GL_ARB_multisample(load);
load_GL_ARB_robustness(load); load_GL_ARB_robustness(load);
return GLVersion.major != 0 || GLVersion.minor != 0; return GLVersion.major != 0 || GLVersion.minor != 0;

785
deps/glad/glad.h vendored

File diff suppressed because it is too large Load Diff