Skip to content

Commit 9018fda

Browse files
committed
OpenGL (Haiku): add support
1 parent 76b8b9a commit 9018fda

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ elseif(Haiku)
11601160
src/detection/memory/memory_haiku.c
11611161
src/detection/mouse/mouse_haiku.cpp
11621162
src/detection/netio/netio_haiku.cpp
1163-
src/detection/opengl/opengl_linux.c
1163+
src/detection/opengl/opengl_haiku.cpp
11641164
src/detection/os/os_haiku.c
11651165
src/detection/packages/packages_haiku.c
11661166
src/detection/poweradapter/poweradapter_nosupport.c
@@ -1650,6 +1650,7 @@ elseif(Haiku)
16501650
PRIVATE "media"
16511651
PRIVATE "device"
16521652
PRIVATE "bluetooth"
1653+
PRIVATE "GL"
16531654
PRIVATE "be"
16541655
PRIVATE "gnu"
16551656
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <OpenGLKit.h>
2+
3+
extern "C" {
4+
#include "opengl.h"
5+
#include "common/io/io.h"
6+
#if FF_HAVE_EGL
7+
const char* ffOpenGLDetectByEGL(FFOpenGLResult* result);
8+
#endif
9+
void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString);
10+
}
11+
12+
static const char* oglDetectOpenGL(FFOpenGLResult* result)
13+
{
14+
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
15+
FF_SUPPRESS_IO();
16+
17+
BGLView glView(BRect(), "ff_ogl_view", B_FOLLOW_NONE, B_WILL_DRAW, BGL_RGB);
18+
auto ffglGetString = (decltype(&glGetString)) glView.GetGLProcAddress("glGetString");
19+
if (!ffglGetString) return "glView.GetGLProcAddress() failed";
20+
ffOpenGLHandleResult(result, ffglGetString);
21+
return NULL;
22+
}
23+
24+
const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result)
25+
{
26+
if (options->library == FF_OPENGL_LIBRARY_AUTO)
27+
return oglDetectOpenGL(result);
28+
else if (options->library == FF_OPENGL_LIBRARY_EGL)
29+
{
30+
#if FF_HAVE_EGL
31+
return ffOpenGLDetectByEGL(result);
32+
#else
33+
return "fastfetch was compiled without egl support";
34+
#endif
35+
}
36+
else
37+
return "Unsupported OpenGL library";
38+
}

0 commit comments

Comments
 (0)