aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-16 07:34:47 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-16 07:34:47 +0200
commit1952897a8cb411d9b10d75ac6a8c223924c07e09 (patch)
tree098414ec3216870a7e4145ba6d4c0c77c9206880 /src
parent97f1b1c735775d1e22412bbcf98ef403f9ee2275 (diff)
Fix resize event sometimes not triggered (set window gravity)
Diffstat (limited to 'src')
-rw-r--r--src/graphics/texture.c4
-rw-r--r--src/window.c3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/graphics/texture.c b/src/graphics/texture.c
index ebc4e58..b3a1fab 100644
--- a/src/graphics/texture.c
+++ b/src/graphics/texture.c
@@ -41,7 +41,7 @@ static int mgl_texture_format_to_source_opengl_format(mgl_texture_format format)
/* TODO: Ensure texture is power of 2 if the hardware doesn't support non power of two textures */
/* TODO: Verify if source format should always be 4 components (RGBA) because apparently if its another format then opengl will internally convert it to RGBA */
-int mgl_texture_load_from_file(mgl_texture *self, const char *filepath) {
+int mgl_texture_load_from_file(mgl_texture *self, const char *filepath, mgl_texture_load_options *load_options) {
self->id = 0;
int format;
@@ -59,7 +59,7 @@ int mgl_texture_load_from_file(mgl_texture *self, const char *filepath) {
return -1;
}
- const int opengl_texture_format = mgl_texture_format_to_compressed_opengl_format(self->format);
+ const int opengl_texture_format = load_options && load_options->compressed ? mgl_texture_format_to_compressed_opengl_format(self->format) : mgl_texture_format_to_opengl_format(self->format);
context->gl.glBindTexture(GL_TEXTURE_2D, self->id);
context->gl.glTexImage2D(GL_TEXTURE_2D, 0, opengl_texture_format, self->width, self->height, 0, mgl_texture_format_to_source_opengl_format(self->format), GL_UNSIGNED_BYTE, image_data);
diff --git a/src/window.c b/src/window.c
index 818805d..62f7e88 100644
--- a/src/window.c
+++ b/src/window.c
@@ -56,8 +56,9 @@ int mgl_window_create_with_params(mgl_window *self, const char *title, int width
XSetWindowAttributes window_attr;
window_attr.colormap = color_map;
window_attr.event_mask = KeyPressMask | StructureNotifyMask;
+ window_attr.bit_gravity = NorthWestGravity;
- self->window = XCreateWindow(context->connection, parent_window, 0, 0, width, height, 0, ((XVisualInfo*)context->visual_info)->depth, InputOutput, ((XVisualInfo*)context->visual_info)->visual, CWColormap | CWEventMask, &window_attr);
+ self->window = XCreateWindow(context->connection, parent_window, 0, 0, width, height, 0, ((XVisualInfo*)context->visual_info)->depth, InputOutput, ((XVisualInfo*)context->visual_info)->visual, CWColormap | CWEventMask | CWBitGravity, &window_attr);
XFreeColormap(context->connection, color_map);
if(!self->window) {
fprintf(stderr, "XCreateWindow failed\n");