Re: [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]

 



On Wed, Jul 3, 2019 at 3:11 PM Yordan Karadzhov (VMware)
<y.karadz@xxxxxxxxx> 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@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/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




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

  Powered by Linux