diff options
author | PoroCYon <pcy@national.shitposting.agency> | 2019-05-26 00:38:24 +0200 |
---|---|---|
committer | PoroCYon <pcy@national.shitposting.agency> | 2019-05-26 00:38:24 +0200 |
commit | 38f61a24fcdf5a78cbabc9184f55ded3b496f1d4 (patch) | |
tree | dd16419db7c9b8cebbdfea58e216b328e73047ea /src/libui_sdl/libui/unix/gl.c | |
parent | 31e0f15797d0b6545ddc1a361252f267bf5d793d (diff) |
'port' libui GL stuff to Linux
Only implemented the functions needed by melonDS, and only tested using
a very recent mesa+libglvnd+nouveau. Will most likely bork using
proprietary nvidia or old(er) drivers (see gl.c)
Diffstat (limited to 'src/libui_sdl/libui/unix/gl.c')
-rw-r--r-- | src/libui_sdl/libui/unix/gl.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/libui_sdl/libui/unix/gl.c b/src/libui_sdl/libui/unix/gl.c new file mode 100644 index 0000000..da41437 --- /dev/null +++ b/src/libui_sdl/libui/unix/gl.c @@ -0,0 +1,47 @@ +// 26 may 2019 +#include "uipriv_unix.h" + +/* + *(melonDS:17013): Gtk-CRITICAL **: 00:28:09.095: gtk_gl_area_set_required_version: assertion 'GTK_IS_GL_AREA (area)' failed + +(melonDS:17013): GLib-GObject-WARNING **: 00:28:09.096: invalid cast from 'GtkGLArea' to 'areaWidget' + */ + +struct uiGLContext { + GtkGLArea *gla; + GdkGLContext *gctx; + int vermaj, vermin; +}; + +uiGLContext *createGLContext(GtkGLArea* gla, int maj, int min) +{ + uiGLContext *ret = uiAlloc(sizeof(uiGLContext), "uiGLContext"); + ret->gla = gla; + ret->gctx = gtk_gl_area_get_context(gla); + ret->vermaj = maj; ret->vermin = min; + return ret; +} + +void uiGLSwapBuffers(uiGLContext* ctx) +{ + if (!ctx) return; + gtk_gl_area_attach_buffers(ctx->gla); +} + +void uiGLMakeContextCurrent(uiGLContext* ctx) +{ + if (!ctx) return; + gtk_gl_area_make_current(ctx->gla); +} +void *uiGLGetProcAddress(const char* proc) +{ + // this *will* break for older systems that don't have libglvnd! + // TODO: use a real solution + return dlsym(NULL /* RTLD_DEFAULT */, proc); +} +unsigned int uiGLGetVersion(uiGLContext* ctx) +{ + if (!ctx) return 0; + return uiGLVersion(ctx->vermaj, ctx->vermin); +} + |