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
This commit is contained in:
parent
d31afde9d8
commit
502280c097
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user