diff options
author | pixel <pixel> | 2002-12-17 01:14:52 +0000 |
---|---|---|
committer | pixel <pixel> | 2002-12-17 01:14:52 +0000 |
commit | c329122f425342ac620696b40f7421753f70a8b6 (patch) | |
tree | cdaa1f94b60b27ead86246f0fe4b86317e2e3b62 /lib | |
parent | f0981aa6b09e67ec57b7cb92421513415292e97f (diff) |
Woo, printf working.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/glfont.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/glfont.cc b/lib/glfont.cc index d935d95..4d2cbd9 100644 --- a/lib/glfont.cc +++ b/lib/glfont.cc @@ -5,6 +5,7 @@ Uint8 prescale2[4] = { 0, 85, 170, 255 }, prescale3[8] = { 0, 36, 72, 109, 145, 182, 218, 255 }; #define DEBUG 1 +#define STRBUFSIZ 512 /* @@ -71,7 +72,7 @@ nbT = number of textures */ -mogltk::font::font(Handle * ffont) { +mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255) { int i; ffont->SetZ(); @@ -204,3 +205,24 @@ void mogltk::font::newline(void) { cx = ox; cy += maxY; } + +int mogltk::font::printf(const String & m, ...) { + static char buffer[STRBUFSIZ + 1]; + va_list ap; + char * p; + int r; + + va_start(ap, m); + r = vsnprintf(buffer, STRBUFSIZ, m.to_charp(), ap); + va_end(ap); + + for (p = buffer; *p; p++) { + putentry(*p, textcolor); + } + + return r; +} + +void mogltk::font::setcolor(Color c) { + textcolor = c; +} |