diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-02-06 15:22:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-06 15:22:24 +0100 |
| commit | db0a1f4baeb928b54d328d5dfbd0ec37b0b58bd3 (patch) | |
| tree | ed53495f5dd435d7c23cd4267fb785e5ebca679c /test/unittest_complex_shapes.cxx | |
| parent | af4954aee3483f03ff69e990e80f4e4a18e8b7f6 (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 'test/unittest_complex_shapes.cxx')
| -rw-r--r-- | test/unittest_complex_shapes.cxx | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/test/unittest_complex_shapes.cxx b/test/unittest_complex_shapes.cxx new file mode 100644 index 000000000..399243e4b --- /dev/null +++ b/test/unittest_complex_shapes.cxx @@ -0,0 +1,121 @@ +// +// Unit tests 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: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#include "unittests.h" + +#include <FL/Fl_Box.H> +#include <FL/fl_draw.H> + +#if 0 + +// TODO: +void fl_push_matrix() +void fl_pop_matrix() + +void fl_scale(double x,double y) +void fl_scale(double x) +void fl_translate(double x,double y) +void fl_rotate(double d) +void fl_mult_matrix(double a,double b,double c,double d,double x,double y) + +double fl_transform_x(double x, double y) +double fl_transform_y(double x, double y) +double fl_transform_dx(double x, double y) +double fl_transform_dy(double x, double y) +void fl_transformed_vertex(double xf, double yf) + +void fl_begin_points() +void fl_end_points() + +void fl_begin_line() +void fl_end_line() + +void fl_begin_loop() +void fl_end_loop() + +void fl_begin_polygon() +void fl_end_polygon() + +void fl_begin_complex_polygon() +void fl_gap() +void fl_end_complex_polygon() + +void fl_vertex(double x,double y) + +void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3) + +void fl_arc(double x, double y, double r, double start, double end) +void fl_circle(double x, double y, double r) + + +#endif + +// +//------- test Complex Shape drawing capabilities of this implementation ---------- +// +class ComplexShapesTest : public Fl_Box { +public: + static Fl_Widget *create() { + return new ComplexShapesTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H); + } + ComplexShapesTest(int x, int y, int w, int h) : Fl_Box(x, y, w, h) { + label("Testing complex shape drawing.\n\n" + "Complex Shapes in FLTK are rendered using floating point coordinates " + "which can be transformed through a matrix."); + align(FL_ALIGN_INSIDE|FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_WRAP); + box(FL_BORDER_BOX); + } + void draw() { + Fl_Box::draw(); + + int i, a = x()+10, b = y()+10; fl_color(FL_BLACK); fl_rect(a, b, 100, 100); + // testing fl_xyline(x, y, x1) + fl_color(FL_RED); fl_point(a+10, b+10); fl_point(a+20, b+10); + fl_color(FL_BLACK); fl_xyline(a+10, b+10, a+20); + // testing fl_xyline(x, y, x1, y2); + fl_color(FL_RED); fl_point(a+10, b+20); fl_point(a+20, b+20); + fl_point(a+20, b+30); + fl_color(FL_BLACK); fl_xyline(a+10, b+20, a+20, b+30); + // testing fl_xyline(x, y, x1, y2, x3); + fl_color(FL_RED); fl_point(a+10, b+40); fl_point(a+20, b+40); + fl_point(a+20, b+50); fl_point(a+30, b+50); + fl_color(FL_BLACK); fl_xyline(a+10, b+40, a+20, b+50, a+30); + //+++ add testing for the fl_yxline commands! + // testing fl_loop(x,y, x,y, x,y, x, y) + fl_color(FL_RED); fl_point(a+60, b+60); fl_point(a+90, b+60); + fl_point(a+60, b+90); fl_point(a+90, b+90); + fl_color(FL_BLACK); + fl_loop(a+60, b+60, a+90, b+60, a+90, b+90, a+60, b+90); + + a = x()+120, b = y()+10; fl_color(FL_BLACK); fl_rect(a, b, 203, 203); + a += 101; b += 101; + fl_color(0xff888800); + for (i=-80; i<=80; i+=20) fl_line(a, b, a+i, b-100); + fl_color(0xff444400); + for (i=-80; i<=80; i+=20) fl_line(a, b, a+i, b+100); + fl_color(0x88ff8800); + for (i=-80; i<=80; i+=20) fl_line(a, b, a-100, b+i); + fl_color(0x44ff4400); + for (i=-80; i<=80; i+=20) fl_line(a, b, a+100, b+i); + fl_color(0x8888ff00); + fl_line(a, b, a-100, b-100); + fl_line(a, b, a+100, b-100); + fl_line(a, b, a+100, b+100); + fl_line(a, b, a-100, b+100); + } +}; + +//UnitTest lines(kTestComplexShapes, "Complex Shapes", ComplexShapesTest::create); |
