diff options
| author | gigaherz <gigaherz@gmail.com> | 2008-08-08 22:04:02 +0000 |
|---|---|---|
| committer | gigaherz <gigaherz@gmail.com> | 2008-08-08 22:04:02 +0000 |
| commit | a1f48fee94b949496cb0fb05ee55fb288d498bbb (patch) | |
| tree | f734a9d0d791f2707bb24dc359eb4f51263e355c /Source | |
| parent | 627695c667a7b8f2b0165f3a24cdadaf43b44f3d (diff) | |
Added a method to rasterfont, to parse strings for newlines. Fixes the statistics overlay in opengl plugin.
The string stuff is somewhat WIP, as I want to add support for TAB character handling (and maybe others).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@156 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 5 | ||||
| -rw-r--r-- | Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp | 37 | ||||
| -rw-r--r-- | Source/Plugins/Plugin_VideoOGL/Src/rasterfont.h | 2 |
3 files changed, 42 insertions, 2 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 81ab42a067..32ddd29563 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -353,7 +353,8 @@ void Renderer::ProcessMessages() int left = 25, top = 15;
list<MESSAGE>::iterator it = s_listMsgs.begin();
- while( it != s_listMsgs.end() ) {
+ while( it != s_listMsgs.end() )
+ {
DrawText(it->str, left+1, top+1, 0xff000000);
DrawText(it->str, left, top, 0xffffff30);
top += 15;
@@ -368,7 +369,7 @@ void Renderer::ProcessMessages() void Renderer::DrawText(const char* pstr, int left, int top, u32 color)
{
glColor3f(((color>>16) & 0xff)/255.0f, ((color>>8) & 0xff)/255.0f, (color & 0xff)/255.0f);
- s_pfont->printString(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0);
+ s_pfont->printStuff(pstr, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight,0,nBackbufferHeight);
}
void Renderer::SetAA(int aa)
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp b/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp index 70cdc2817f..9bacf0ca09 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.cpp @@ -172,3 +172,40 @@ void RasterFont::printCenteredString(const char *s, double y, int screen_width, printString(s, x, y, z);
}
+void RasterFont::printStuff(const char *text, double x, double start_y, double z, int bbHeight)
+{
+ double y=start_y;
+
+ static char temp[1024];
+ char* t = temp;
+
+ while(*text)
+ {
+ if(*text=='\n')
+ {
+ *t=0;
+ printString(temp,x,y,z);
+ y-=char_height * 2.0f / bbHeight;
+ t=temp;
+ }
+ else if(*text=='\r')
+ {
+ t=temp;
+ }
+ else if(*text=='\t')
+ {
+ //todo: add tabs every something like 4*char_width
+ *(t++)=' ';
+ }
+ else
+ {
+ *(t++)=*text;
+ }
+ text++;
+ }
+ if(t!=text)
+ {
+ *t=0;
+ printString(temp,x,y,z);
+ }
+}
\ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.h b/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.h index 93440b4ff1..e18687fe22 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/rasterfont.h @@ -34,6 +34,8 @@ public: // and the happy helper functions
void printString(const char *s, double x, double y, double z=0.0);
void printCenteredString(const char *s, double y, int screen_width, double z=0.0);
+
+ void printStuff(const char *text, double x, double y, double z, int bbHeight);
};
#endif
|
