linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v6 22/27] kernel-shark: Make GLUT optional dependency
Date: Wed,  9 Dec 2020 15:41:58 +0200	[thread overview]
Message-ID: <20201209134203.428068-23-y.karadz@gmail.com> (raw)
In-Reply-To: <20201209134203.428068-1-y.karadz@gmail.com>

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.

Signen-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 build/deff.h.cmake   |  3 +++
 src/CMakeLists.txt   |  4 ++--
 src/libkshark-plot.c | 20 +++++++-------------
 src/libkshark-plot.h | 11 +++++++++++
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/build/deff.h.cmake b/build/deff.h.cmake
index e398c0c..868ffec 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 3a07d82..cbd45ed 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 0c6b1a5..1c45f44 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 0edf5d5..063740d 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);
-- 
2.25.1


  parent reply	other threads:[~2020-12-09 13:44 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 13:41 [PATCH v6 00/27] Start KernelShark v2 transformation Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 01/27] kernel-shark: Use only signed types in kshark_entry Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 02/27] kernel-shark: Add stream_id to kshark_entry Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 03/27] kernel-shark: Introduce libkshark-hash Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 04/27] kernel-shark: Introduce Data streams Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 05/27] kernel-shark: Rename static methods in libkshark Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 06/27] kernel-shark: Add basic methods for Data streams Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 07/27] kernel-shark: Housekeeping before implementing stream interface Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 08/27] kernel-shark: Add stream interface for trace-cmd data Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 09/27] kernel-shark: Start introducing KernelShark 2.0 Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 10/27] kernel-shark: Start using data streams Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 11/27] kernel-shark: Remove dead code Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 12/27] kernel-shark: Redesign the plugin interface Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 13/27] kernel-shark: Complete the stream integration Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 14/27] kernel-shark: Provide merging of multiple data streams Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 15/27] kernel-shark: Integrate the stream definitions with data model Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 16/27] kernel-shark: Use only signed types for model defs Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 17/27] kernel-shark: Add ksmodel_get_bin() Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 18/27] kernel-shark: Protect ksmodel_set_in_range_bining() Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 19/27] kernel-shark: Add methods for time calibration Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 20/27] kernel-shark: Integrate streams with libkshark-configio Yordan Karadzhov (VMware)
2020-12-09 13:41 ` [PATCH v6 21/27] kernel-shark: Add support for drawing text Yordan Karadzhov (VMware)
2020-12-09 13:41 ` Yordan Karadzhov (VMware) [this message]
2020-12-09 13:41 ` [PATCH v6 23/27] kernel-shark: Add ksplot_draw_polyline() Yordan Karadzhov (VMware)
2020-12-09 13:42 ` [PATCH v6 24/27] kernel-shark: Optimize ksplot_draw_polygon() Yordan Karadzhov (VMware)
2020-12-09 13:42 ` [PATCH v6 25/27] kernel-shark: Do not use the ARRAY_SIZE macro Yordan Karadzhov (VMware)
2020-12-09 13:42 ` [PATCH v6 26/27] kernel-shark: Add basic infrastructure for testing Yordan Karadzhov (VMware)
2020-12-09 13:42 ` [PATCH v6 27/27] kernel-shark: Add "github Actions" workflow Yordan Karadzhov (VMware)
2020-12-10  2:38 ` [PATCH v6 00/27] Start KernelShark v2 transformation Steven Rostedt
2020-12-10  8:48   ` David Runge
2020-12-10 14:38     ` Yordan Karadzhov (VMware)
2020-12-10 14:42     ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201209134203.428068-23-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).