From db0a1f4baeb928b54d328d5dfbd0ec37b0b58bd3 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 6 Feb 2022 15:22:24 +0100 Subject: 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. --- src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H') diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H index b3c7e9de7..274d911dc 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H @@ -24,12 +24,20 @@ #define FL_OPENGL_GRAPHICS_DRIVER_H #include +#include /** \brief OpenGL specific graphics class. */ class FL_EXPORT Fl_OpenGL_Graphics_Driver : public Fl_Graphics_Driver { public: + float pixels_per_unit_; + float line_width_; + int line_stipple_; + Fl_OpenGL_Graphics_Driver() : + pixels_per_unit_(1.0f), + line_width_(1.0f), + line_stipple_(FL_SOLID) { } // --- line and polygon drawing with integer coordinates void point(int x, int y); void rect(int x, int y, int w, int h); @@ -46,10 +54,17 @@ public: 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 focus_rect(int x, int y, int w, int h); + // ---- clipping 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 pop_clip(); + void push_no_clip(); + Fl_Region clip_region(); + void clip_region(Fl_Region r); void restore_clip(); + int not_clipped(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); + // ---- matrix transformed drawing void transformed_vertex(double xf, double yf); void begin_points(); void end_points(); -- cgit v1.2.3