diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-03-18 20:14:39 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-03-18 20:14:39 +0100 |
| commit | f9004352b42b3b039c391d5a8c83930c9b49b53a (patch) | |
| tree | 43cdc4f9e8773702cf784d980a691229246e1d19 | |
| parent | 5c482f9d9b357e098f955351f425bc985254ff28 (diff) | |
Fix gl_rect and OGL::fl_point #688
| -rw-r--r-- | src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx | 12 | ||||
| -rw-r--r-- | src/gl_draw.cxx | 10 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx index 22956605c..044b16450 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_rect.cxx @@ -31,9 +31,15 @@ // --- line and polygon drawing with integer coordinates void Fl_OpenGL_Graphics_Driver::point(int x, int y) { - glBegin(GL_POINTS); - glVertex2f(x+0.5f, y+0.5f); - glEnd(); + if (line_width_ == 1.0f) { + glBegin(GL_POINTS); + glVertex2f(x+0.5f, y+0.5f); + glEnd(); + } else { + float offset = line_width_ / 2.0f; + float xx = x+0.5f, yy = y+0.5f; + glRectf(xx-offset, yy-offset, xx+offset, yy+offset); + } } void Fl_OpenGL_Graphics_Driver::rect(int x, int y, int w, int h) { diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 35b2007f8..e6adaa1c7 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -216,12 +216,12 @@ void gl_measure(const char* str, int& x, int& y) { void gl_rect(int x, int y, int w, int h) { if (w < 0) {w = -w; x = x-w;} if (h < 0) {h = -h; y = y-h;} - glBegin(GL_LINE_STRIP); - glVertex2i(x+w-1, y+h-1); - glVertex2i(x+w-1, y); + glBegin(GL_LINE_LOOP); + int r = x+w-1, b = y+h-1; + glVertex2i(r, b); + glVertex2i(r, y); glVertex2i(x, y); - glVertex2i(x, y+h-1); - glVertex2i(x+w, y+h-1); + glVertex2i(x, b); glEnd(); } |
