New static member function: Fl_Device_Plugin *Fl_Device_Plugin::opengl_plugin()
This commit is contained in:
parent
fb4cb71655
commit
3bcb1256bb
@ -126,6 +126,8 @@ public:
|
||||
virtual Fl_RGB_Image* rectangle_capture(Fl_Widget *widget, int x, int y, int w, int h) = 0;
|
||||
/** Returns the window's GL context */
|
||||
virtual GLContext context(Fl_Widget *widget) = 0;
|
||||
/** Returns the OpenGL plugin */
|
||||
static Fl_Device_Plugin *opengl_plugin();
|
||||
};
|
||||
|
||||
#endif // Fl_Device_H
|
||||
|
||||
@ -122,6 +122,15 @@ Fl_Surface_Device *Fl_Surface_Device::pop_current()
|
||||
return surface_;
|
||||
}
|
||||
|
||||
Fl_Device_Plugin *Fl_Device_Plugin::opengl_plugin() {
|
||||
static Fl_Device_Plugin *pi = NULL;
|
||||
if (!pi) {
|
||||
Fl_Plugin_Manager pm("fltk:device");
|
||||
pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
|
||||
}
|
||||
return pi;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
||||
@ -192,8 +192,7 @@ Fl_RGB_Image *Fl_Screen_Driver::traverse_to_gl_subwindows(Fl_Group *g, int x, in
|
||||
Fl_RGB_Image *full_img)
|
||||
{
|
||||
if ( g->as_gl_window() ) {
|
||||
Fl_Plugin_Manager pm("fltk:device");
|
||||
Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
|
||||
Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin();
|
||||
if (!pi) return full_img;
|
||||
full_img = pi->rectangle_capture(g, x, y, w, h);
|
||||
}
|
||||
|
||||
@ -68,8 +68,7 @@ void Fl_Widget_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y)
|
||||
// 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");
|
||||
Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin();
|
||||
if (pi) {
|
||||
drawn_by_plugin = pi->print(widget);
|
||||
}
|
||||
|
||||
@ -147,15 +147,6 @@ static TISCreateASCIICapableInputSourceList_type TISCreateASCIICapableInputSourc
|
||||
typedef void (*KeyScript_type)(short);
|
||||
static KeyScript_type KeyScript;
|
||||
|
||||
static Fl_Device_Plugin *opengl_plugin_device() {
|
||||
static Fl_Device_Plugin *pi = NULL;
|
||||
if (!pi) {
|
||||
Fl_Plugin_Manager pm("fltk:device");
|
||||
pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
|
||||
}
|
||||
return pi;
|
||||
}
|
||||
|
||||
/* fltk-utf8 placekeepers */
|
||||
void fl_set_status(int x, int y, int w, int h)
|
||||
{
|
||||
@ -2212,7 +2203,7 @@ static CGContextRef prepare_bitmap_for_layer(int w, int h ) {
|
||||
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(window);
|
||||
[self did_view_resolution_change];
|
||||
if (d->wait_for_expose_value) { // 1st drawing of layer-backed GL window
|
||||
Fl_Device_Plugin *pi = opengl_plugin_device();
|
||||
Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin();
|
||||
if (pi) {
|
||||
[pi->context(window) update]; // layer-backed GL windows may be empty without this
|
||||
}
|
||||
@ -4253,7 +4244,7 @@ static NSBitmapImageRep* GL_rect_to_nsbitmap(Fl_Window *win, int x, int y, int w
|
||||
// captures a rectangle from a GL window and returns it as an allocated NSBitmapImageRep
|
||||
// the capture has high res on retina
|
||||
{
|
||||
Fl_Device_Plugin *pi = opengl_plugin_device();
|
||||
Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin();
|
||||
if (!pi) return nil;
|
||||
Fl_RGB_Image *img = pi->rectangle_capture(win, x, y, w, h);
|
||||
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:img->w() pixelsHigh:img->h() bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:4*img->w() bitsPerPixel:32];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user