diff options
| author | Manolo Gouy <Manolo> | 2013-05-19 12:34:31 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2013-05-19 12:34:31 +0000 |
| commit | 502280c09712eb22245ee2ad0bc3bec43457f59b (patch) | |
| tree | feea4483d6a88d181b7fbf3bdaa99ce8921c611b /src/Fl_Gl_Device_Plugin.cxx | |
| parent | d31afde9d89279c3f4b62e723a37ace158b433b5 (diff) | |
It doesn't seem necessary to redraw a GL window before capturing its pixel content.
Calling Fl_Gl_Window::make_current() is enough.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9921 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Device_Plugin.cxx')
| -rw-r--r-- | src/Fl_Gl_Device_Plugin.cxx | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/src/Fl_Gl_Device_Plugin.cxx b/src/Fl_Gl_Device_Plugin.cxx index 47d3ada7c..ca46d2759 100644 --- a/src/Fl_Gl_Device_Plugin.cxx +++ b/src/Fl_Gl_Device_Plugin.cxx @@ -34,34 +34,12 @@ static void imgProviderReleaseData (void *info, const void *data, size_t size) static void print_gl_window(Fl_Gl_Window *glw, int x, int y, int height) { -#ifdef WIN32 - HDC save_gc = fl_gc; - const int bytesperpixel = 3; -#elif defined(__APPLE__) - CGContextRef save_gc = fl_gc; +#if defined(__APPLE__) const int bytesperpixel = 4; #else - _XGC *save_gc = fl_gc; const int bytesperpixel = 3; #endif - Fl_Surface_Device *save_surface = Fl_Surface_Device::surface(); - Window save_window = fl_window; - fl_gc = NULL; - Fl_Display_Device::display_device()->set_current(); -#ifdef WIN32 - Fl::check(); - Fl_Window *win = (Fl_Window*)glw; - while( win->window() ) win = win->window(); - win->redraw(); - Fl::check(); - glw->make_current(); -#else glw->make_current(); - glw->redraw(); - glFlush(); - Fl::check(); - glFinish(); -#endif // Read OpenGL context pixels directly. // For extra safety, save & restore OpenGL states that are changed glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); @@ -74,18 +52,13 @@ static void print_gl_window(Fl_Gl_Window *glw, int x, int y, int height) mByteWidth = (mByteWidth + 3) & ~3; // Align to 4 bytes uchar *baseAddress = (uchar*)malloc(mByteWidth * glw->h()); glReadPixels(0, 0, glw->w(), glw->h(), -#ifdef WIN32 - GL_RGB, GL_UNSIGNED_BYTE, -#elif defined(__APPLE__) +#if defined(__APPLE__) GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, -#else // FIXME Linux/Unix +#else GL_RGB, GL_UNSIGNED_BYTE, #endif baseAddress); glPopClientAttrib(); - save_surface->Fl_Surface_Device::set_current(); - fl_window = save_window; - fl_gc = save_gc; #if defined(__APPLE__) // kCGBitmapByteOrder32Host and CGBitmapInfo are supposed to arrive with 10.4 // but some 10.4 don't have kCGBitmapByteOrder32Host, so we play a little #define game |
