[RFC PATCH v2 5/5] kernel-shark: Drop Freeglut as a compulsory dependency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
---
 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/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)
-- 
2.20.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux