summaryrefslogtreecommitdiff
path: root/src/normalopenglgraphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-11-20 13:29:10 +0300
committerAndrei Karas <akaras@inbox.ru>2012-11-20 22:21:59 +0300
commit6637f4af57cd60008388bfefda1c37376c9d7042 (patch)
treeeb31d1c197c86583e5f2a525ca020de625f32919 /src/normalopenglgraphics.cpp
parentcadc0f8b6d0bd71f319c3e6576af05dcd0a7533f (diff)
downloadmanaverse-6637f4af57cd60008388bfefda1c37376c9d7042.tar.gz
manaverse-6637f4af57cd60008388bfefda1c37376c9d7042.tar.bz2
manaverse-6637f4af57cd60008388bfefda1c37376c9d7042.tar.xz
manaverse-6637f4af57cd60008388bfefda1c37376c9d7042.zip
Add debug option to show draw calls per frame.
Also fix map draw and text in debug window with mobile OpenGL.
Diffstat (limited to 'src/normalopenglgraphics.cpp')
-rw-r--r--src/normalopenglgraphics.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index 40cd5226b..188a57d69 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -40,6 +40,10 @@
#include "debug.h"
GLuint NormalOpenGLGraphics::mLastImage = 0;
+#ifdef DEBUG_DRAW_CALLS
+unsigned int NormalOpenGLGraphics::mDrawCalls = 0;
+unsigned int NormalOpenGLGraphics::mLastDrawCalls = 0;
+#endif
//unsigned int vertexBufSize = 500;
@@ -130,6 +134,9 @@ static inline void drawQuad(const Image *image,
glVertexPointer(2, GL_INT, 0, &vert);
glTexCoordPointer(2, GL_FLOAT, 0, &tex);
+#ifdef DEBUG_DRAW_CALLS
+ NormalOpenGLGraphics::mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, 4);
}
else
@@ -152,6 +159,9 @@ static inline void drawQuad(const Image *image,
glVertexPointer(2, GL_INT, 0, &vert);
glTexCoordPointer(2, GL_INT, 0, &tex);
+#ifdef DEBUG_DRAW_CALLS
+ NormalOpenGLGraphics::mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, 4);
}
}
@@ -192,6 +202,9 @@ static inline void drawRescaledQuad(const Image *const image,
glVertexPointer(2, GL_INT, 0, &vert);
glTexCoordPointer(2, GL_FLOAT, 0, &tex);
+#ifdef DEBUG_DRAW_CALLS
+ NormalOpenGLGraphics::mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, 4);
}
else
@@ -214,6 +227,9 @@ static inline void drawRescaledQuad(const Image *const image,
glVertexPointer(2, GL_INT, 0, &vert);
glTexCoordPointer(2, GL_INT, 0, &tex);
+#ifdef DEBUG_DRAW_CALLS
+ NormalOpenGLGraphics::mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, 4);
}
}
@@ -934,6 +950,10 @@ void NormalOpenGLGraphics::updateScreen()
BLOCK_START("Graphics::updateScreen")
// glFlush();
// glFinish();
+#ifdef DEBUG_DRAW_CALLS
+ mLastDrawCalls = mDrawCalls;
+ mDrawCalls = 0;
+#endif
SDL_GL_SwapBuffers();
// may be need clear?
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -1197,6 +1217,9 @@ void NormalOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect,
};
glVertexPointer(2, GL_FLOAT, 0, &vert);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(filled ? GL_QUADS : GL_LINE_LOOP, 0, 4);
BLOCK_END("Graphics::drawRectangle")
}
@@ -1268,6 +1291,9 @@ inline void NormalOpenGLGraphics::drawQuadArrayfi(int size)
glVertexPointer(2, GL_INT, 0, mIntVertArray);
glTexCoordPointer(2, GL_FLOAT, 0, mFloatTexArray);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1278,6 +1304,9 @@ inline void NormalOpenGLGraphics::drawQuadArrayfi(GLint *const intVertArray,
glVertexPointer(2, GL_INT, 0, intVertArray);
glTexCoordPointer(2, GL_FLOAT, 0, floatTexArray);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1286,6 +1315,9 @@ inline void NormalOpenGLGraphics::drawQuadArrayii(int size)
glVertexPointer(2, GL_INT, 0, mIntVertArray);
glTexCoordPointer(2, GL_INT, 0, mIntTexArray);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1296,6 +1328,9 @@ inline void NormalOpenGLGraphics::drawQuadArrayii(GLint *const intVertArray,
glVertexPointer(2, GL_INT, 0, intVertArray);
glTexCoordPointer(2, GL_INT, 0, intTexArray);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(GL_QUADS, 0, size / 2);
}
@@ -1303,6 +1338,9 @@ inline void NormalOpenGLGraphics::drawLineArrayi(int size)
{
glVertexPointer(2, GL_INT, 0, mIntVertArray);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(GL_LINES, 0, size / 2);
}
@@ -1310,6 +1348,9 @@ inline void NormalOpenGLGraphics::drawLineArrayf(int size)
{
glVertexPointer(2, GL_FLOAT, 0, mFloatTexArray);
+#ifdef DEBUG_DRAW_CALLS
+ mDrawCalls ++;
+#endif
glDrawArrays(GL_LINES, 0, size / 2);
}