diff options
Diffstat (limited to 'src/Fl_Gl_Choice.cxx')
| -rw-r--r-- | src/Fl_Gl_Choice.cxx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index f0ddda652..bafab56fd 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -28,7 +28,10 @@ #include "Fl_Gl_Window_Driver.H" #include <FL/gl_draw.H> #include <stdlib.h> - +#ifndef GL_CURRENT_PROGRAM +// from glew.h in Windows, glext.h in Unix, not used by FLTK's macOS platform +# define GL_CURRENT_PROGRAM 0x8B8D +#endif GLContext *Fl_Gl_Window_Driver::context_list = 0; int Fl_Gl_Window_Driver::nContext = 0; static int NContext = 0; @@ -57,6 +60,23 @@ void Fl_Gl_Window_Driver::del_context(GLContext ctx) { if (!nContext) gl_remove_displaylist_fonts(); } +Fl_Gl_Window_Driver::glUseProgram_type Fl_Gl_Window_Driver::glUseProgram_f = NULL; + +void Fl_Gl_Window_Driver::switch_to_GL1() { + if (!glUseProgram_f) { + glUseProgram_f = (glUseProgram_type)GetProcAddress("glUseProgram"); + } + glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_prog); + // Switch from GL3-style to GL1-style drawing; + // good under Windows, X11 and Wayland; not appropriate under macOS. + // suggested by https://stackoverflow.com/questions/22293870/mixing-fixed-function-pipeline-and-programmable-pipeline-in-opengl + if (current_prog) glUseProgram_f(0); +} + +void Fl_Gl_Window_Driver::switch_back() { + if (current_prog) glUseProgram_f((GLuint)current_prog); +} + Fl_Gl_Choice *Fl_Gl_Window_Driver::first; // this assumes one of the two arguments is zero: |
