diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-12 20:09:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-12 20:09:23 +0300 |
commit | 19d9c94b2c0fc5585fdba7aa0b7756be1be88f40 (patch) | |
tree | 3b991f33e2eeb0860e83f30a3820be51ec238225 | |
parent | 0a28edcfc315f4e907fa8f37efe3300efe88c8b8 (diff) | |
download | manaplus-19d9c94b2c0fc5585fdba7aa0b7756be1be88f40.tar.gz manaplus-19d9c94b2c0fc5585fdba7aa0b7756be1be88f40.tar.bz2 manaplus-19d9c94b2c0fc5585fdba7aa0b7756be1be88f40.tar.xz manaplus-19d9c94b2c0fc5585fdba7aa0b7756be1be88f40.zip |
In modernopengl add drawnet function.
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 66 | ||||
-rw-r--r-- | src/render/modernopenglgraphics.h | 2 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index 3d4cf68a1..e92002e92 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -903,6 +903,62 @@ bool ModernOpenGLGraphics::drawNet(const int x1, const int y1, const int x2, const int y2, const int width, const int height) { + unsigned int vp = 0; + const unsigned int vLimit = mMaxVertices * 4; + + setTexturingAndBlending(false); + const ClipRect &clipArea = mClipStack.top(); + const GLfloat dx = clipArea.xOffset; + const GLfloat dy = clipArea.yOffset; + + const GLfloat xs1 = static_cast<GLfloat>(x1) + dx; + const GLfloat xs2 = static_cast<GLfloat>(x2) + dx; + const GLfloat ys1 = static_cast<GLfloat>(y1) + dy; + const GLfloat ys2 = static_cast<GLfloat>(y2) + dy; + + for (int y = y1; y < y2; y += height) + { + mFloatArray[vp + 0] = xs1; + mFloatArray[vp + 1] = y; + mFloatArray[vp + 2] = 0.0f; + mFloatArray[vp + 3] = 0.0f; + + mFloatArray[vp + 4] = xs2; + mFloatArray[vp + 5] = y; + mFloatArray[vp + 6] = 0.0f; + mFloatArray[vp + 7] = 0.0f; + + vp += 8; + if (vp >= vLimit) + { + drawLineArrays(vp); + vp = 0; + } + } + + for (int x = x1; x < x2; x += width) + { + mFloatArray[vp + 0] = x; + mFloatArray[vp + 1] = ys1; + mFloatArray[vp + 2] = 0.0f; + mFloatArray[vp + 3] = 0.0f; + + mFloatArray[vp + 4] = x; + mFloatArray[vp + 5] = ys2; + mFloatArray[vp + 6] = 0.0f; + mFloatArray[vp + 7] = 0.0f; + + vp += 8; + if (vp >= vLimit) + { + drawLineArrays(vp); + vp = 0; + } + } + + if (vp > 0) + drawLineArrays(vp); + return true; } @@ -964,6 +1020,16 @@ void ModernOpenGLGraphics::drawTriangleArray(const int size) glDrawArrays(GL_TRIANGLES, 0, size / 4); } +void ModernOpenGLGraphics::drawLineArrays(const int size) +{ + mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat), + mFloatArray, GL_DYNAMIC_DRAW); +#ifdef DEBUG_DRAW_CALLS + mDrawCalls ++; +#endif + glDrawArrays(GL_LINES, 0, size / 4); +} + #ifdef DEBUG_BIND_TEXTURE void ModernOpenGLGraphics::debugBindTexture(const Image *const image) { diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h index fec209a7e..3528462a8 100644 --- a/src/render/modernopenglgraphics.h +++ b/src/render/modernopenglgraphics.h @@ -87,6 +87,8 @@ class ModernOpenGLGraphics final : public Graphics inline void drawTriangleArray(const int size); + inline void drawLineArrays(const int size); + GLfloat *mFloatArray; GLfloat *mFloatArrayCached; ShaderProgram *mProgram; |