diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-03 22:55:43 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-06-03 22:55:43 +0000 |
commit | 33a948139cb6edffeb84cb6234ee9aba90bfda3c (patch) | |
tree | 4375df350968b5184e99bf4669577f29d6c905b0 /src/render-text.c | |
parent | 0cece1620a0a9132f98d426b35bdf8b26b3974c1 (diff) |
Text rendering framework (foundation)
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@68 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/render-text.c')
-rw-r--r-- | src/render-text.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/render-text.c b/src/render-text.c new file mode 100644 index 0000000..710837f --- /dev/null +++ b/src/render-text.c @@ -0,0 +1,52 @@ +/* + * render-text.c + * + * Simple text rendering + * + * (c) 2008 Thomas White <taw27@cam.ac.uk> + * + * thrust3d - a silly game + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <png.h> +#include <stdlib.h> +#include <glew.h> + +#include "render.h" +#include "texture.h" + +void render_text_setup(RenderContext *r) { + + texture_load(r, "font"); + +} + +void render_text_write(GLfloat x, GLfloat y, const char *text, RenderContext *r) { + + Texture *texture; + + texture = texture_lookup(r, "font"); + glBindTexture(GL_TEXTURE_2D, texture->texname); + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex2f(x, y); + glTexCoord2f(1.0, 0.0); + glVertex2f(x+0.1, y); + glTexCoord2f(1.0, 1.0); + glVertex2f(x+0.1, y+0.1); + glTexCoord2f(0.0, 1.0); + glVertex2f(x, y+0.1); + glEnd(); + + glDisable(GL_TEXTURE_2D); + +} + |