diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-03-16 22:51:31 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-03-16 22:51:31 +0000 |
| commit | 762d02fb6207c40e3c0e2ff8a9d41a510094f9c0 (patch) | |
| tree | 75d1ebfaded516aaaf7c972090a5b408c6b11638 /src/Fl_Gl_Printer.cxx | |
| parent | 1b6e7bd81272849f89b6e1c34b41de0b7d67c7f5 (diff) | |
Using Fl_Plugin feature to automatically draw OpenGL (sub)windows. No extra coding needs to be done. Just call Fl_Printer::print_widget(...). The Fl_Gl_Printer device can (and should) be removed or at least made inaccessible.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7280 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Printer.cxx')
| -rw-r--r-- | src/Fl_Gl_Printer.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
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; + |
