aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--include/mgl/window/window.h (renamed from include/mgl/window.h)3
-rw-r--r--src/mgl.c1
-rw-r--r--src/window.c7
4 files changed, 7 insertions, 5 deletions
diff --git a/README.md b/README.md
index 9d567aa..fa9db3b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,6 @@
# Minimal Graphics Library
Written in C and uses legacy OpenGL to support as many platforms as possible.\
Right now mgl only supports x11.
-
# Dependencies
## Build
`xlib`
diff --git a/include/mgl/window.h b/include/mgl/window/window.h
index 0184577..5232260 100644
--- a/include/mgl/window.h
+++ b/include/mgl/window/window.h
@@ -1,7 +1,7 @@
#ifndef MGL_WINDOW_H
#define MGL_WINDOW_H
-#include "system/vec.h"
+#include "../system/vec.h"
typedef struct mgl_window mgl_window;
@@ -18,6 +18,7 @@ struct mgl_window {
};
int mgl_window_create(mgl_window *self, const char *title, int width, int height, mgl_window_callback *callback);
+/* if |parent_window| is 0 then the root window is used */
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 mgl_window_deinit(mgl_window *self);
diff --git a/src/mgl.c b/src/mgl.c
index cbdfb41..549121f 100644
--- a/src/mgl.c
+++ b/src/mgl.c
@@ -89,7 +89,6 @@ void mgl_deinit(void) {
if(init_count == 1) {
glx_context_deinit();
mgl_gl_unload(&context.gl);
- mgl_gl_unload(&context.gl);
XSetErrorHandler(prev_xerror);
if(context.connection) {
XCloseDisplay(context.connection);
diff --git a/src/window.c b/src/window.c
index 5e09261..8042ad3 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,4 +1,4 @@
-#include "../include/mgl/window.h"
+#include "../include/mgl/window/window.h"
#include "../include/mgl/mgl.h"
#include <X11/Xutil.h>
#include <errno.h>
@@ -38,7 +38,7 @@ static void mgl_window_on_resize(mgl_window *self, int width, int height) {
}
int mgl_window_create(mgl_window *self, const char *title, int width, int height, mgl_window_callback *callback) {
- return mgl_window_create_with_params(self, title, width, height, DefaultRootWindow(mgl_get_context()->connection), callback);
+ return mgl_window_create_with_params(self, title, width, height, 0, callback);
}
int mgl_window_create_with_params(mgl_window *self, const char *title, int width, int height, unsigned long parent_window, mgl_window_callback *callback) {
@@ -47,6 +47,9 @@ int mgl_window_create_with_params(mgl_window *self, const char *title, int width
mgl_context *context = mgl_get_context();
+ if(parent_window == 0)
+ parent_window = DefaultRootWindow(context->connection);
+
Colormap color_map = XCreateColormap(context->connection, DefaultRootWindow(context->connection), ((XVisualInfo*)context->visual_info)->visual, AllocNone);
if(!color_map) {
fprintf(stderr, "XCreateColormap failed\n");