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. --- .../Fl_OpenGL_Graphics_Driver_line_style.cxx | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx') diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx index 89dea699d..c1963352b 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_line_style.cxx @@ -31,27 +31,41 @@ // OpenGL implementation does not support cap and join types void Fl_OpenGL_Graphics_Driver::line_style(int style, int width, char* dashes) { - if (width<1) width = 1; + line_width_ = width; + + int stipple = style & 0x00ff; + line_stipple_ = stipple; +// int cap = style & 0x0f00; +// int join = style & 0xf000; - if (style==FL_SOLID) { + if (stipple==FL_SOLID) { glLineStipple(1, 0xFFFF); glDisable(GL_LINE_STIPPLE); } else { - switch (style) { + char enable = 1; + switch (stipple & 0x00ff) { case FL_DASH: - glLineStipple(width, 0x0F0F); // ....****....**** + glLineStipple(pixels_per_unit_*line_width_, 0x0F0F); // ....****....**** break; case FL_DOT: - glLineStipple(width, 0x5555); // .*.*.*.*.*.*.*.* + glLineStipple(pixels_per_unit_*line_width_, 0x5555); // .*.*.*.*.*.*.*.* break; case FL_DASHDOT: - glLineStipple(width, 0x2727); // ..*..***..*..*** + glLineStipple(pixels_per_unit_*line_width_, 0x2727); // ..*..***..*..*** break; case FL_DASHDOTDOT: - glLineStipple(width, 0x5757); // .*.*.***.*.*.*** + glLineStipple(pixels_per_unit_*line_width_, 0x5757); // .*.*.***.*.*.*** break; + default: + glLineStipple(1, 0xFFFF); + enable = 0; } - glEnable(GL_LINE_STIPPLE); + if (enable) + glEnable(GL_LINE_STIPPLE); + else + glDisable(GL_LINE_STIPPLE); } + glLineWidth( (GLfloat)(pixels_per_unit_ * line_width_) ); + glPointSize( (GLfloat)(pixels_per_unit_) ); } -- cgit v1.2.3