Skip to content

Commit

Permalink
OpenGL (Haiku): add support
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Feb 16, 2025
1 parent 76b8b9a commit 9018fda
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ elseif(Haiku)
src/detection/memory/memory_haiku.c
src/detection/mouse/mouse_haiku.cpp
src/detection/netio/netio_haiku.cpp
src/detection/opengl/opengl_linux.c
src/detection/opengl/opengl_haiku.cpp
src/detection/os/os_haiku.c
src/detection/packages/packages_haiku.c
src/detection/poweradapter/poweradapter_nosupport.c
Expand Down Expand Up @@ -1650,6 +1650,7 @@ elseif(Haiku)
PRIVATE "media"
PRIVATE "device"
PRIVATE "bluetooth"
PRIVATE "GL"
PRIVATE "be"
PRIVATE "gnu"
)
Expand Down
38 changes: 38 additions & 0 deletions src/detection/opengl/opengl_haiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <OpenGLKit.h>

extern "C" {
#include "opengl.h"
#include "common/io/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);
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";
}

0 comments on commit 9018fda

Please sign in to comment.