diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-08-18 08:53:19 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-08-18 08:53:19 +0200 |
| commit | f927a3047c84be70387c0292f93d02aeb357f304 (patch) | |
| tree | 3cdd070744d000a2fd68ac39557797436abd9e4d /src/drivers | |
| parent | 5227ee09a3fdd7d555f56cf7c9053dc42638d6cb (diff) | |
Simplify class Fl_OpenGL_Display_Device.
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/OpenGL/Fl_OpenGL_Display_Device.H | 5 | ||||
| -rw-r--r-- | src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx | 61 |
2 files changed, 2 insertions, 64 deletions
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Display_Device.H b/src/drivers/OpenGL/Fl_OpenGL_Display_Device.H index 8e6d1c8bb..2245ee938 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Display_Device.H +++ b/src/drivers/OpenGL/Fl_OpenGL_Display_Device.H @@ -1,7 +1,7 @@ // // Definition of class Fl_OpenGL_Display_Device for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2016 by Bill Spitzak and others. +// Copyright 2010-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -17,8 +17,6 @@ #include <FL/Fl_Device.H> class Fl_OpenGL_Graphics_Driver; -class Fl_Gl_Window; -class Fl_RGB_Image; /** OpenGL Surface. @@ -28,5 +26,4 @@ class FL_EXPORT Fl_OpenGL_Display_Device : public Fl_Surface_Device { Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *graphics_driver); public: static Fl_OpenGL_Display_Device *display_device(); - static Fl_RGB_Image* capture_gl_rectangle(Fl_Gl_Window*, int, int, int, int); }; diff --git a/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx b/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx index 1d0b25ccf..007408a15 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx @@ -1,7 +1,7 @@ // // implementation of class Fl_OpenGL_Display_Device for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2017 by Bill Spitzak and others. +// Copyright 2010-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -14,20 +14,9 @@ // https://www.fltk.org/bugs.php // -#include <config.h> -#include <FL/Fl_Gl_Window.H> -#include "../../Fl_Gl_Window_Driver.H" -#include <FL/Fl_Image.H> -#include "../../Fl_Screen_Driver.H" -#include "../../Fl_Window_Driver.H" -#include <FL/gl.h> -#include <string.h> - #include "Fl_OpenGL_Graphics_Driver.H" #include "Fl_OpenGL_Display_Device.H" -// TODO: much of Fl_Gl_Choice should probably go here - Fl_OpenGL_Display_Device *Fl_OpenGL_Display_Device::display_device() { static Fl_OpenGL_Display_Device *display = new Fl_OpenGL_Display_Device(new Fl_OpenGL_Graphics_Driver()); return display; @@ -37,51 +26,3 @@ Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *gr : Fl_Surface_Device(graphics_driver) { } - -Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw, int x, int y, int w, int h) -{ - return Fl_Gl_Window_Driver::driver(glw)->capture_gl_rectangle(x, y, w, h); -} - -/* Captures a rectangle of a Fl_Gl_Window and returns it as a RGB image. - This is the platform-independent version. Some platforms may re-implement it. - */ -Fl_RGB_Image* Fl_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int w, int h) -{ - Fl_Gl_Window *glw = pWindow; - glw->flush(); // forces a GL redraw, necessary for the glpuzzle demo - // Read OpenGL context pixels directly. - // For extra safety, save & restore OpenGL states that are changed - glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); - glPixelStorei(GL_PACK_ALIGNMENT, 4); /* Force 4-byte alignment */ - glPixelStorei(GL_PACK_ROW_LENGTH, 0); - glPixelStorei(GL_PACK_SKIP_ROWS, 0); - glPixelStorei(GL_PACK_SKIP_PIXELS, 0); - // - float s = glw->pixels_per_unit(); - if (s != 1) { - x = int(x * s); y = int(y * s); w = int(w * s); h = int(h * s); - } - // Read a block of pixels from the frame buffer - int mByteWidth = w * 3; - mByteWidth = (mByteWidth + 3) & ~3; // Align to 4 bytes - uchar *baseAddress = new uchar[mByteWidth * h]; - glReadPixels(x, glw->pixel_h() - (y+h), w, h, - GL_RGB, GL_UNSIGNED_BYTE, - baseAddress); - glPopClientAttrib(); - // GL gives a bottom-to-top image, convert it to top-to-bottom - uchar *tmp = new uchar[mByteWidth]; - uchar *p = baseAddress ; - uchar *q = baseAddress + (h-1)*mByteWidth; - for (int i = 0; i < h/2; i++, p += mByteWidth, q -= mByteWidth) { - memcpy(tmp, p, mByteWidth); - memcpy(p, q, mByteWidth); - memcpy(q, tmp, mByteWidth); - } - delete[] tmp; - - Fl_RGB_Image *img = new Fl_RGB_Image(baseAddress, w, h, 3, mByteWidth); - img->alloc_array = 1; - return img; -} |
