diff options
Diffstat (limited to 'src/cfg_gfx')
| -rw-r--r-- | src/cfg_gfx/opengl.H | 101 | ||||
| -rw-r--r-- | src/cfg_gfx/opengl_arci.cxx | 70 | ||||
| -rw-r--r-- | src/cfg_gfx/opengl_color.cxx | 70 | ||||
| -rw-r--r-- | src/cfg_gfx/opengl_font.cxx | 133 | ||||
| -rw-r--r-- | src/cfg_gfx/opengl_line_style.cxx | 70 | ||||
| -rw-r--r-- | src/cfg_gfx/opengl_rect.cxx | 209 | ||||
| -rw-r--r-- | src/cfg_gfx/opengl_vertex.cxx | 142 |
7 files changed, 0 insertions, 795 deletions
diff --git a/src/cfg_gfx/opengl.H b/src/cfg_gfx/opengl.H deleted file mode 100644 index 48944fcb8..000000000 --- a/src/cfg_gfx/opengl.H +++ /dev/null @@ -1,101 +0,0 @@ -// -// "$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/cfg_gfx/opengl_arci.cxx b/src/cfg_gfx/opengl_arci.cxx deleted file mode 100644 index 15ec4cf36..000000000 --- a/src/cfg_gfx/opengl_arci.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// -// "$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/cfg_gfx/opengl_color.cxx b/src/cfg_gfx/opengl_color.cxx deleted file mode 100644 index 9413be75e..000000000 --- a/src/cfg_gfx/opengl_color.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// -// "$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 "opengl.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/cfg_gfx/opengl_font.cxx b/src/cfg_gfx/opengl_font.cxx deleted file mode 100644 index 18c0c2b77..000000000 --- a/src/cfg_gfx/opengl_font.cxx +++ /dev/null @@ -1,133 +0,0 @@ -// -// "$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> - -/* - |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, -}; - - -#if 0 - -void Fl_OpenGL_Graphics_Driver::draw(const char* str, int n, int x, int y) { - gl_draw(str, n, x, y); -} - -#else - -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=0.0f, py=0.0f; - 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; - } -} - -#endif - - -// -// End of "$Id$". -// diff --git a/src/cfg_gfx/opengl_line_style.cxx b/src/cfg_gfx/opengl_line_style.cxx deleted file mode 100644 index 4bcb2f7fa..000000000 --- a/src/cfg_gfx/opengl_line_style.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// -// "$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 "opengl.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/cfg_gfx/opengl_rect.cxx b/src/cfg_gfx/opengl_rect.cxx deleted file mode 100644 index b1617fcd3..000000000 --- a/src/cfg_gfx/opengl_rect.cxx +++ /dev/null @@ -1,209 +0,0 @@ -// -// "$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 "opengl.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/cfg_gfx/opengl_vertex.cxx b/src/cfg_gfx/opengl_vertex.cxx deleted file mode 100644 index 46bc77fa8..000000000 --- a/src/cfg_gfx/opengl_vertex.cxx +++ /dev/null @@ -1,142 +0,0 @@ -// -// "$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 "opengl.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$". -// |
