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-05-11 15:16:25 +0000
committerStijn Buys <ingar@osirion.org>2008-05-11 15:16:25 +0000
commitd2e93235b9ccd37bf8c8fb7c4376ab1911c83639 (patch)
tree61bfbf023228ba10abe488d8c8bd27359171c9f7 /src/render/text.cc
parentd82c8f449c604d0f957e3dd190f7beae3596e6f9 (diff)
console font
Diffstat (limited to 'src/render/text.cc')
-rw-r--r--src/render/text.cc43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/render/text.cc b/src/render/text.cc
index 768ebf8..668f4ec 100644
--- a/src/render/text.cc
+++ b/src/render/text.cc
@@ -4,12 +4,23 @@
the terms of the GNU General Public License version 2
*/
-#include "render/render.h"
+#include "render/text.h"
+#include "render/textures.h"
#include "sys/sys.h"
namespace render {
-void draw_text(float x, float y, const char ascii)
+float Text::text_fontwidth = 16.0f;
+float Text::text_fontheight = 24.0f;
+
+void Text::setfont(const char *texture, float width, float height)
+{
+ Textures::bind(texture, false);
+ text_fontwidth = width;
+ text_fontheight = height;
+
+}
+void Text::draw(float x, float y, const char ascii)
{
if (ascii != ' ') {
int row = (int) ascii >> 4;
@@ -21,49 +32,45 @@ void draw_text(float x, float y, const char ascii)
gl::begin(gl::Quads);
glTexCoord2f(fcol, frow);
- gl::vertex(x,y,0);
+ gl::vertex(x,y,1);
glTexCoord2f(fcol + 0.0625f, frow);
- gl::vertex(x+CHARWIDTH,y,0);
+ gl::vertex(x+text_fontwidth,y,1);
glTexCoord2f(fcol +0.0625f, frow + 0.0625f);
- gl::vertex(x+CHARWIDTH,y+CHARHEIGHT,0);
+ gl::vertex(x+text_fontwidth,y+text_fontheight,1);
glTexCoord2f(fcol, frow+0.0625f);
- gl::vertex(x,y+CHARHEIGHT,0);
+ gl::vertex(x,y+text_fontheight,1);
gl::end();
}
}
-void draw_text(float x, float y, const char *text)
+void Text::draw(float x, float y, const char *text)
{
const char *c = text;
while (*c) {
- draw_text(x, y, *c);
+ draw(x, y, *c);
c++;
- x += CHARWIDTH;
+ x += text_fontwidth;
}
}
-void draw_text(float x, float y, std::stringstream & textstream)
+void Text::draw(float x, float y, std::stringstream & textstream)
{
char line[MAXCMDSIZE];
while (textstream.getline(line, MAXCMDSIZE-1)) {
- draw_text(x, y, line);
- y += CHARHEIGHT;
+ draw(x, y, line);
+ y += text_fontheight;
}
textstream.clear();
}
-void draw_text(float x, float y, const std::string & text)
+void Text::draw(float x, float y, const std::string & text)
{
- for (size_t i =0; i < text.size(); i++) {
- draw_text(x, y, text[i]);
- x += CHARWIDTH;
- }
+ draw(x, y, text.c_str());
}
}
-