MacOS: have Fl_OpenGL_Display_Device::capture_gl_rectangle() capture also the overlay of GL windows.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12938 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
8ef4035b6d
commit
f3971319b9
@ -59,7 +59,6 @@ public:
|
||||
virtual void swap_buffers() {}
|
||||
virtual void resize(int is_a_resize, int w, int h) {}
|
||||
virtual char swap_type();
|
||||
virtual void flush_context() {}
|
||||
virtual int flush_begin(char& valid_f) {return 0;}
|
||||
virtual void hide_overlay(void *& overlay) {}
|
||||
static Fl_Gl_Choice *find_begin(int m, const int *alistp);
|
||||
@ -101,6 +100,7 @@ class NSOpenGLPixelFormat;
|
||||
|
||||
class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
||||
friend class Fl_Gl_Window_Driver;
|
||||
friend class Fl_OpenGL_Display_Device;
|
||||
Fl_Cocoa_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
|
||||
virtual float pixels_per_unit();
|
||||
virtual void before_show(int& need_redraw);
|
||||
@ -110,7 +110,7 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
||||
virtual void swap_buffers();
|
||||
virtual void resize(int is_a_resize, int w, int h);
|
||||
virtual char swap_type();
|
||||
virtual void flush_context();
|
||||
void flush_context();
|
||||
virtual Fl_Gl_Choice *find(int m, const int *alistp);
|
||||
virtual GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer = 0);
|
||||
virtual void set_gl_context(Fl_Window* w, GLContext context);
|
||||
|
@ -238,7 +238,6 @@ void Fl_Gl_Window::flush() {
|
||||
}
|
||||
|
||||
}
|
||||
pGlWindowDriver->flush_context();
|
||||
if (overlay==this && SWAP_TYPE != SWAP) { // fake overlay in front buffer
|
||||
glDrawBuffer(GL_FRONT);
|
||||
draw_overlay();
|
||||
@ -588,10 +587,8 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() {
|
||||
glMatrixMode(matrixmode);
|
||||
glRasterPos3f(pos[0], pos[1], pos[2]); // restore original glRasterPos
|
||||
}
|
||||
/* // nothing to do here under Cocoa because [NSOpenGLContext -flushBuffer] done later replaces it
|
||||
else
|
||||
aglSwapBuffers((AGLContext)context_);
|
||||
*/
|
||||
flush_context();//aglSwapBuffers((AGLContext)context_);
|
||||
}
|
||||
|
||||
void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int unused, int also) {
|
||||
|
@ -38,6 +38,7 @@ Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *gr
|
||||
}
|
||||
|
||||
#ifdef FL_CFG_GFX_QUARTZ
|
||||
#include <FL/Fl_Gl_Window_Driver.H>
|
||||
|
||||
// convert BGRA to RGB and also exchange top and bottom
|
||||
static uchar *convert_BGRA_to_RGB(uchar *baseAddress, int w, int h, int mByteWidth)
|
||||
@ -67,7 +68,8 @@ Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw,
|
||||
if (factor != 1) {
|
||||
w *= factor; h *= factor; x *= factor; y *= factor;
|
||||
}
|
||||
glw->flush(); // forces a GL redraw, necessary for the glpuzzle demo
|
||||
Fl_Cocoa_Gl_Window_Driver *driver = (Fl_Cocoa_Gl_Window_Driver*)glw->gl_driver();
|
||||
driver->flush_context(); // to capture also the overlay and for directGL demo
|
||||
// Read OpenGL context pixels directly.
|
||||
// For extra safety, save & restore OpenGL states that are changed
|
||||
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
||||
@ -85,6 +87,7 @@ Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw,
|
||||
baseAddress = convert_BGRA_to_RGB(baseAddress, w, h, mByteWidth);
|
||||
Fl_RGB_Image *img = new Fl_RGB_Image(baseAddress, w, h, 3, 3 * w);
|
||||
img->alloc_array = 1;
|
||||
driver->flush_context();
|
||||
return img;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user