aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2020-12-11 17:07:51 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2020-12-21 19:13:16 -0500
commit81954c32724212e02a1e279441f019751c9a084f (patch)
tree128e6c7dd82bc151bb1c9a52b46771ec198ff3f7
parenteeda7cdc43edbf951f0a2711d6256a192baf85c2 (diff)
downloadkernel-shark-81954c32724212e02a1e279441f019751c9a084f.tar.gz
kernel-shark: Make GLUT optional dependency
GLUT is not needed in order to build the KernelShark GUI. Currently it is being used only by the plotting example, so it makes more sense to removed it from the list of compulsory third party packages. The patch optimizes the way the OpenGL and GLUT headers are included and removes some duplicated code. Link: https://lore.kernel.org/linux-trace-devel/<20201211150756.577366-28-y.karadz@gmail.com> Signen-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--build/deff.h.cmake3
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/libkshark-plot.c20
-rw-r--r--src/libkshark-plot.h11
4 files changed, 23 insertions, 15 deletions
diff --git a/build/deff.h.cmake b/build/deff.h.cmake
index e398c0ca..868ffeca 100644
--- a/build/deff.h.cmake
+++ b/build/deff.h.cmake
@@ -23,6 +23,9 @@
/** "pkexec" executable. */
#cmakedefine DO_AS_ROOT "@DO_AS_ROOT@"
+/** GLUT has been found. */
+#cmakedefine GLUT_FOUND
+
/** Semicolon-separated list of plugin names. */
#define KS_BUILTIN_PLUGINS "@PLUGINS@"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 939a016d..96b69cdc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,7 +19,7 @@ set_target_properties(kshark PROPERTIES SUFFIX ".so.${KS_VERSION_STRING}")
install(TARGETS kshark LIBRARY DESTINATION ${_LIBDIR}/${KS_APP_NAME})
-if (OPENGL_FOUND AND GLUT_FOUND)
+if (OPENGL_FOUND)
message(STATUS "libkshark-plot")
add_library(kshark-plot SHARED libkshark-plot.c)
@@ -33,7 +33,7 @@ if (OPENGL_FOUND AND GLUT_FOUND)
install(TARGETS kshark-plot LIBRARY DESTINATION ${_LIBDIR}/${KS_APP_NAME})
-endif (OPENGL_FOUND AND GLUT_FOUND)
+endif (OPENGL_FOUND)
if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
diff --git a/src/libkshark-plot.c b/src/libkshark-plot.c
index 1c8ede4b..c9a35305 100644
--- a/src/libkshark-plot.c
+++ b/src/libkshark-plot.c
@@ -19,10 +19,6 @@
#include <string.h>
#include <stdio.h>
-// OpenGL
-#include <GL/freeglut.h>
-#include <GL/gl.h>
-
// KernelShark
#include "libkshark-plot.h"
@@ -37,6 +33,10 @@
#define STBTT_STATIC
#include "stb_truetype.h"
+#ifdef GLUT_FOUND
+
+#include <GL/freeglut.h>
+
/**
* @brief Create an empty scene for drawing.
*
@@ -61,17 +61,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/src/libkshark-plot.h b/src/libkshark-plot.h
index 0edf5d50..063740d9 100644
--- a/src/libkshark-plot.h
+++ b/src/libkshark-plot.h
@@ -15,6 +15,10 @@
// C
#include <stdbool.h>
+// OpenGL
+#include <GL/gl.h>
+#include <GL/glu.h>
+
/*
* STB TrueType (single-file public domain library)
* https://github.com/nothings/stb
@@ -25,6 +29,9 @@
extern "C" {
#endif
+// KernelShark
+#include "KsCmakeDef.hpp"
+
/** Structure defining a RGB color. */
struct ksplot_color {
/** The Red component of the color. */
@@ -46,8 +53,12 @@ struct ksplot_point {
int y;
};
+#ifdef GLUT_FOUND
+
void ksplot_make_scene(int width, int height);
+#endif // GLUT_FOUND
+
void ksplot_init_opengl(int dpr);
void ksplot_resize_opengl(int width, int height);