|
|
On 4/29/21 10:47 AM ManoloFLTK wrote:
commit 9df287b415cd4d67a7a371c4cc89a11ebb8340f6
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu Apr 29 10:40:02 2021 +0200
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu Apr 29 10:40:18 2021 +0200
Cleaner access to Fl_Gl_Window_Driver objects.
...
diff --git src/Fl_Gl_Window_Driver.H src/Fl_Gl_Window_Driver.H
index bebde10..ae2c66f 100644
--- src/Fl_Gl_Window_Driver.H
+++ src/Fl_Gl_Window_Driver.H
@@ -100,6 +100,7 @@ public:
virtual int genlistsize() { return 0; } // support for gl_draw()
virtual Fl_Font_Descriptor** fontnum_to_fontdescriptor(int fnum);
virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h);
+ static inline Fl_Gl_Window_Driver* driver(const Fl_Gl_Window *win) {return win->pGlWindowDriver;}
};
...
#endif /* Fl_Gl_Window_Driver_H */
diff --git src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
index 121c0db..1d0b25c 100644
--- src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
+++ src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
@@ -40,7 +40,7 @@ Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *gr
Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw, int x, int y, int w, int h)
{
- return glw->gl_driver()->capture_gl_rectangle(x, y, w, h);
+ return Fl_Gl_Window_Driver::driver(glw)->capture_gl_rectangle(x, y, w, h);
}
/* Captures a rectangle of a Fl_Gl_Window and returns it as a RGB image.
diff --git src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
index a52d4c7..ac7041f 100644
--- src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
+++ src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
@@ -430,7 +430,7 @@ void _Fl_Gl_Overlay::draw() {
uchar save_valid = w->valid();
w->valid(valid());
Fl_Xlib_Graphics_Driver::fl_overlay = 1;
- w->gl_driver()->draw_overlay();
+ Fl_Gl_Window_Driver::driver(w)->draw_overlay();
Fl_Xlib_Graphics_Driver::fl_overlay = 0;
valid(w->valid());
w->valid(save_valid);
Manolo, many thanks for all your continuous work on the driver
stuff.
Here I'm wondering if it's "a good idea" to add that static method
to return the driver.
My second question is if we really need 'capture_gl_rectangle()'
rather than having a 'virtual capture_rectangle()' method
that automatically does "the right thing"?
What about using the Fl_Window object to do the stuff we need to do,
maybe with functions like these:
(1) virtual Fl_RGB_Image * Fl_Window::capture_rectangle(x, y, w, h);
This method would have (virtual) reimplementations in all subclasses and work with Fl_Gl_Window as well.
(2) virtual Fl_Window::draw_overlay();
This method would do nothing for normal windows but would have
(virtual) reimplementations in all subclasses that need it. Maybe it
could only be defined for classes that require it (not in the base
Fl_Window class).
With such methods the driver stuff would be even more hidden and the
virtual methods could do what we need.
Sorry if I'm not seeing the whole picture (I didn't investigate the
relevant code parts), it's more a gut feeling in the sense: this must
be easier to achieve...
Looking forward to your thoughts and explanations...
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/20e9e3fa-1684-1398-e6d8-b6487c6b67f3%40online.de.
[ Direct Link to Message ] | |
|
| |