aboutsummaryrefslogtreecommitdiff
path: root/src/egl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl.h')
-rw-r--r--src/egl.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/egl.h b/src/egl.h
new file mode 100644
index 0000000..52422bc
--- /dev/null
+++ b/src/egl.h
@@ -0,0 +1,52 @@
+#ifndef GSR_EGL_H
+#define GSR_EGL_H
+
+/* OpenGL EGL library with a hidden window context (to allow using the opengl functions) */
+
+#include <X11/X.h>
+#include <X11/Xutil.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+typedef void* EGLDisplay;
+typedef void* EGLSurface;
+typedef void* EGLContext;
+typedef void* EGLConfig;
+typedef void* EGLNativeDisplayType;
+typedef uintptr_t EGLNativeWindowType;
+
+#define EGL_BUFFER_SIZE 0x3020
+#define EGL_RENDERABLE_TYPE 0x3040
+#define EGL_OPENGL_ES2_BIT 0x0004
+#define EGL_NONE 0x3038
+#define EGL_CONTEXT_CLIENT_VERSION 0x3098
+
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+
+typedef struct {
+ void *egl_library;
+ void *gl_library;
+ Display *dpy;
+ EGLDisplay egl_display;
+ EGLSurface egl_surface;
+ EGLContext egl_context;
+ Window window;
+
+ EGLDisplay (*eglGetDisplay)(EGLNativeDisplayType display_id);
+ unsigned int (*eglInitialize)(EGLDisplay dpy, int32_t *major, int32_t *minor);
+ unsigned int (*eglTerminate)(EGLDisplay dpy);
+ unsigned int (*eglChooseConfig)(EGLDisplay dpy, const int32_t *attrib_list, EGLConfig *configs, int32_t config_size, int32_t *num_config);
+ EGLSurface (*eglCreateWindowSurface)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const int32_t *attrib_list);
+ EGLContext (*eglCreateContext)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const int32_t *attrib_list);
+ unsigned int (*eglMakeCurrent)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+ unsigned int (*eglDestroyContext)(EGLDisplay dpy, EGLContext ctx);
+ unsigned int (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
+
+ const unsigned char* (*glGetString)(unsigned int name);
+} gsr_egl;
+
+bool gsr_egl_load(gsr_egl *self, Display *dpy);
+void gsr_egl_unload(gsr_egl *self);
+
+#endif /* GSR_EGL_H */