summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-31 12:50:20 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-31 12:50:20 +0300
commit05451849f8cec9ed91a213d5020cf6406ba94feb (patch)
tree7e14bb29478f69f48d832caef670cef0e49b9c8a
parent0e3e3df8c385ed8ad6e4612570016ffae03169a6 (diff)
downloadplus-05451849f8cec9ed91a213d5020cf6406ba94feb.tar.gz
plus-05451849f8cec9ed91a213d5020cf6406ba94feb.tar.bz2
plus-05451849f8cec9ed91a213d5020cf6406ba94feb.tar.xz
plus-05451849f8cec9ed91a213d5020cf6406ba94feb.zip
Improve drawNet in safeopenglgraphics.
-rw-r--r--src/render/safeopenglgraphics.cpp28
-rw-r--r--src/render/safeopenglgraphics.h4
2 files changed, 28 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();
}
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
index 36ce27ded..c4bfd46de 100644
--- a/src/render/safeopenglgraphics.h
+++ b/src/render/safeopenglgraphics.h
@@ -59,6 +59,10 @@ class SafeOpenGLGraphics final : public Graphics
void drawImageRect(int x, int y, int w, int h,
const ImageRect &imgRect);
+ bool drawNet(const int x1, const int y1,
+ const int x2, const int y2,
+ const int width, const int height) override final;
+
protected:
void setTexturingAndBlending(const bool enable);