diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-13 18:41:18 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-13 18:41:18 +0200 |
| commit | f265ca2afc52c5b9fcd7494ac182278ad92f6939 (patch) | |
| tree | 1699113da358e642808760e27bea0c7c8e443cc7 | |
| parent | e43c2f566dc956108ace21e8669da198dd92b4dd (diff) | |
Avoid deprecated glGetString(GL_EXTENSIONS) call when possible.
| -rw-r--r-- | src/gl_draw.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 1ec4798bf..3104f161d 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -74,13 +74,21 @@ void gl_font(int fontid, int size) { if (once) { once = false; if (Fl::draw_GL_text_with_textures()) { - // For the font texture pile to work, we need a texture rectangle extension, so check for - // one here. First we check for GL_EXT_texture_rectangle and if that fails we try - // for GL_ARB_texture_rectangle instead. If that also fails, we fall back to the - // legacy methods used by fltk-1.3 and earlier. - has_texture_rectangle = (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_rectangle") != NULL); - if (!has_texture_rectangle) has_texture_rectangle = - (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_ARB_texture_rectangle") != NULL); + int gl_version_major; + sscanf((const char *)glGetString(GL_VERSION), "%d", &gl_version_major); + //printf("gl_version_major=%d\n", gl_version_major); + if (gl_version_major >= 3) { + has_texture_rectangle = true; + } else { + const char *extensions = (const char*)glGetString(GL_EXTENSIONS); + if (extensions) { + // For the font texture pile to work, we need a texture rectangle extension, so check for + // one here. First we check for GL_EXT_texture_rectangle and if that fails we try + // for GL_ARB_texture_rectangle instead. If that also fails, we fall back to the + // legacy methods used by fltk-1.3 and earlier. + has_texture_rectangle = (strstr(extensions, "GL_EXT_texture_rectangle") != NULL || strstr(extensions, "GL_ARB_texture_rectangle") != NULL); + } + } Fl::draw_GL_text_with_textures(has_texture_rectangle); } } |
