diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-27 14:12:39 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-27 14:12:39 +0200 |
| commit | 59fc60ea4cb8db6ee43a1ac37cd4bbbefcb87faa (patch) | |
| tree | 072de9da3e8f6c0b69f0872320ff7ad117e6aee9 /src/Fl_Gl_Choice.cxx | |
| parent | 2ffd4e4f1af16b17a286ff354603a717f5d828a5 (diff) | |
Simpler code to support FLTK widgets in macOS OpenGL 3 windows.
Also, the application-level code to add widgets to a GL3 window becomes
platform-independent.
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: |
