summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyprinus Carpio <cregams@gmail.com>2024-07-12 11:09:09 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-07-12 17:42:32 +0200
commitdac5f0ab391df9239b89b5dfe8de9587073caeec (patch)
tree6d07ef9524aea9558cbb9725b4f45939b908f91a
parent6ed7b56c798eea9ae36cfcc88c33235a26c9932d (diff)
gl_draw: fix drawing of text outside of viewport
-rw-r--r--src/gl_draw.cxx5
1 files changed, 5 insertions, 0 deletions
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();