summaryrefslogtreecommitdiffstats
path: root/src/detection/opengl/opengl_haiku.cpp
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/opengl/opengl_haiku.cpp
Add the files
Diffstat (limited to 'src/detection/opengl/opengl_haiku.cpp')
-rw-r--r--src/detection/opengl/opengl_haiku.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/detection/opengl/opengl_haiku.cpp b/src/detection/opengl/opengl_haiku.cpp
new file mode 100644
index 0000000..64a21a0
--- /dev/null
+++ b/src/detection/opengl/opengl_haiku.cpp
@@ -0,0 +1,38 @@
+#include <OpenGLKit.h>
+
+extern "C" {
+#include "opengl.h"
+#include "common/io.h"
+#if FF_HAVE_EGL
+const char* ffOpenGLDetectByEGL(FFOpenGLResult* result);
+#endif
+void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString);
+}
+
+static const char* oglDetectOpenGL(FFOpenGLResult* result) {
+ BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
+ FF_SUPPRESS_IO();
+
+ BGLView glView(BRect(), "ff_ogl_view", B_FOLLOW_NONE, B_WILL_DRAW, BGL_RGB);
+ auto ffglGetString = (decltype(&glGetString)) glView.GetGLProcAddress("glGetString");
+ if (!ffglGetString) {
+ return "glView.GetGLProcAddress() failed";
+ }
+ ffOpenGLHandleResult(result, ffglGetString);
+ ffStrbufSetStatic(&result->library, "OpenGLKit");
+ return NULL;
+}
+
+const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) {
+ if (options->library == FF_OPENGL_LIBRARY_AUTO) {
+ return oglDetectOpenGL(result);
+ } else if (options->library == FF_OPENGL_LIBRARY_EGL) {
+#if FF_HAVE_EGL
+ return ffOpenGLDetectByEGL(result);
+#else
+ return "fastfetch was compiled without egl support";
+#endif
+ } else {
+ return "Unsupported OpenGL library";
+ }
+}