|
|
commit f265ca2afc52c5b9fcd7494ac182278ad92f6939
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Tue Sep 13 18:41:18 2022 +0200
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Tue Sep 13 18:41:18 2022 +0200
Avoid deprecated glGetString(GL_EXTENSIONS) call when possible.
src/gl_draw.cxx | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git src/gl_draw.cxx src/gl_draw.cxx
index 1ec4798..3104f16 100644
--- src/gl_draw.cxx
+++ 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);
}
}
[ Direct Link to Message ] | |
|
| |