FLTK logo

[master] 0627213 - FLTK widgets in OpenGL 3 windows: rewrite for driver system.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 0627213 - FLTK widgets in OpenGL 3 windows: rewrite for driver system. "ManoloFLTK" Sep 30, 2022  
 
commit 0627213a824388321b8b39ff2476f5dc04f56638
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Sep 30 19:25:23 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Sep 30 19:25:23 2022 +0200

    FLTK widgets in OpenGL 3 windows: rewrite for driver system.

 src/Fl_Gl_Choice.cxx                              |  9 +--------
 src/Fl_Gl_Window_Driver.H                         |  3 +--
 src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H   |  2 ++
 src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx | 20 ++++++++++++++++++++
 4 files changed, 24 insertions(+), 10 deletions(-)

diff --git src/Fl_Gl_Choice.cxx src/Fl_Gl_Choice.cxx
index f67ce0a..5c77e97 100644
--- src/Fl_Gl_Choice.cxx
+++ src/Fl_Gl_Choice.cxx
@@ -33,14 +33,7 @@
 #  define GL_CURRENT_PROGRAM 0x8B8D
 #endif
 
-// TODO: remove that from this platform-independent source file
-#ifdef _WIN32
-#  include <windows.h> // for WINAPI
-#else
-#  define WINAPI
-#endif
-
-typedef void (WINAPI *glUseProgram_type)(GLint);
+typedef void (*glUseProgram_type)(GLint);
 static glUseProgram_type glUseProgram_f = NULL;
 
 GLContext *Fl_Gl_Window_Driver::context_list = 0;
diff --git src/Fl_Gl_Window_Driver.H src/Fl_Gl_Window_Driver.H
index 5c44a8c..0580e52 100644
--- src/Fl_Gl_Window_Driver.H
+++ src/Fl_Gl_Window_Driver.H
@@ -34,9 +34,8 @@ class Fl_Font_Descriptor;
  platform-specific derived class from this class.
  */
 class Fl_Gl_Window_Driver {
-private:
-  GLint current_prog;
 protected:
+  GLint current_prog;
   Fl_Gl_Window *pWindow;
 public:
   static GLContext cached_context;
diff --git src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H
index 3b09c73..2de50eb 100644
--- src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H
+++ src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H
@@ -51,6 +51,8 @@ class Fl_WinAPI_Gl_Window_Driver : public Fl_Gl_Window_Driver {
   virtual void gl_bitmap_font(Fl_Font_Descriptor *fl_fontsize);
   virtual void get_list(Fl_Font_Descriptor *fd, int r);
   virtual int genlistsize();
+  virtual void switch_to_GL1();
+  virtual void switch_back();
 #if HAVE_GL_OVERLAY
   virtual void gl_hide_before(void *& overlay);
   virtual int can_do_overlay();
diff --git src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx
index 7952dfd..ca72d3e 100644
--- src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx
+++ src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx
@@ -25,6 +25,10 @@
 #include "../GDI/Fl_Font.H"
 extern void fl_save_dc(HWND, HDC);
 
+#ifndef GL_CURRENT_PROGRAM
+#  define GL_CURRENT_PROGRAM 0x8B8D // from glew.h
+#endif
+
 // STR #3119: select pixel format with composition support
 // ... and no more than 32 color bits (8 bits/color)
 // Ref: PixelFormatDescriptor Object
@@ -368,6 +372,22 @@ void Fl_WinAPI_Gl_Window_Driver::get_list(Fl_Font_Descriptor *fd, int r) {
 }
 
 
+typedef void (WINAPI *glUseProgram_type)(GLint);
+static glUseProgram_type glUseProgram_f = NULL;
+
+void Fl_WinAPI_Gl_Window_Driver::switch_to_GL1() {
+  if (!glUseProgram_f) {
+    glUseProgram_f = (glUseProgram_type)GetProcAddress("glUseProgram");
+  }
+  glGetIntegerv(GL_CURRENT_PROGRAM, &current_prog);
+  if (current_prog) glUseProgram_f(0);
+}
+
+void Fl_WinAPI_Gl_Window_Driver::switch_back() {
+  if (current_prog) glUseProgram_f((GLuint)current_prog);
+}
+
+
 FL_EXPORT HGLRC fl_win32_glcontext(GLContext rc) { return (HGLRC)rc; }
 
 #endif // HAVE_GL
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.