diff options
author | Stijn Buys <ingar@osirion.org> | 2008-02-03 18:51:46 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-02-03 18:51:46 +0000 |
commit | 6011bbb179f72a370411960eafdbbc98e6607f05 (patch) | |
tree | c57fe3b9b6e57a6c17d4159ba1b2455a692548b9 /src/render/text.cc | |
parent | b4973888aeaea2dde6058bc06c3f6631349e7f3c (diff) |
basic text rendering
Diffstat (limited to 'src/render/text.cc')
-rw-r--r-- | src/render/text.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/render/text.cc b/src/render/text.cc new file mode 100644 index 0000000..f97aff6 --- /dev/null +++ b/src/render/text.cc @@ -0,0 +1,43 @@ +/* + render/text.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "render/render.h" +#include "GL/glut.h" + +namespace render { + +void draw_text(float x, float y, std::string text) +{ + for (size_t i =0; i < text.size(); i++) { + if (text[i] != ' ') { + int row = (int) text[i] >> 4; + int col = (int) text[i] & 15; + + float frow = row * 0.0625f; + float fcol = col * 0.0625f; + + gl::begin(gl::Quads); + + glTexCoord2f(fcol, frow); + gl::vertex(x,y,0); + + glTexCoord2f(fcol + 0.0625f, frow); + gl::vertex(x+CHARSIZE,y,0); + + glTexCoord2f(fcol +0.0625f, frow + 0.0625f); + gl::vertex(x+CHARSIZE,y+CHARSIZE,0); + + glTexCoord2f(fcol, frow+0.0625f); + gl::vertex(x,y+CHARSIZE,0); + + gl::end(); + } + x += CHARSIZE; + } +} + +} + |