Simplify glad

This commit is contained in:
Camilla Berglund 2015-10-14 02:48:48 +02:00
parent d4c5d4d104
commit bf123b5299

58
deps/glad.c vendored
View File

@ -5,47 +5,16 @@
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 void 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);
}
for(index = 0; index < num_exts_i; index++) {
exts_i[index] = (const char*)glGetStringi(GL_EXTENSIONS, index);
}
}
#endif
}
static int has_ext(const char *ext) {
#ifdef _GLAD_IS_SOME_NEW_VERSION
if(max_loaded_major < 3) {
#if defined(GL_ES_VERSION_3_0)
if(!GLAD_GL_ES_VERSION_3_0) {
#elif defined(GL_VERSION_3_0)
if(!GLAD_GL_VERSION_3_0) {
#endif
const char *extensions;
const char *loc;
const char *terminator;
extensions = exts;
extensions = (const char*) glGetString(GL_EXTENSIONS);
if(extensions == NULL || ext == NULL) {
return 0;
}
@ -63,14 +32,13 @@ static int has_ext(const char *ext) {
}
extensions = terminator;
}
#ifdef _GLAD_IS_SOME_NEW_VERSION
#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
} else {
int index;
GLint num_exts, index;
for(index = 0; index < num_exts_i; index++) {
const char *e = exts_i[index];
if(strcmp(e, ext) == 0) {
glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts);
for(index = 0; index < num_exts; index++) {
if(strcmp((const char*) glGetStringi(GL_EXTENSIONS, index), ext) == 0) {
return 1;
}
}
@ -1510,7 +1478,6 @@ static void load_GL_ARB_robustness(GLADloadproc load) {
glad_glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC)load("glGetnMinmaxARB");
}
static void find_extensionsGL(void) {
get_exts();
GLAD_GL_EXT_separate_specular_color = has_ext("GL_EXT_separate_specular_color");
GLAD_GL_ARB_multisample = has_ext("GL_ARB_multisample");
GLAD_GL_ARB_robustness = has_ext("GL_ARB_robustness");
@ -1551,7 +1518,6 @@ static void find_coreGL(void) {
#endif
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_1 = (major == 1 && minor >= 1) || major > 1;
GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
@ -1563,10 +1529,6 @@ static void find_coreGL(void) {
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_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) {