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.
This commit is contained in:
Matthias Melcher
2022-02-06 15:22:24 +01:00
committed by GitHub
parent af4954aee3
commit db0a1f4bae
30 changed files with 1670 additions and 424 deletions
+69
View File
@@ -257,6 +257,75 @@ adhere to for maximum portability:
Do \e not call \p gl_start() or
\p gl_finish() when drawing into an Fl_Gl_Window !
\section opengl_with_fltk_widgets Using FLTK widgets in OpenGL Windows
FLTK widgets can be added to `Fl_Gl_Window`s just as they would be added to
`Fl_Window`s. They are rendered as an overlay over the user defined
OpenGL graphics using 'fl_..' graphics calls that are implemented in GL.
`Fl_Gl_Window` does not add subsequent widgets as children by default as
`Fl_Window` does. Call `myGlWindow->begin()` after creating the GL window to
automatically add following widgets. Remember to call `myGlWindow->end()`.
\code
class My_Gl_Window : public Fl_Gl_Window {
...
void draw();
...
};
...
myGlWindow = new My_Gl_Window(0, 0, 500, 500);
myGlWindow->begin();
myButton = new Fl_Button(10, 10, 120, 24, "Hello!");
myGlWindow->end();
...
void My_Gl_Window::draw() {
// ... user GL drawing code
Fl_Gl_Window::draw(); // Draw FLTK child widgets.
}
\endcode
Users can draw into the overlay by using GL graphics calls as well as all
`fl_...` graphics calls from the "Drawing Fast Shapes" section.
\code
void My_Gl_Window::draw() {
// ... user GL drawing code
Fl_Gl_Window::draw_begin(); // Set up 1:1 projection
Fl_Window::draw(); // Draw FLTK children
fl_color(FL_RED);
fl_rect(10, 10, 100, 100);
Fl_Gl_Window::draw_end(); // Restore GL state
}
\endcode
Widgets can be drawn with transparencies by assigning an alpha value to a
colormap entry and using that color in the widget.
\code
Fl::set_color(FL_FREE_COLOR, 255, 255, 0, 127); // 50% transparent yellow
myGlWindow = new My_Gl_Window(0, 0, 500, 500);
myGlWindow->begin();
myButton = new Fl_Button(10, 10, 120, 24, "Hello!");
myButton->box(FL_BORDER_BOX);
myButton->color(FL_FREE_COLOR);
myGlWindow->end();
\endcode
Transparencies can also be set directly when drawing. This can be used to
create custom box types and RGB overlay drawings with an alpha channel.
\code
fl_color(0, 255, 0, 127); // 50% transparent green
fl_rectf(10, 10, 100, 100);
fl_color(FL_RED); // back to opaque red
fl_rect(20, 20, 80, 80);
\endcode
\section opengl_drawing OpenGL Drawing Functions
FLTK provides some useful OpenGL drawing functions. They can