summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Device.cxx11
-rw-r--r--src/Fl_Gl_Printer.cxx22
2 files changed, 32 insertions, 1 deletions
diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx
index 03e8367ac..642ddd22b 100644
--- a/src/Fl_Device.cxx
+++ b/src/Fl_Device.cxx
@@ -52,7 +52,16 @@ void Fl_Virtual_Printer::print_widget(Fl_Widget* widget, int delta_x, int delta_
#else
_XGC *save_gc = fl_gc; // FIXME
#endif
- widget->draw();
+ // we do some trickery to recognize OpenGL windows and draw them via a plugin
+ int drawn_by_plugin = 0;
+ if (widget->as_gl_window()) {
+ Fl_Plugin_Manager pm("fltk:device");
+ Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
+ if (pi) drawn_by_plugin = pi->print(this, widget, 0, 0);
+ }
+ if (!drawn_by_plugin)
+ widget->draw();
+
fl_gc = save_gc;
if (is_window) fl_pop_clip();
// find subwindows of widget and print them
diff --git a/src/Fl_Gl_Printer.cxx b/src/Fl_Gl_Printer.cxx
index 233327913..ac1892dde 100644
--- a/src/Fl_Gl_Printer.cxx
+++ b/src/Fl_Gl_Printer.cxx
@@ -89,3 +89,25 @@ void Fl_Gl_Printer::print_gl_window(Fl_Gl_Window *glw, int x, int y)
free(baseAddress);
#endif // __APPLE__
}
+
+/*
+ This class will make sure that OpenGL printing is availbale if fltk_gl
+ was linked to the programm.
+ */
+class Fl_Gl_Device_Plugin : public Fl_Device_Plugin {
+public:
+ Fl_Gl_Device_Plugin() : Fl_Device_Plugin(name()) { }
+ virtual const char *name() { return "opengl.device.fltk.org"; }
+ virtual int print(Fl_Virtual_Printer *p, Fl_Widget *w, int x, int y) {
+ Fl_Gl_Window *glw = w->as_gl_window();
+ if (!glw) return 0;
+ // FIXME: this is a dangerous cast! Remove Fl_Gl_Printer entirely and add
+ // FIXME: a static function (may be a friend of Fl_Printer).
+ Fl_Gl_Printer *glp = (Fl_Gl_Printer*)p;
+ glp->print_gl_window(glw, x, y);
+ return 1;
+ }
+};
+
+static Fl_Gl_Device_Plugin Gl_Device_Plugin;
+