diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-31 12:50:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-31 12:50:20 +0300 |
commit | 05451849f8cec9ed91a213d5020cf6406ba94feb (patch) | |
tree | 7e14bb29478f69f48d832caef670cef0e49b9c8a /src/render/safeopenglgraphics.cpp | |
parent | 0e3e3df8c385ed8ad6e4612570016ffae03169a6 (diff) | |
download | manaplus-05451849f8cec9ed91a213d5020cf6406ba94feb.tar.gz manaplus-05451849f8cec9ed91a213d5020cf6406ba94feb.tar.bz2 manaplus-05451849f8cec9ed91a213d5020cf6406ba94feb.tar.xz manaplus-05451849f8cec9ed91a213d5020cf6406ba94feb.zip |
Improve drawNet in safeopenglgraphics.
Diffstat (limited to 'src/render/safeopenglgraphics.cpp')
-rw-r--r-- | src/render/safeopenglgraphics.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index 717e7d5bf..c988e6825 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -566,17 +566,37 @@ void SafeOpenGLGraphics::drawPoint(int x, int y) glEnd(); } -void SafeOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) +bool SafeOpenGLGraphics::drawNet(const int x1, const int y1, + const int x2, const int y2, + const int width, const int height) { setTexturingAndBlending(false); restoreColor(); glBegin(GL_LINES); - glVertex2f(static_cast<float>(x1) + 0.5F, static_cast<float>(y1) + 0.5F); - glVertex2f(static_cast<float>(x2) + 0.5F, static_cast<float>(y2) + 0.5F); + for (int y = y1; y < y2; y += height) + { + glVertex2f(static_cast<float>(x1) + 0.5F, static_cast<float>(y) + 0.5F); + glVertex2f(static_cast<float>(x2) + 0.5F, static_cast<float>(y) + 0.5F); + } + + for (int x = x1; x < x2; x += width) + { + glVertex2f(static_cast<float>(x) + 0.5F, static_cast<float>(y1) + 0.5F); + glVertex2f(static_cast<float>(x) + 0.5F, static_cast<float>(y2) + 0.5F); + } glEnd(); - glBegin(GL_POINTS); + return true; +} + +void SafeOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) +{ + setTexturingAndBlending(false); + restoreColor(); + + glBegin(GL_LINES); + glVertex2f(static_cast<float>(x1) + 0.5F, static_cast<float>(y1) + 0.5F); glVertex2f(static_cast<float>(x2) + 0.5F, static_cast<float>(y2) + 0.5F); glEnd(); } |