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/BlenderRoutines | |
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/BlenderRoutines')
4 files changed, 71 insertions, 3 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index f8ad8870e83..3a9a10dd0cc 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -121,6 +121,50 @@ static void DisableForText() } } +void BL_draw_gamedebug_box(int xco, int yco, int width, int height, float percentage) +{ + /* This is a rather important line :( The gl-mode hasn't been left + * behind quite as neatly as we'd have wanted to. I don't know + * what cause it, though :/ .*/ + glDisable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glOrtho(0, width, 0, height, -100, 100); + + 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(); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glEnable(GL_DEPTH_TEST); +} + /* Print 3D text */ void BL_print_game_line(int fontid, const char* text, int size, int dpi, float* color, double* mat, float aspect) { @@ -164,7 +208,9 @@ void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int /* the actual drawing */ glColor3ub(255, 255, 255); - BLF_draw_default((float)xco, (float)(height-yco), 0.0f, (char *)text, 65535); /* XXX, use real len */ + BLF_size(blf_mono_font, 11, 72); + BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f); + BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */ glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -193,9 +239,13 @@ void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int widt /* draw in black first*/ glColor3ub(0, 0, 0); - BLF_draw_default((float)(xco+2), (float)(height-yco-2), 0.0f, text, 65535); /* XXX, use real len */ + BLF_size(blf_mono_font, 11, 72); + BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f); + BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */ + glColor3ub(255, 255, 255); - BLF_draw_default((float)xco, (float)(height-yco), 0.0f, text, 65535); /* XXX, use real len */ + BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f); + BLF_draw(blf_mono_font, (char *)text, 65535); glMatrixMode(GL_PROJECTION); glPopMatrix(); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index 7ba612b19cf..5c3f0684764 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -50,6 +50,7 @@ void BL_HideMouse(struct wmWindow *win); void BL_NormalMouse(struct wmWindow *win); void BL_WaitMouse(struct wmWindow *win); +void BL_draw_gamedebug_box(int xco, int yco, int width, int height, float percentage); void BL_print_game_line(int fontid, const char* text, int size, int dpi, float* color, double* mat, float aspect); void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height); void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index e32239b148d..64ed384e961 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -280,6 +280,16 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat } } } + +void KX_BlenderRenderTools::RenderBox2D(int xco, + int yco, + int width, + int height, + float percentage) +{ + BL_draw_gamedebug_box(xco, yco, width, height, percentage); +} + void KX_BlenderRenderTools::RenderText3D(int fontid, const char* text, int size, diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 7195524ceae..228763e7d2d 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -71,6 +71,13 @@ 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, |