FLTK logo

[master] 6732044 - Fix use of several FLTK widgets above an GL scene. The code failed with 2 or more widgets when FLTK would trigger partial redraws of the widgets, unless the Fl_Gl_Window was FL_DAMAGE_ALL.

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] 6732044 - Fix use of several FLTK widgets above an GL scene. The code failed with 2 or more widgets when FLTK would trigger partial redraws of the widgets, unless the Fl_Gl_Window was FL_DAMAGE_ALL. "ManoloFLTK" Oct 05, 2022  
 
commit 6732044a0789d45b5daa5a376474ca832db44ddb
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu Oct 6 08:43:09 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu Oct 6 08:43:09 2022 +0200

    Fix use of several FLTK widgets above an GL scene.
    The code failed with 2 or more widgets when FLTK would trigger
    partial redraws of the widgets, unless the Fl_Gl_Window was FL_DAMAGE_ALL.
    
    This commit also adds a second FLTK widget to example/OpenGL3test to
    check this multiple widget situation, and fixes an error where operator ! was used
    instead of ~ .

 examples/OpenGL3test.cxx | 14 +++++++++-----
 src/Fl_Gl_Window.cxx     |  1 +
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git examples/OpenGL3test.cxx examples/OpenGL3test.cxx
index d9216c4..441571f 100644
--- examples/OpenGL3test.cxx
+++ examples/OpenGL3test.cxx
@@ -163,7 +163,7 @@ public:
         add_output("\nThis platform does not support OpenGL V3 :\n"
                    "FLTK widgets will appear but the programmed "
                    "rendering pipeline will not run.\n");
-        mode(mode() & !FL_OPENGL3);
+        mode(mode() & ~FL_OPENGL3);
       }
       redraw();
     }
@@ -230,18 +230,22 @@ void add_output(const char *format, ...)
 }
 
 
-void button_cb(Fl_Widget *, void *) {
-  add_output("run button callback\n");
+void button_cb(Fl_Widget *widget, void *) {
+  add_output("run %s callback\n", widget->label());
 }
 
 void add_widgets(Fl_Gl_Window *g) {
   Fl::set_color(FL_FREE_COLOR, 255, 255, 255, 140); // partially transparent white
   g->begin();
   // Create here widgets to go above the GL3 scene
-  Fl_Button* b = new Fl_Button( 0, 170, 60, 30, "button");
+  Fl_Button* b = new Fl_Button( 0, 0, 60, 30, "button");
   b->color(FL_FREE_COLOR);
-  b->box(FL_BORDER_BOX );
+  b->box(FL_DOWN_BOX );
   b->callback(button_cb, NULL);
+  Fl_Button* b2 = new Fl_Button( 0, 170, 60, 30, "button2");
+  b2->color(FL_FREE_COLOR);
+  b2->box(FL_BORDER_BOX );
+  b2->callback(button_cb, NULL);
   g->end();
 }
 
diff --git src/Fl_Gl_Window.cxx src/Fl_Gl_Window.cxx
index 4bd4397..ae1e66b 100644
--- src/Fl_Gl_Window.cxx
+++ src/Fl_Gl_Window.cxx
@@ -344,6 +344,7 @@ void Fl_Gl_Window::draw_overlay() {}
  */
 void Fl_Gl_Window::draw_begin() {
   if (mode() & FL_OPENGL3) pGlWindowDriver->switch_to_GL1();
+  damage(FL_DAMAGE_ALL); // always redraw all GL widgets above the GL scene
   Fl_Surface_Device::push_current( Fl_OpenGL_Display_Device::display_device() );
   Fl_OpenGL_Graphics_Driver *drv = (Fl_OpenGL_Graphics_Driver*)Fl_Surface_Device::surface()->driver();
   drv->pixels_per_unit_ = pixels_per_unit();
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'.