[SDL] [DEMO] Truetype in OpenGL

Daniel Phillips phillips at arcor.de
Wed Jan 29 14:13:01 PST 2003


Well, this may look a little ugly and for some folks I'm sure it's nothing 
new, but for me it's new, so I took a screenshot:

   http://people.nl.linux.org/~phillips/world/font.png

This uses the gltt library:

   http://gltt.sourceforge.net/20010907_000000.html

which is written in c++, which means my little world engine is 
compiling/running in c++ now.  (I'll post the revised code pretty soon.) 

The gltt library worked exactly as advertised, with an absolute minimum of 
fuss and muss, though the project is a little short on documentation, to say 
the least.  This library combines very well with OpenGL and SDL, does exactly 
one thing, and by appearances, does it well.

Here's the code for the demo:

#include "world.h"
#include <gltt/FTFace.h>
#include <gltt/GLTTFont.h>

FTFace face;
GLTTFont font(&face);

int create(void)
{
	int point_size= 20;
	char *doing = "open ttf file";
	if (!face.open("/usr/share/fonts/truetype/Arial.ttf"))
		goto fail;
	doing = "create outline font";
	if (font.create(point_size))
		return 0;
fail:   printf("unable to %s\n", doing);
	return -1;
}

void render(void)
{
	glColor3f(1, 0, 0);
	font.output("hello truetype world");
}

struct world world = { create, NULL, render };




More information about the SDL mailing list