aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/backend/graphics.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/backend/graphics.c')
-rw-r--r--src/graphics/backend/graphics.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/graphics/backend/graphics.c b/src/graphics/backend/graphics.c
new file mode 100644
index 0000000..792894e
--- /dev/null
+++ b/src/graphics/backend/graphics.c
@@ -0,0 +1,54 @@
+#include "../../../include/mgl/graphics/backend/graphics.h"
+#include "../../../include/mgl/graphics/backend/glx.h"
+#include "../../../include/mgl/graphics/backend/egl.h"
+
+#include <string.h>
+
+bool mgl_graphics_init(mgl_graphics *self, const mgl_graphics_create_params *params) {
+ memset(self, 0, sizeof(*self));
+ self->graphics_api = params ? params->graphics_api : MGL_GRAPHICS_API_EGL;
+ self->alpha = params && params->alpha;
+
+ switch(self->graphics_api) {
+ case MGL_GRAPHICS_API_GLX:
+ return mgl_graphics_glx_init(self);
+ case MGL_GRAPHICS_API_EGL:
+ return mgl_graphics_egl_init(self);
+ }
+ return false;
+}
+
+void mgl_graphics_deinit(mgl_graphics *self) {
+ if(self->deinit)
+ self->deinit(self);
+}
+
+bool mgl_graphics_make_context_current(mgl_graphics *self, mgl_window_handle window) {
+ return self->make_context_current(self, window);
+}
+
+void mgl_graphics_swap_buffers(mgl_graphics *self, mgl_window_handle window) {
+ self->swap_buffers(self, window);
+}
+
+bool mgl_graphics_set_swap_interval(mgl_graphics *self, mgl_window_handle window, bool enabled) {
+ return self->set_swap_interval(self, window, enabled);
+}
+
+void* mgl_graphics_get_xvisual_info(mgl_graphics *self) {
+ return self->get_xvisual_info(self);
+}
+
+void* mgl_graphics_get_display(mgl_graphics *self) {
+ if(self->get_display)
+ return self->get_display(self);
+ else
+ return NULL;
+}
+
+void* mgl_graphics_get_context(mgl_graphics *self) {
+ if(self->get_context)
+ return self->get_context(self);
+ else
+ return NULL;
+}