Message ID | 20190703121023.16655-6-y.karadz@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add support for text rendering | expand |
On Wed, Jul 3, 2019 at 3:11 PM Yordan Karadzhov (VMware) <y.karadz@gmail.com> wrote: > > Freeglut is not a necessary dependency for programs like the > KernelShark GUI that are using Qt for window and OpenGL context > management. Currently it is been used only by the data plotting > example (dataplot.cpp). > > Suggested-by: Slavomir Kaslev <kaslevs@vmware.com> > Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> > --- > kernel-shark/build/deff.h.cmake | 3 +++ > kernel-shark/examples/CMakeLists.txt | 10 +++++++--- > kernel-shark/src/CMakeLists.txt | 4 ++-- > kernel-shark/src/KsGLWidget.cpp | 4 ---- > kernel-shark/src/KsPlotTools.cpp | 4 ---- > kernel-shark/src/libkshark-plot.c | 17 ++++++++--------- > kernel-shark/src/libkshark-plot.h | 2 +- > 7 files changed, 21 insertions(+), 23 deletions(-) > [...] > diff --git a/kernel-shark/src/libkshark-plot.c b/kernel-shark/src/libkshark-plot.c > index 1982494..32e2ae9 100644 > --- a/kernel-shark/src/libkshark-plot.c > +++ b/kernel-shark/src/libkshark-plot.c > @@ -19,6 +19,7 @@ > > // KernelShark > #include "libkshark-plot.h" > +#include "KsCmakeDef.hpp" > > /* > * STB TrueType (single-file public domain library) > @@ -31,6 +32,10 @@ > #define STBTT_STATIC > #include "stb_truetype.h" > > +#ifdef GLUT_FOUND > + > +#include <GL/freeglut.h> > + > /** > * @brief Create an empty scene for drawing. > * > @@ -55,17 +60,11 @@ void ksplot_make_scene(int width, int height) > /* Open the screen window. */ > glutCreateWindow("KernelShark Plot"); > > - /* > - * Set the origin of the coordinate system to be the top left corner. > - * The "Y" coordinate is inverted. > - */ > - gluOrtho2D(0, width, height, 0); > - glViewport(0, 0, width, height); > - > - glMatrixMode(GL_PROJECTION); > - glLoadIdentity(); > + ksplot_resize_opengl(width, height); > } > > +#endif // GLUT_FOUND I think we shouldn't link libkshark-plot with GLUT even if it's available on the system and let users of the library decide whether they need it. The glut code in this function is pretty standard GLUT initialization which users would want to control anyway and there's no point in providing it here. Dropping GLUT as libkshark-plot dependency would imply GLU needs to be added as dependency for the gluOrtho2D() function (GLUT depends on GLU so that's how we've been picking up GLU till now). Alternatively, we can drop GLU altogether as dependency by implementing gluOrtho2D() ourselves (by using something like this[1] and glLoadMatrix() it). [1] https://github.com/skaslev/catmull-clark/blob/e7142dd270176a38c180fd74b67da740ea68991c/mathx.c#L169 Cheers, -- Slavi
diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake index efee2a1..e3543ca 100644 --- a/kernel-shark/build/deff.h.cmake +++ b/kernel-shark/build/deff.h.cmake @@ -23,6 +23,9 @@ /** "pkexec" executable. */ #cmakedefine DO_AS_ROOT "@DO_AS_ROOT@" +/** GLUT has been found. */ +#cmakedefine GLUT_FOUND + #ifdef __cplusplus #include <QString> diff --git a/kernel-shark/examples/CMakeLists.txt b/kernel-shark/examples/CMakeLists.txt index 824b21c..74898c0 100644 --- a/kernel-shark/examples/CMakeLists.txt +++ b/kernel-shark/examples/CMakeLists.txt @@ -16,9 +16,13 @@ message(STATUS "confogio") add_executable(confio configio.c) target_link_libraries(confio kshark) -message(STATUS "dataplot") -add_executable(dplot dataplot.cpp) -target_link_libraries(dplot kshark-plot) +if (GLUT_FOUND) + + message(STATUS "dataplot") + add_executable(dplot dataplot.cpp) + target_link_libraries(dplot kshark-plot) + +endif (GLUT_FOUND) message(STATUS "widgetdemo") add_executable(widgetdemo widgetdemo.cpp) diff --git a/kernel-shark/src/CMakeLists.txt b/kernel-shark/src/CMakeLists.txt index 36ce884..8c8f988 100644 --- a/kernel-shark/src/CMakeLists.txt +++ b/kernel-shark/src/CMakeLists.txt @@ -38,7 +38,7 @@ if (_DEVEL) endif (_DEVEL) -if (OPENGL_FOUND AND GLUT_FOUND) +if (OPENGL_FOUND) message(STATUS "libkshark-plot") add_library(kshark-plot SHARED libkshark-plot.c @@ -65,7 +65,7 @@ if (OPENGL_FOUND AND GLUT_FOUND) endif (_DEVEL) -endif (OPENGL_FOUND AND GLUT_FOUND) +endif (OPENGL_FOUND) if (Qt5Widgets_FOUND AND Qt5Network_FOUND) diff --git a/kernel-shark/src/KsGLWidget.cpp b/kernel-shark/src/KsGLWidget.cpp index ce68052..37819d3 100644 --- a/kernel-shark/src/KsGLWidget.cpp +++ b/kernel-shark/src/KsGLWidget.cpp @@ -9,10 +9,6 @@ * @brief OpenGL widget for plotting trace graphs. */ -// OpenGL -#include <GL/glut.h> -#include <GL/gl.h> - // KernelShark #include "KsGLWidget.hpp" #include "KsUtils.hpp" diff --git a/kernel-shark/src/KsPlotTools.cpp b/kernel-shark/src/KsPlotTools.cpp index a8eddcd..152ec47 100644 --- a/kernel-shark/src/KsPlotTools.cpp +++ b/kernel-shark/src/KsPlotTools.cpp @@ -16,10 +16,6 @@ #include <algorithm> #include <vector> -// OpenGL -#include <GL/freeglut.h> -#include <GL/gl.h> - // KernelShark #include "KsPlotTools.hpp" diff --git a/kernel-shark/src/libkshark-plot.c b/kernel-shark/src/libkshark-plot.c index 1982494..32e2ae9 100644 --- a/kernel-shark/src/libkshark-plot.c +++ b/kernel-shark/src/libkshark-plot.c @@ -19,6 +19,7 @@ // KernelShark #include "libkshark-plot.h" +#include "KsCmakeDef.hpp" /* * STB TrueType (single-file public domain library) @@ -31,6 +32,10 @@ #define STBTT_STATIC #include "stb_truetype.h" +#ifdef GLUT_FOUND + +#include <GL/freeglut.h> + /** * @brief Create an empty scene for drawing. * @@ -55,17 +60,11 @@ void ksplot_make_scene(int width, int height) /* Open the screen window. */ glutCreateWindow("KernelShark Plot"); - /* - * Set the origin of the coordinate system to be the top left corner. - * The "Y" coordinate is inverted. - */ - gluOrtho2D(0, width, height, 0); - glViewport(0, 0, width, height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + ksplot_resize_opengl(width, height); } +#endif // GLUT_FOUND + /** * @brief Initialize OpenGL. * diff --git a/kernel-shark/src/libkshark-plot.h b/kernel-shark/src/libkshark-plot.h index 1895bee..2c44787 100644 --- a/kernel-shark/src/libkshark-plot.h +++ b/kernel-shark/src/libkshark-plot.h @@ -16,8 +16,8 @@ #include <stdbool.h> // OpenGL -#include <GL/freeglut.h> #include <GL/gl.h> +#include <GL/glu.h> /* * STB TrueType (single-file public domain library)
Freeglut is not a necessary dependency for programs like the KernelShark GUI that are using Qt for window and OpenGL context management. Currently it is been used only by the data plotting example (dataplot.cpp). Suggested-by: Slavomir Kaslev <kaslevs@vmware.com> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- kernel-shark/build/deff.h.cmake | 3 +++ kernel-shark/examples/CMakeLists.txt | 10 +++++++--- kernel-shark/src/CMakeLists.txt | 4 ++-- kernel-shark/src/KsGLWidget.cpp | 4 ---- kernel-shark/src/KsPlotTools.cpp | 4 ---- kernel-shark/src/libkshark-plot.c | 17 ++++++++--------- kernel-shark/src/libkshark-plot.h | 2 +- 7 files changed, 21 insertions(+), 23 deletions(-)