From 49ac7d74292339fe9d52ce19de23d0ce25fa9bd1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 21 Apr 2023 20:59:06 +0200 Subject: Add code to copy cursor image to opengl texture and update on event update (not used yet) --- include/cursor.h | 28 ++++++++++++++++++++++++++++ include/egl.h | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 include/cursor.h (limited to 'include') diff --git a/include/cursor.h b/include/cursor.h new file mode 100644 index 0000000..0a7831d --- /dev/null +++ b/include/cursor.h @@ -0,0 +1,28 @@ +#ifndef GSR_CURSOR_H +#define GSR_CURSOR_H + +#include "egl.h" +#include "vec2.h" + +#include + +typedef struct { + gsr_egl *egl; + Display *display; + Window window; + int x_fixes_event_base; + + unsigned int texture_id; + vec2i size; + vec2i hotspot; + + bool cursor_image_set; +} gsr_cursor; + +int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display); +void gsr_cursor_deinit(gsr_cursor *self); + +int gsr_cursor_change_window_target(gsr_cursor *self, Window window); +void gsr_cursor_update(gsr_cursor *self, XEvent *xev); + +#endif /* GSR_CURSOR_H */ diff --git a/include/egl.h b/include/egl.h index 891c7a0..0d291d0 100644 --- a/include/egl.h +++ b/include/egl.h @@ -58,12 +58,15 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define GL_TRIANGLES 0x0004 #define GL_TEXTURE_2D 0x0DE1 #define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_RGBA8 0x8058 #define GL_UNSIGNED_BYTE 0x1401 #define GL_COLOR_BUFFER_BIT 0x00004000 #define GL_TEXTURE_WRAP_S 0x2802 #define GL_TEXTURE_WRAP_T 0x2803 #define GL_TEXTURE_MAG_FILTER 0x2800 #define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TEXTURE_HEIGHT 0x1001 #define GL_NEAREST 0x2600 @@ -126,6 +129,7 @@ typedef struct { void (*glTexImage2D)(unsigned int target, int level, int internalFormat, int width, int height, int border, unsigned int format, unsigned int type, const void *pixels); void (*glCopyImageSubData)(unsigned int srcName, unsigned int srcTarget, int srcLevel, int srcX, int srcY, int srcZ, unsigned int dstName, unsigned int dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int srcWidth, int srcHeight, int srcDepth); void (*glClearTexImage)(unsigned int texture, unsigned int level, unsigned int format, unsigned int type, const void *data); + void (*glGenerateMipmap)(unsigned int target); void (*glGenFramebuffers)(int n, unsigned int *framebuffers); void (*glBindFramebuffer)(unsigned int target, unsigned int framebuffer); void (*glDeleteFramebuffers)(int n, const unsigned int *framebuffers); -- cgit v1.2.3