aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-10 12:56:55 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-10 13:18:12 +0200
commit3b2fceed064c06d55e1cd33d51e855e909c81f75 (patch)
tree962611955ddac906d906af1b44076d7cfae2bb64 /include
parente57daa001cc74682cdb905d8e0c6c8c3a2c29372 (diff)
add event and test graphics
Diffstat (limited to 'include')
-rw-r--r--include/mgl/gl.h14
-rw-r--r--include/mgl/glx.h10
-rw-r--r--include/mgl/mgl.h4
-rw-r--r--include/mgl/window.h17
4 files changed, 40 insertions, 5 deletions
diff --git a/include/mgl/gl.h b/include/mgl/gl.h
new file mode 100644
index 0000000..1791059
--- /dev/null
+++ b/include/mgl/gl.h
@@ -0,0 +1,14 @@
+#ifndef MGL_GL_H
+#define MGL_GL_H
+
+typedef struct {
+ void *handle;
+ void (*glViewport)(int x, int y, int width, int height);
+ void (*glClearColor)(float red, float green, float blue, float alpha);
+ void (*glClear)(unsigned int mask);
+} mgl_gl;
+
+int mgl_gl_load(mgl_gl *self);
+void mgl_gl_unload(mgl_gl *self);
+
+#endif /* MGL_GL_H */
diff --git a/include/mgl/glx.h b/include/mgl/glx.h
index dfb736d..4197402 100644
--- a/include/mgl/glx.h
+++ b/include/mgl/glx.h
@@ -1,12 +1,18 @@
#ifndef MGL_GLX_H
#define MGL_GLX_H
+typedef struct _XVisualInfo _XVisualInfo;
typedef struct _XDisplay Display;
-typedef struct __GLXFBConfigRec *GLXFBConfig;
+typedef struct __GLXcontextRec *GLXContext;
+typedef unsigned long GLXDrawable;
typedef struct {
void *handle;
- GLXFBConfig* (*glXGetFBConfigs)(Display *dpy, int screen, int *nelements);
+ _XVisualInfo* (*glXChooseVisual)(Display *dpy, int screen, int *attribList);
+ GLXContext (*glXCreateContext)(Display *dpy, _XVisualInfo *vis, GLXContext shareList, int direct);
+ void (*glXDestroyContext)(Display *dpy, GLXContext ctx);
+ int (*glXMakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
+ void (*glXSwapBuffers)(Display *dpy, GLXDrawable drawable);
} mgl_glx;
int mgl_glx_load(mgl_glx *self);
diff --git a/include/mgl/mgl.h b/include/mgl/mgl.h
index d896497..606c14b 100644
--- a/include/mgl/mgl.h
+++ b/include/mgl/mgl.h
@@ -2,13 +2,17 @@
#define MGL_MGL_H
#include "glx.h"
+#include "gl.h"
/* Display* on x11 */
typedef void* mgl_connection;
typedef struct {
mgl_connection connection;
+ GLXContext glx_context;
+ _XVisualInfo *visual_info;
mgl_glx glx;
+ mgl_gl gl;
} mgl_context;
/*
diff --git a/include/mgl/window.h b/include/mgl/window.h
index bd29936..c6dc9e2 100644
--- a/include/mgl/window.h
+++ b/include/mgl/window.h
@@ -1,12 +1,23 @@
#ifndef MGL_WINDOW_H
#define MGL_WINDOW_H
+typedef struct mgl_window mgl_window;
+
typedef struct {
- int booba;
-} mgl_window;
+ void (*draw)(mgl_window *window, void *userdata);
+} mgl_window_callback;
+
+struct mgl_window {
+ unsigned long window;
+ mgl_window_callback callback;
+ void *callback_userdata;
+};
-void mgl_window_init(mgl_window *self);
+int mgl_window_create(mgl_window *self, const char *title, int width, int height, mgl_window_callback *callback, void *userdata);
+int mgl_window_create_with_params(mgl_window *self, const char *title, int width, int height, unsigned long parent_window, mgl_window_callback *callback, void *userdata);
void mgl_window_deinit(mgl_window *self);
+
void mgl_window_show(mgl_window *self);
+void mgl_window_event_poll(mgl_window *self, int timeout_ms);
#endif /* MGL_WINDOW_H */