From f2da59054cedd1c07779e72537da4d7b14616b48 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Aug 2024 06:01:36 +0200 Subject: Ensure correct blending function for transparent window --- include/mgl/gl_macro.h | 1 + include/mgl/mgl.h | 3 +++ include/mgl/window/window.h | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mgl/gl_macro.h b/include/mgl/gl_macro.h index cbecf94..ba2d3f1 100644 --- a/include/mgl/gl_macro.h +++ b/include/mgl/gl_macro.h @@ -18,6 +18,7 @@ #define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_BLEND 0x0BE2 +#define GL_ONE 1 #define GL_SRC_ALPHA 0x0302 #define GL_ONE_MINUS_SRC_ALPHA 0x0303 #define GL_TEXTURE_2D 0x0DE1 diff --git a/include/mgl/mgl.h b/include/mgl/mgl.h index 4e1a181..e314e03 100644 --- a/include/mgl/mgl.h +++ b/include/mgl/mgl.h @@ -6,10 +6,13 @@ /* Display* on x11 */ typedef void* mgl_connection; typedef struct mgl_context mgl_context; +typedef struct mgl_window mgl_window; struct mgl_context { mgl_connection connection; mgl_gl gl; + mgl_window *current_window; + unsigned long wm_delete_window_atom; unsigned long net_wm_ping_atom; unsigned long net_wm_pid_atom; diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h index eb7f587..23b780a 100644 --- a/include/mgl/window/window.h +++ b/include/mgl/window/window.h @@ -74,7 +74,7 @@ typedef struct { mgl_window_handle parent_window; /* 0 = root window */ bool hidden; /* false by default */ bool override_redirect; /* false by default */ - bool support_alpha; /* support alpha for the window, false by default */ + bool support_alpha; /* support alpha for the window, false by default. If this is set to true then you need to call mgl_window_set_texture_blend_func before rendering textures and call mgl_window_set_render_blend_func afterwards to ensure correct alpha blending */ bool hide_decorations; /* this is a hint, it may be ignored by the window manager, false by default */ mgl_color background_color; /* default: black */ const char *class_name; @@ -165,6 +165,9 @@ bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback, bool mgl_window_get_clipboard_string(mgl_window *self, char **str, size_t *size); void mgl_window_set_key_repeat_enabled(mgl_window *self, bool enabled); +void mgl_window_set_texture_blend_func(mgl_window *self); +void mgl_window_set_render_blend_func(mgl_window *self); + void mgl_window_flush(mgl_window *self); #endif /* MGL_WINDOW_H */ -- cgit v1.2.3