Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-03 18:51:46 +0000
committerStijn Buys <ingar@osirion.org>2008-02-03 18:51:46 +0000
commit6011bbb179f72a370411960eafdbbc98e6607f05 (patch)
treec57fe3b9b6e57a6c17d4159ba1b2455a692548b9 /src/render/text.cc
parentb4973888aeaea2dde6058bc06c3f6631349e7f3c (diff)
basic text rendering
Diffstat (limited to 'src/render/text.cc')
-rw-r--r--src/render/text.cc43
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;
+ }
+}
+
+}
+