diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2013-01-28 05:26:36 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2013-01-28 05:26:36 +0400 |
commit | 3a1ee13278b21176482b98d86709a3bdd489d531 (patch) | |
tree | cc2eedec28b5e8bba5062db0fedf5d07930e5efc /source/gameengine/GamePlayer/common | |
parent | f64124cb781fee2366f1c5db4f0068420f874556 (diff) |
BGE Profile : visual feedback bars and improvements
You can see a screenshot of the funcionality here:
http://wiki.blender.org/index.php/Doc:2.6/manual/Game_Engine/Performance/Display/Framerate_and_Profile
This patch creates a bar-like graph to quickly allow the game dev to see the performance changes.
Also it changes the font to monospace (too allow ' ' padding) and reduced shadow border to
match the blenderplayer one.
Patch finalized and commited at Global Game Jam Vancouver (last one, time to sleep forever now)
Diffstat (limited to 'source/gameengine/GamePlayer/common')
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 72 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/common/GPC_RenderTools.h | 6 |
2 files changed, 78 insertions, 0 deletions
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index dfc866526eb..bab4aa14bbd 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -283,6 +283,78 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in } } +void GPC_RenderTools::RenderBox2D(int xco, + int yco, + int width, + int height, + float percentage) +{ + // Save and change OpenGL settings + int texture2D; + glGetIntegerv(GL_TEXTURE_2D, (GLint*)&texture2D); + glDisable(GL_TEXTURE_2D); + int fog; + glGetIntegerv(GL_FOG, (GLint*)&fog); + glDisable(GL_FOG); + + int light; + glGetIntegerv(GL_LIGHTING, (GLint*)&light); + glDisable(GL_LIGHTING); + + glDisable(GL_DEPTH_TEST); + + // Set up viewing settings + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, width, 0, height, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + yco = height - yco; + int barsize = 50; + + // draw in black first + glColor3ub(0, 0, 0); + glBegin(GL_QUADS); + glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1 + 10); + glVertex2f(xco + 1, yco - 1 + 10); + glVertex2f(xco + 1, yco - 1); + glVertex2f(xco + 1 + 1 + barsize * percentage, yco - 1); + glEnd(); + + glColor3ub(255, 255, 255); + glBegin(GL_QUADS); + glVertex2f(xco + 1 + barsize * percentage, yco + 10); + glVertex2f(xco, yco + 10); + glVertex2f(xco, yco); + glVertex2f(xco + 1 + barsize * percentage, yco); + glEnd(); + + // Restore view settings + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + // Restore OpenGL Settings + if (fog) + glEnable(GL_FOG); + else + glDisable(GL_FOG); + + if (texture2D) + glEnable(GL_TEXTURE_2D); + else + glDisable(GL_TEXTURE_2D); + if (light) + glEnable(GL_LIGHTING); + else + glDisable(GL_LIGHTING); +} + + void GPC_RenderTools::RenderText3D( int fontid, const char* text, int size, diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 1030c09548a..f4dcddd3250 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -70,6 +70,12 @@ public: void DisableOpenGLLights(); void ProcessLighting(RAS_IRasterizer *rasty, bool uselights, const MT_Transform& viewmat); + void RenderBox2D(int xco, + int yco, + int width, + int height, + float percentage); + void RenderText3D(int fontid, const char* text, int size, |