summaryrefslogtreecommitdiff
path: root/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-02-06 15:22:24 +0100
committerGitHub <noreply@github.com>2022-02-06 15:22:24 +0100
commitdb0a1f4baeb928b54d328d5dfbd0ec37b0b58bd3 (patch)
treeed53495f5dd435d7c23cd4267fb785e5ebca679c /src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
parentaf4954aee3483f03ff69e990e80f4e4a18e8b7f6 (diff)
OpenGL implementation of all `fl_` "Drawing Fast Shapes" graphics calls (#385)
* Fix build system for unites, * Updated unittest to check OpenGL drawing. Making sure that OpenGL drawing is exactly the same as native drawing to make FLTK widget rendering look the same in GL windows. * Make OpenGL optional. * Implemented clipping in OpenGL * unites drawing fast shapes * Fixed CMake * Updating unittest. Added tests for fl_pi and fl_arc (int) Renamed tab to render complex shapes. * Improved OpenGL FLTK drawing emulation. * Fixed GTK ROUND DOWN BOX * Fixing Makefile for unittest * Correctly aligning OpenGL text. * Fixed text alignment in GL windows. Explained the "FLTK over GL " example in Cube. * Overlapping test. * Better GL graphics alignment. * Drawing the focus rect. * Adding Alpha Channel support for GL. * Added FLTK-on-GL documentation.
Diffstat (limited to 'src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx')
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
index f933d10e2..73b216f01 100644
--- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
+++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_arci.cxx
@@ -27,20 +27,21 @@
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#define _USE_MATH_DEFINES
-#include <math.h>
+#include <FL/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;
+ a1 = a1/180.0*M_PI; a2 = a2/180.0*M_PI;
+ double cx = x + 0.5*w, cy = y + 0.5*h;
+ double rx = 0.5*w-0.3, ry = 0.5*h-0.3;
+ double rMax; if (w>h) rMax = rx; else rMax = ry;
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);
+ for (int i=0; i<=nSeg; i++) {
+ glVertex2d(cx+cos(a1)*rx, cy-sin(a1)*ry);
a1 += incr;
}
glEnd();
@@ -53,16 +54,17 @@ void Fl_OpenGL_Graphics_Driver::arc(double x, double y, double r, double start,
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;
+ a1 = a1/180.0*M_PI; a2 = a2/180.0*M_PI;
+ double cx = x + 0.5*w, cy = y + 0.5*h;
+ double rx = 0.5*w, ry = 0.5*h;
+ double rMax; if (w>h) rMax = rx; else rMax = ry;
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);
+ for (int i=0; i<=nSeg; i++) {
+ glVertex2d(cx+cos(a1)*rx, cy-sin(a1)*ry);
a1 += incr;
}
glEnd();