@@ -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@"
@@ -38,7 +38,7 @@ install(FILES "${KS_DIR}/src/libkshark.h"
DESTINATION ${KS_INCLUDS_DESTINATION}
COMPONENT libkshark-devel)
-if (OPENGL_FOUND AND GLUT_FOUND)
+if (OPENGL_FOUND)
message(STATUS "libkshark-plot")
add_library(kshark-plot SHARED libkshark-plot.c)
@@ -61,7 +61,7 @@ if (OPENGL_FOUND AND GLUT_FOUND)
ARCHIVE DESTINATION ${_LIBDIR}
COMPONENT libkshark-devel)
-endif (OPENGL_FOUND AND GLUT_FOUND)
+endif (OPENGL_FOUND)
if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
@@ -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.
*
@@ -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);