From dac5f0ab391df9239b89b5dfe8de9587073caeec Mon Sep 17 00:00:00 2001 From: Cyprinus Carpio Date: Fri, 12 Jul 2024 11:09:09 +0200 Subject: gl_draw: fix drawing of text outside of viewport --- src/gl_draw.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 82ee2b95d..367990da5 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -510,6 +510,11 @@ void Fl_Gl_Window_Driver::draw_string_legacy(const char* str, int n) /** draws a utf8 string using an OpenGL texture */ void Fl_Gl_Window_Driver::draw_string_with_texture(const char* str, int n) { + // Check if the raster pos is valid. + // If it's not, then drawing it results in undefined behaviour (#1006, #1007). + GLint valid; + glGetIntegerv(GL_CURRENT_RASTER_POSITION_VALID, &valid); + if (!valid) return; Fl_Gl_Window *gwin = Fl_Window::current()->as_gl_window(); gl_scale = (gwin ? gwin->pixels_per_unit() : 1); if (!gl_fifo) gl_fifo = new gl_texture_fifo(); -- cgit v1.2.3