diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 14fce1227..db74dced0 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1683,6 +1683,7 @@ typedef void (* GLFWjoystickfun)(int,int); typedef void (* GLFWuserdatafun)(unsigned long long, void*); typedef void (* GLFWtickcallback)(void*); +typedef void (* GLFWdrawtextfun)(const char *text, uint32_t fg, uint32_t bg, uint8_t *output_buf, size_t width, size_t height, float x_offset, float y_offset); /*! @brief Video mode type. * @@ -1839,6 +1840,7 @@ GLFWAPI void glfwStopMainLoop(void); GLFWAPI unsigned long long glfwAddTimer(monotonic_t interval, bool repeats, GLFWuserdatafun callback, void * callback_data, GLFWuserdatafun free_callback); GLFWAPI void glfwUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled); GLFWAPI void glfwRemoveTimer(unsigned long long); +GLFWAPI GLFWdrawtextfun glfwSetDrawTextFunction(GLFWdrawtextfun function); /*! @brief Terminates the GLFW library. * diff --git a/glfw/init.c b/glfw/init.c index 2ed62d5c1..c23a6d9fa 100644 --- a/glfw/init.c +++ b/glfw/init.c @@ -375,3 +375,10 @@ GLFWAPI GLFWapplicationclosefun glfwSetApplicationCloseCallback(GLFWapplicationc _GLFW_SWAP_POINTERS(_glfw.callbacks.application_close, cbfun); return cbfun; } + +GLFWAPI GLFWdrawtextfun glfwSetDrawTextFunction(GLFWdrawtextfun cbfun) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFW_SWAP_POINTERS(_glfw.callbacks.draw_text, cbfun); + return cbfun; +} diff --git a/glfw/internal.h b/glfw/internal.h index fa150cb1d..88cf83ebc 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -614,6 +614,7 @@ struct _GLFWlibrary GLFWmonitorfun monitor; GLFWjoystickfun joystick; GLFWapplicationclosefun application_close; + GLFWdrawtextfun draw_text; } callbacks; diff --git a/kitty/glfw-wrapper.c b/kitty/glfw-wrapper.c index e3251bfb8..1c78bba04 100644 --- a/kitty/glfw-wrapper.c +++ b/kitty/glfw-wrapper.c @@ -33,6 +33,9 @@ load_glfw(const char* path) { *(void **) (&glfwRemoveTimer_impl) = dlsym(handle, "glfwRemoveTimer"); if (glfwRemoveTimer_impl == NULL) fail("Failed to load glfw function glfwRemoveTimer with error: %s", dlerror()); + *(void **) (&glfwSetDrawTextFunction_impl) = dlsym(handle, "glfwSetDrawTextFunction"); + if (glfwSetDrawTextFunction_impl == NULL) fail("Failed to load glfw function glfwSetDrawTextFunction with error: %s", dlerror()); + *(void **) (&glfwTerminate_impl) = dlsym(handle, "glfwTerminate"); if (glfwTerminate_impl == NULL) fail("Failed to load glfw function glfwTerminate with error: %s", dlerror()); diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index 101cde393..cf4ffaffd 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -1421,6 +1421,7 @@ typedef void (* GLFWjoystickfun)(int,int); typedef void (* GLFWuserdatafun)(unsigned long long, void*); typedef void (* GLFWtickcallback)(void*); +typedef void (* GLFWdrawtextfun)(const char *text, uint32_t fg, uint32_t bg, uint8_t *output_buf, size_t width, size_t height, float x_offset, float y_offset); /*! @brief Video mode type. * @@ -1606,6 +1607,10 @@ typedef void (*glfwRemoveTimer_func)(unsigned long); GFW_EXTERN glfwRemoveTimer_func glfwRemoveTimer_impl; #define glfwRemoveTimer glfwRemoveTimer_impl +typedef GLFWdrawtextfun (*glfwSetDrawTextFunction_func)(GLFWdrawtextfun); +GFW_EXTERN glfwSetDrawTextFunction_func glfwSetDrawTextFunction_impl; +#define glfwSetDrawTextFunction glfwSetDrawTextFunction_impl + typedef void (*glfwTerminate_func)(void); GFW_EXTERN glfwTerminate_func glfwTerminate_impl; #define glfwTerminate glfwTerminate_impl