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. --- test/cube.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test/cube.cxx') diff --git a/test/cube.cxx b/test/cube.cxx index 64e9044cd..fa96130ee 100644 --- a/test/cube.cxx +++ b/test/cube.cxx @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -184,6 +185,12 @@ void print_cb(Fl_Widget *w, void *data) #define MARGIN2 (MARGIN*2) #define MARGIN3 (MARGIN*3) +void show_info_cb(Fl_Widget*, void*) { + fl_message("This is an example of using FLTK widgets inside OpenGL windows.\n" + "Multiple widgets can be added to Fl_Gl_Windows. They will be\n" + "rendered as overlays over the scene."); +} + void makeform(const char *name) { // Widget's XYWH's int form_w = 800 + 4 * MARGIN; // main window width @@ -207,6 +214,14 @@ void makeform(const char *name) { lt_grp->begin(); // left GL window lt_cube = new cube_box(lt_cub_x, lt_cub_y, lt_cub_w, lt_cub_h, 0); + + lt_cube->begin(); + Fl_Widget *w = new Fl_Button(10, 10, 120, 30, "FLTK over GL"); + w->color(FL_FREE_COLOR); + w->box(FL_BORDER_BOX ); + w->callback(show_info_cb); + lt_cube->end(); + // center group Fl_Group *ct_grp = new Fl_Group(ct_grp_x, ct_grp_y, ct_grp_w, ct_grp_h); ct_grp->begin(); @@ -238,6 +253,7 @@ void makeform(const char *name) { int main(int argc, char **argv) { Fl::use_high_res_GL(1); + Fl::set_color(FL_FREE_COLOR, 255, 255, 0, 75); makeform(argv[0]); speed->bounds(4,0); #if HAVE_GL @@ -246,7 +262,7 @@ int main(int argc, char **argv) { speed->value(lt_cube->speed = rt_cube->speed = 0.0); #endif size->bounds(4,0.01); - size->value(lt_cube->size = rt_cube->size = 1.0); + size->value(lt_cube->size = rt_cube->size = 3.0); flat->value(1); lt_cube->wire = 0; rt_cube->wire = 1; form->label("cube"); form->show(argc,argv); -- cgit v1.2.3