summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2016-01-26 20:48:21 +0000
committerMatthias Melcher <fltk@matthiasm.com>2016-01-26 20:48:21 +0000
commit2b3567c83ca18b5dad62be7f10cc71446c028164 (patch)
treefa3e3151c1bf84673d8a3632025895efa01b2da4 /src/drivers
parent222538baad665f226546c2cfae417df3f6835a44 (diff)
OpenGL new naming scheme.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11055 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.h101
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx70
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_color.cxx70
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx151
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx70
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx209
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx142
7 files changed, 813 insertions, 0 deletions
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.h b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.h
new file mode 100644
index 000000000..48944fcb8
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.h
@@ -0,0 +1,101 @@
+//
+// "$Id$"
+//
+// Definition of OpenGL graphics driver
+// for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2016 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+/**
+ \file opengl.H
+ \brief Definition of OpenGL graphics driver.
+ */
+
+#ifndef FL_CFG_GFX_OPENGL_H
+#define FL_CFG_GFX_OPENGL_H
+
+#include <FL/Fl_Device.H>
+
+
+/**
+ \brief OpenGL specific graphics class.
+ */
+class FL_EXPORT Fl_OpenGL_Graphics_Driver : public Fl_Graphics_Driver {
+public:
+ static const char *class_id;
+ const char *class_name() {return class_id;};
+ // --- line and polygon drawing with integer coordinates
+ void point(int x, int y);
+ void rect(int x, int y, int w, int h);
+ void rectf(int x, int y, int w, int h);
+ void line(int x, int y, int x1, int y1);
+ void line(int x, int y, int x1, int y1, int x2, int y2);
+ void xyline(int x, int y, int x1);
+ void xyline(int x, int y, int x1, int y2);
+ void xyline(int x, int y, int x1, int y2, int x3);
+ void yxline(int x, int y, int y1);
+ void yxline(int x, int y, int y1, int x2);
+ void yxline(int x, int y, int y1, int x2, int y3);
+ void loop(int x0, int y0, int x1, int y1, int x2, int y2);
+ void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
+ void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
+ void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
+ void push_clip(int x, int y, int w, int h);
+ int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
+ int not_clipped(int x, int y, int w, int h);
+ void push_no_clip();
+ void pop_clip();
+ void restore_clip();
+ // --- implementation is in src/fl_vertex.cxx which includes src/cfg_gfx/xxx_rect.cxx
+ void transformed_vertex0(COORD_T x, COORD_T y);
+ void transformed_vertex(double xf, double yf);
+ void vertex(double x, double y);
+ void begin_points();
+ void end_points();
+ void begin_line();
+ void end_line();
+ void begin_loop();
+ void end_loop();
+ void begin_polygon();
+ void end_polygon();
+ void begin_complex_polygon();
+ void gap();
+ void end_complex_polygon();
+ void fixloop();
+ void circle(double x, double y, double r);
+ // --- implementation is in src/fl_arc.cxx which includes src/cfg_gfx/xxx_arc.cxx if needed
+ // using void Fl_Graphics_Driver::arc(double x, double y, double r, double start, double end);
+ // --- implementation is in src/fl_arci.cxx which includes src/cfg_gfx/xxx_arci.cxx
+ void arc(int x, int y, int w, int h, double a1, double a2);
+ void pie(int x, int y, int w, int h, double a1, double a2);
+ // --- implementation is in src/fl_line_style.cxx which includes src/cfg_gfx/xxx_line_style.cxx
+ void line_style(int style, int width=0, char* dashes=0);
+ // --- implementation is in src/fl_color.cxx which includes src/cfg_gfx/xxx_color.cxx
+ void color(Fl_Color c);
+ Fl_Color color() { return color_; }
+ void color(uchar r, uchar g, uchar b);
+ // --- implementation is in src/fl_font.cxx which includes src/cfg_gfx/xxx_font.cxx
+ void draw(const char *str, int n, int x, int y);
+ double width(const char *str, int n);
+ void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
+ int height();
+ int descent();
+};
+
+
+#endif // FL_CFG_GFX_OPENGL_H
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
new file mode 100644
index 000000000..15ec4cf36
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
@@ -0,0 +1,70 @@
+//
+// "$Id$"
+//
+// Arc (integer) drawing functions for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2010 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+#ifndef FL_CFG_GFX_OPENGL_ARCI_CXX
+#define FL_CFG_GFX_OPENGL_ARCI_CXX
+
+/**
+ \file opengl_arci.cxx
+ \brief Utility functions for drawing circles using integers
+*/
+
+#include <FL/gl.h>
+#define _USE_MATH_DEFINES
+#include <math.h>
+
+void Fl_OpenGL_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) {
+ if (w <= 0 || h <= 0) return;
+ while (a2<a1) a2 += 360.0; // TODO: write a sensible fmod angle alignment here
+ a1 = a1/180.0f*M_PI; a2 = a2/180.0f*M_PI;
+ double cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f;
+ double rMax; if (w<h) rMax = h/2; else rMax = w/2;
+ int nSeg = (int)(10 * sqrt(rMax))+1;
+ double incr = (a2-a1)/(double)nSeg;
+
+ glBegin(GL_LINE_STRIP);
+ for (int i=0; i<nSeg; i++) {
+ glVertex2d(cx+cos(a1)*rMax, cy-sin(a1)*rMax);
+ a1 += incr;
+ }
+ glEnd();
+}
+
+void Fl_OpenGL_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) {
+ if (w <= 0 || h <= 0) return;
+ while (a2<a1) a2 += 360.0; // TODO: write a sensible fmod angle alignment here
+ a1 = a1/180.0f*M_PI; a2 = a2/180.0f*M_PI;
+ double cx = x + 0.5f*w - 0.5f, cy = y + 0.5f*h - 0.5f;
+ double rMax; if (w<h) rMax = h/2; else rMax = w/2;
+ int nSeg = (int)(10 * sqrt(rMax))+1;
+ double incr = (a2-a1)/(double)nSeg;
+
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex2d(cx, cy);
+ for (int i=0; i<nSeg+1; i++) {
+ glVertex2d(cx+cos(a1)*rMax, cy-sin(a1)*rMax);
+ a1 += incr;
+ }
+ glEnd();
+}
+
+#endif // FL_CFG_GFX_OPENGL_ARCI_CXX
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_color.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_color.cxx
new file mode 100644
index 000000000..0923b02fb
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_color.cxx
@@ -0,0 +1,70 @@
+//
+// "$Id$"
+//
+// Color functions for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2016 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+/**
+ \file fl_color.cxx
+ \brief Color handling
+*/
+
+#include "Fl_OpenGL_Graphics_Driver.h"
+#include <FL/gl.h>
+
+// Implementation of fl_color(i), fl_color(r,g,b).
+
+void Fl_OpenGL_Graphics_Driver::color(Fl_Color i) {
+ // FIXME: do we need the code below?
+ /*
+#if HAVE_GL_OVERLAY
+#if defined(WIN32)
+ if (fl_overlay && fl_overlay_depth) {
+ if (fl_overlay_depth < 8) {
+ // only black & white produce the expected colors. This could
+ // be improved by fixing the colormap set in Fl_Gl_Overlay.cxx
+ int size = 1<<fl_overlay_depth;
+ if (!i) glIndexi(size-2);
+ else if (i >= size-2) glIndexi(size-1);
+ else glIndexi(i);
+ } else {
+ glIndexi(i ? i : FL_GRAY_RAMP);
+ }
+ return;
+ }
+#else
+ if (fl_overlay) {glIndexi(int(fl_xpixel(i))); return;}
+#endif
+#endif
+*/
+ if (i & 0xffffff00) {
+ unsigned rgb = (unsigned)i;
+ fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8));
+ } else {
+ Fl_Graphics_Driver::color(i);
+ uchar red, green, blue;
+ Fl::get_color(i, red, green, blue);
+ glColor3ub(red, green, blue);
+ }
+}
+
+void Fl_OpenGL_Graphics_Driver::color(uchar r,uchar g,uchar b) {
+ Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
+ glColor3ub(r,g,b);
+}
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx
new file mode 100644
index 000000000..24a5fe51b
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx
@@ -0,0 +1,151 @@
+//
+// "$Id$"
+//
+// Standard X11 font selection code for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2016 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+/*
+ This module implements a lowest-common-denominator font for OpenGL.
+ It will always work, even if the main graphics library does not support
+ rendering text into a texture buffer.
+
+ The font is limited to a single face and ASCII characters. It is drawn using
+ lines which makes it arbitrarily scalable. I am trying to keep font data really
+ compact.
+ */
+
+
+#include <FL/gl.h>
+
+// FIXME: check out FreeGlut:
+// FIXME: implement font-to-RGBA in the main graphics driver
+
+#if 1
+
+/*
+ |01234567|
+ -+--------+
+ 0| |____
+ 1|++++++++|font
+ 2|++++++++|
+ 3|++++++++|
+ 4|++++++++|
+ 5|++++++++|____
+ 6| |descent
+ 7| |
+ -+--------+
+ */
+
+
+static const char *font_data[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, /*T*/"\11\71\100\41\45", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, /*e*/"\55\25\14\13\22\52\63\64\14", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, /*s*/"\62\22\13\64\55\15", /*t*/"\41\44\55\65\100\22\62", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+
+double Fl_OpenGL_Graphics_Driver::width(const char *str, int n) {
+ return size_*n*0.5;
+}
+
+int Fl_OpenGL_Graphics_Driver::descent() {
+ return (int)(size_ - size_*0.8);
+}
+
+int Fl_OpenGL_Graphics_Driver::height() {
+ return (int)(size_*0.8);
+}
+
+void Fl_OpenGL_Graphics_Driver::text_extents(const char *str, int n, int& dx, int& dy, int& w, int& h)
+{
+ dx = 0;
+ dy = descent();
+ w = width(str, n);
+ h = size_;
+}
+
+void Fl_OpenGL_Graphics_Driver::draw(const char *str, int n, int x, int y)
+{
+ int i;
+ for (i=0; i<n; i++) {
+ char c = str[i] & 0x7f;
+ const char *fd = font_data[(int)c];
+ if (fd) {
+ char rendering = 0;
+ float px, py;
+ for (;;) {
+ char cmd = *fd++;
+ if (cmd==0) {
+ if (rendering) {
+ glEnd();
+ glBegin(GL_POINTS); glVertex2f(px, py); glEnd();
+ rendering = 0;
+ }
+ break;
+ } else if (cmd>63) {
+ if (cmd=='\100' && rendering) {
+ glEnd();
+ glBegin(GL_POINTS); glVertex2f(px, py); glEnd();
+ rendering = 0;
+ }
+ } else {
+ if (!rendering) { glBegin(GL_LINE_STRIP); rendering = 1; }
+ int vx = (cmd & '\70')>>3;
+ int vy = (cmd & '\07');
+ px = 0.5+x+vx*size_*0.5/8.0;
+ py = 0.5+y+vy*size_/8.0-0.8*size_;
+ glVertex2f(px, py);
+ }
+ }
+ }
+ x += size_*0.5;
+ }
+}
+
+#elif 0
+
+/*
+extern FL_EXPORT Fl_Glut_StrokeFont glutStrokeRoman;
+extern FL_EXPORT Fl_Glut_StrokeFont glutStrokeMonoRoman;
+# define GLUT_STROKE_ROMAN (&glutStrokeRoman)
+# define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman)
+
+FL_EXPORT void glutStrokeCharacter(void *font, int character);
+FL_EXPORT GLfloat glutStrokeHeight(void *font);
+FL_EXPORT int glutStrokeLength(void *font, const unsigned char *string);
+FL_EXPORT void glutStrokeString(void *font, const unsigned char *string);
+FL_EXPORT int glutStrokeWidth(void *font, int character);
+*/
+
+#else
+
+void Fl_OpenGL_Graphics_Driver::draw(const char* str, int n, int x, int y) {
+ gl_draw(str, n, x, y);
+}
+
+#endif
+
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx
new file mode 100644
index 000000000..c9606f95d
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx
@@ -0,0 +1,70 @@
+//
+// "$Id$"
+//
+// Line style code for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2016 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+#ifndef FL_CFG_GFX_OPENGL_LINE_STYLE_CXX
+#define FL_CFG_GFX_OPENGL_LINE_STYLE_CXX
+
+/**
+ \file opengl_line_style.cxx
+ \brief Line style drawing utility hiding different platforms.
+*/
+
+#include "Fl_OpenGL_Graphics_Driver.h"
+#include <FL/gl.h>
+
+extern int fl_line_width_;
+
+// OpenGL implementation does not support custom patterns
+// OpenGL implementation does not support cap and join types
+
+void Fl_OpenGL_Graphics_Driver::line_style(int style, int width, char* dashes) {
+
+ // save line width in global variable for X11 clipping
+ // FIXME: what does this code do?
+ if (width == 0) fl_line_width_ = 1;
+ else fl_line_width_ = width>0 ? width : -width;
+
+ if (width<1) width = 1;
+
+ if (style==FL_SOLID) {
+ glLineStipple(1, 0xFFFF);
+ glDisable(GL_LINE_STIPPLE);
+ } else {
+ switch (style) {
+ case FL_DASH:
+ glLineStipple(width, 0x0F0F); // ....****....****
+ break;
+ case FL_DOT:
+ glLineStipple(width, 0x5555); // .*.*.*.*.*.*.*.*
+ break;
+ case FL_DASHDOT:
+ glLineStipple(width, 0x2727); // ..*..***..*..***
+ break;
+ case FL_DASHDOTDOT:
+ glLineStipple(width, 0x5757); // .*.*.***.*.*.***
+ break;
+ }
+ glEnable(GL_LINE_STIPPLE);
+ }
+}
+
+#endif // FL_CFG_GFX_OPENGL_LINE_STYLE_CXX
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
new file mode 100644
index 000000000..1ea30a4d7
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx
@@ -0,0 +1,209 @@
+//
+// "$Id$"
+//
+// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2016 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+#ifndef FL_CFG_GFX_OPENGL_RECT_CXX
+#define FL_CFG_GFX_OPENGL_RECT_CXX
+
+
+/**
+ \file quartz_rect.cxx
+ \brief OpenGL specific line and polygon drawing with integer coordinates.
+ */
+
+#include <FL/gl.h>
+#include "Fl_OpenGL_Graphics_Driver.h"
+
+// --- line and polygon drawing with integer coordinates
+
+void Fl_OpenGL_Graphics_Driver::point(int x, int y) {
+ glBegin(GL_POINTS);
+ glVertex2i(x, y);
+ glEnd();
+}
+
+void Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::line(int x, int y, int x1, int y1) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x1, y1);
+ glEnd();
+ point(x1, y1);
+}
+
+void Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::xyline(int x, int y, int x1) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x1, y);
+ glEnd();
+ point(x1, y);
+}
+
+void Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::yxline(int x, int y, int y1) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x, y1);
+ glEnd();
+ point(x, y1);
+}
+
+void Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::not_clipped(int x, int y, int w, int h) {
+ // TODO: implement OpenGL clipping
+ return 1;
+}
+
+void Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::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 Fl_OpenGL_Graphics_Driver::restore_clip() {
+ // TODO: implement OpenGL clipping
+ fl_clip_state_number++;
+}
+
+const char *Fl_OpenGL_Graphics_Driver::class_id = "Fl_OpenGL_Graphics_Driver";
+
+
+#endif // FL_CFG_GFX_OPENGL_RECT_CXX
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
new file mode 100644
index 000000000..1dd091f0d
--- /dev/null
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_vertex.cxx
@@ -0,0 +1,142 @@
+//
+// "$Id$"
+//
+// Portable drawing routines for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2016 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
+// file is missing or damaged, see the license at:
+//
+// http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+#ifndef FL_CFG_GFX_OPENGL_VERTEX_CXX
+#define FL_CFG_GFX_OPENGL_VERTEX_CXX
+
+/**
+ \file opengl_vertex.cxx
+ \brief Portable drawing code for drawing arbitrary shapes with
+ simple 2D transformations, implemented for OpenGL.
+*/
+
+#include "Fl_OpenGL_Graphics_Driver.h"
+
+#include <FL/fl_draw.H>
+#include <FL/gl.h>
+#include <FL/math.h>
+
+
+// Event though there are faster versions of the functions in OpenGL,
+// we use the default FLTK implementation for compatibility in the
+// following functions.
+
+// void Fl_OpenGL_Graphics_Driver::push_matrix()
+// void Fl_OpenGL_Graphics_Driver::pop_matrix()
+// void Fl_OpenGL_Graphics_Driver::mult_matrix(double a, double b, double c, double d, double x, double y)
+// void Fl_OpenGL_Graphics_Driver::rotate(double d)
+// double Fl_OpenGL_Graphics_Driver::transform_x(double x, double y)
+// double Fl_OpenGL_Graphics_Driver::transform_y(double x, double y)
+// double Fl_OpenGL_Graphics_Driver::transform_dx(double x, double y)
+// double Fl_OpenGL_Graphics_Driver::transform_dy(double x, double y)
+
+void Fl_OpenGL_Graphics_Driver::begin_points() {
+ glBegin(GL_POINTS);
+}
+
+void Fl_OpenGL_Graphics_Driver::end_points() {
+ glEnd();
+}
+
+void Fl_OpenGL_Graphics_Driver::begin_line() {
+ glBegin(GL_LINE_STRIP);
+}
+
+void Fl_OpenGL_Graphics_Driver::end_line() {
+ glEnd();
+}
+
+void Fl_OpenGL_Graphics_Driver::begin_loop() {
+ glBegin(GL_LINE_LOOP);
+}
+
+void Fl_OpenGL_Graphics_Driver::end_loop() {
+ glEnd();
+}
+
+void Fl_OpenGL_Graphics_Driver::begin_polygon() {
+ glBegin(GL_POLYGON);
+}
+
+void Fl_OpenGL_Graphics_Driver::end_polygon() {
+ glEnd();
+}
+
+void Fl_OpenGL_Graphics_Driver::begin_complex_polygon() {
+ glBegin(GL_POLYGON);
+}
+
+void Fl_OpenGL_Graphics_Driver::gap() {
+ glEnd();
+ glBegin(GL_POLYGON);
+}
+
+// FXIME: non-convex polygons are not supported yet
+// use gluTess* functions to do this; search for gluBeginPolygon
+void Fl_OpenGL_Graphics_Driver::end_complex_polygon() {
+ glEnd();
+}
+
+// remove equal points from closed path
+void Fl_OpenGL_Graphics_Driver::fixloop() { }
+
+void Fl_OpenGL_Graphics_Driver::transformed_vertex(double xf, double yf) {
+ glVertex2d(xf, yf);
+}
+
+void Fl_OpenGL_Graphics_Driver::transformed_vertex0(COORD_T x, COORD_T y) {
+ glVertex2d(x, y);
+}
+
+void Fl_OpenGL_Graphics_Driver::vertex(double x,double y) {
+ transformed_vertex0(x*m.a + y*m.c + m.x, x*m.b + y*m.d + m.y);
+}
+
+void Fl_OpenGL_Graphics_Driver::circle(double cx, double cy, double r) {
+ double rx = r * (m.c ? sqrt(m.a*m.a+m.c*m.c) : fabs(m.a));
+ double ry = r * (m.b ? sqrt(m.b*m.b+m.d*m.d) : fabs(m.d));
+ double rMax;
+ if (ry>rx) rMax = ry; else rMax = rx;
+
+ // from http://slabode.exofire.net/circle_draw.shtml and many other places
+ int num_segments = (int)(10 * sqrt(rMax))+1;
+ double theta = 2 * M_PI / float(num_segments);
+ double tangetial_factor = tan(theta);
+ double radial_factor = cosf(theta);//calculate the radial factor
+ double x = r; //we start at angle = 0
+ double y = 0;
+
+ glBegin(GL_LINE_LOOP);
+ for(int ii = 0; ii < num_segments; ii++) {
+ vertex(x + cx, y + cy); // output vertex
+ double tx = -y;
+ double ty = x;
+ x += tx * tangetial_factor;
+ y += ty * tangetial_factor;
+ x *= radial_factor;
+ y *= radial_factor;
+ }
+ glEnd();
+
+}
+
+#endif // FL_CFG_GFX_OPENGL_VERTEX_CXX
+
+//
+// End of "$Id$".
+//