summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Fl_Gl_Device_Plugin.cxx28
-rw-r--r--src/Fl_Gl_Window.cxx199
-rw-r--r--src/fl_rect.cxx5
3 files changed, 33 insertions, 199 deletions
diff --git a/src/Fl_Gl_Device_Plugin.cxx b/src/Fl_Gl_Device_Plugin.cxx
index a7dfcd0a6..3ad9263ab 100644
--- a/src/Fl_Gl_Device_Plugin.cxx
+++ b/src/Fl_Gl_Device_Plugin.cxx
@@ -17,6 +17,7 @@
//
#include <config.h>
+#include "config_lib.h"
#include <FL/Fl_Printer.H>
#include <FL/Fl_Gl_Window.H>
#include "Fl_Gl_Choice.H"
@@ -29,6 +30,33 @@
#else
#endif
+
+// ------ this should be in a separate file! -----------------------------------
+#ifdef FL_CFG_GFX_OPENGL
+
+#include <FL/Fl_Device.H>
+#include <FL/gl.h>
+#include "src/cfg_gfx/opengl.H"
+
+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;
+};
+
+Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *graphics_driver)
+: Fl_Surface_Device(graphics_driver)
+{
+}
+
+const char *Fl_OpenGL_Display_Device::class_id = "Fl_OpenGL_Display_Device";
+
+#endif
+// ------ end of separate file! ------------------------------------------------
+
+#include "cfg_gfx/opengl_rect.cxx"
+
+
+
#if defined(__APPLE__)
uchar *convert_BGRA_to_RGB(uchar *baseAddress, int w, int h, int mByteWidth)
{
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 82b38fd14..9a8398a68 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -41,205 +41,6 @@ extern int fl_gl_load_plugin;
#endif
-// ------ this should be in a separate file! -----------------------------------
-#ifdef FL_CFG_GFX_OPENGL
-
-#include <FL/Fl_Device.H>
-#include <FL/gl.h>
-
-/**
- \brief OpenGL pecific graphics class.
- *
- This class is implemented only on the Mac OS X platform.
- */
-class FL_EXPORT Fl_OpenGL_Graphics_Driver : public Fl_Graphics_Driver {
-public:
- static const char *class_id;
- const char *class_name() {return class_id;};
- void draw(const char* str, int n, int x, int y) {
- gl_draw(str, n, x, y);
- }
- void color(Fl_Color c) {
- gl_color(c);
- }
- void color(uchar r, uchar g, uchar b) {
- unsigned int c = (r<<24)|(g<<16)|(b<<8);
- gl_color(c);
- }
- // --- implementation will eventually be in src/fl_rect.cxx which includes src/cfg_gfx/xlib_rect.cxx
- // --- line and polygon drawing with integer coordinates
- void point(int x, int y) {
- glBegin(GL_POINTS);
- glVertex2i(x, y);
- glEnd();
- }
- void rect(int x, int y, int w, int h) {
- glBegin(GL_LINE_LOOP);
- glVertex2i(x, y);
- glVertex2i(x+w, y);
- glVertex2i(x+w, y+h);
- glVertex2i(x, y+h);
- glEnd();
- }
- void rectf(int x, int y, int w, int h) {
- if (w<=0 || h<=0) return;
- // OpenGL has the natural origin at the bottom left. Drawing in FLTK
- // coordinates requires that we shift the rectangle one pixel up.
- glBegin(GL_POLYGON);
- glVertex2i(x, y-1);
- glVertex2i(x+w, y-1);
- glVertex2i(x+w, y+h-1);
- glVertex2i(x, y+h-1);
- glEnd();
- }
- void line(int x, int y, int x1, int y1) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x1, y1);
- glEnd();
- point(x1, y1);
- }
- void line(int x, int y, int x1, int y1, int x2, int y2) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x1, y1);
- glVertex2i(x2, y2);
- glEnd();
- point(x2, y2);
- }
- void xyline(int x, int y, int x1) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x1, y);
- glEnd();
- point(x1, y);
- }
- void xyline(int x, int y, int x1, int y2) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x1, y);
- glVertex2i(x1, y2);
- glEnd();
- point(x1, y2);
- }
- void xyline(int x, int y, int x1, int y2, int x3) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x1, y);
- glVertex2i(x1, y2);
- glVertex2i(x3, y2);
- glEnd();
- point(x3, y2);
- }
- void yxline(int x, int y, int y1) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x, y1);
- glEnd();
- point(x, y1);
- }
- void yxline(int x, int y, int y1, int x2) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x, y1);
- glVertex2i(x2, y1);
- glEnd();
- point(x2, y1);
- }
- void yxline(int x, int y, int y1, int x2, int y3) {
- glBegin(GL_LINE_STRIP);
- glVertex2i(x, y);
- glVertex2i(x, y1);
- glVertex2i(x2, y1);
- glVertex2i(x2, y3);
- glEnd();
- point(x2, y3);
- }
- void loop(int x0, int y0, int x1, int y1, int x2, int y2) {
- glBegin(GL_LINE_LOOP);
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
- glVertex2i(x2, y2);
- glEnd();
- }
- void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
- glBegin(GL_LINE_LOOP);
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
- glVertex2i(x2, y2);
- glVertex2i(x3, y3);
- glEnd();
- }
- void polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
- glBegin(GL_POLYGON);
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
- glVertex2i(x2, y2);
- glEnd();
- }
- void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
- glBegin(GL_POLYGON);
- glVertex2i(x0, y0);
- glVertex2i(x1, y1);
- glVertex2i(x2, y2);
- glVertex2i(x3, y3);
- glEnd();
- }
- void push_clip(int x, int y, int w, int h) {
- // TODO: implement OpenGL clipping
- if (rstackptr < region_stack_max) rstack[++rstackptr] = 0L;
- else Fl::warning("Fl_OpenGL_Graphics_Driver::push_clip: clip stack overflow!\n");
- }
- int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H) {
- // TODO: implement OpenGL clipping
- X = x; Y = y; W = w, H = h;
- return 0;
- }
- int not_clipped(int x, int y, int w, int h) {
- // TODO: implement OpenGL clipping
- return 1;
- }
- void push_no_clip() {
- // TODO: implement OpenGL clipping
- if (rstackptr < region_stack_max) rstack[++rstackptr] = 0;
- else Fl::warning("Fl_OpenGL_Graphics_Driver::push_no_clip: clip stack overflow!\n");
- restore_clip();
- }
- void pop_clip() {
- // TODO: implement OpenGL clipping
- if (rstackptr > 0) {
- rstackptr--;
- } else Fl::warning("Fl_OpenGL_Graphics_Driver::pop_clip: clip stack underflow!\n");
- restore_clip();
- }
- void restore_clip() {
- // TODO: implement OpenGL clipping
- fl_clip_state_number++;
- }
-};
-
-const char *Fl_OpenGL_Graphics_Driver::class_id = "Fl_OpenGL_Graphics_Driver";
-
-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;
-};
-
-
-Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *graphics_driver)
-: Fl_Surface_Device(graphics_driver)
-{
-}
-
-
-const char *Fl_OpenGL_Display_Device::class_id = "Fl_OpenGL_Display_Device";
-
-
-
-#endif
-// ------ end of separate file! ------------------------------------------------
-
-
////////////////////////////////////////////////////////////////
// The symbol SWAP_TYPE defines what is in the back buffer after doing
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index 060e2600c..5ad2c9e5e 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -50,6 +50,7 @@ void Fl_Graphics_Driver::restore_clip() {
fl_clip_state_number++;
}
+
void Fl_Graphics_Driver::clip_region(Fl_Region r) {
Fl_Region oldr = rstack[rstackptr];
if (oldr) XDestroyRegion(oldr);
@@ -57,6 +58,7 @@ void Fl_Graphics_Driver::clip_region(Fl_Region r) {
fl_restore_clip();
}
+
Fl_Region Fl_Graphics_Driver::clip_region() {
return rstack[rstackptr];
}
@@ -87,14 +89,17 @@ Fl_Region Fl_Graphics_Driver::clip_region() {
////////////////////////////////////////////////////////////////
+
#ifdef FL_CFG_GFX_QUARTZ
# include "cfg_gfx/quartz_rect.cxx"
#endif
+
// -----------------------------------------------------------------------------
+
#ifdef FL_CFG_GFX_GDI
// --- line and polygon drawing with integer coordinates