Skip to content

Commit

Permalink
c: fixed #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Jul 5, 2015
1 parent c7d2753 commit 4a5e79c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions glad/lang/c/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def generate_loader(self, features, extensions):
for feature in features[api]:
f.write('\tGLAD_{} = (major == {num[0]} && minor >= {num[1]}) ||'
' major > {num[0]};\n'.format(feature.name, num=feature.number))
if api == 'gl':
f.write('\tif (GLVersion.major > {0} || (GLVersion.major >= {0} && GLVersion.minor >= {1})) {{\n'.format(version[0], version[1]))
f.write('\t\tmax_loaded_major = {0};\n'.format(version[0]))
f.write('\t\tmax_loaded_minor = {0};\n'.format(version[1]))
f.write('\t}\n')
f.write('}\n\n')

if api == 'glx':
Expand Down
11 changes: 9 additions & 2 deletions glad/lang/c/loader/gl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
#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(GLVersion.major < 3) {
if(max_loaded_major < 3) {
#endif
exts = (const char *)glGetString(GL_EXTENSIONS);
#ifdef _GLAD_IS_SOME_NEW_VERSION
Expand All @@ -52,7 +55,7 @@
static int has_ext(const char *ext) {
#ifdef _GLAD_IS_SOME_NEW_VERSION
if(GLVersion.major < 3) {
if(max_loaded_major < 3) {
#endif
const char *extensions;
const char *loc;
Expand Down Expand Up @@ -177,6 +180,7 @@
#endif
GLVersion.major = major; GLVersion.minor = minor;
max_loaded_major = major; max_loaded_minor = minor;
'''


Expand All @@ -197,6 +201,9 @@ def write_end_load(self, fobj):
def write_find_core(self, fobj):
fobj.write(_FIND_VERSION)

def write_find_core_end(self, fobj):
fobj.write(_FIND_VERSION)

def write_has_ext(self, fobj):
fobj.write(_OPENGL_HAS_EXT)

Expand Down

0 comments on commit 4a5e79c

Please sign in to comment.