Debian Codegraph @

test/FTPixmapFont-Bitmap.cpp

raw
1 //$LIBS_PKG_CONFIG glu gl ftgl fontconfig
2 //$LIBS -lglut
3
4 #include <GL/glut.h>
5 #include <FTGL/ftgl.h>
6
7 FTFont *font;
8
9 void display ()
10 {
11 glClear (GL_COLOR_BUFFER_BIT);
12 glMatrixMode (GL_PROJECTION);
13 glLoadIdentity ();
14 gluPerspective (90, 1, 1, 1000);
15 glMatrixMode (GL_MODELVIEW);
16 glLoadIdentity ();
17 gluLookAt (0, 0, 200, 0, 0, 0, 0, 1, 0);
18 glPushMatrix ();
19 glColor3f (1, 1, 1);
20 glEnable (GL_BLEND);
21 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
22 glTranslatef (-100, 100, 0);
23 glRasterPos2i (0, 0);
24 font->Render ("Test", -1, FTPoint (), FTPoint (), FTGL::RENDER_FRONT | FTGL::RENDER_BACK);
25 glPopMatrix ();
26 glutSwapBuffers ();
27 }
28
29 int main (int argc, char **argv)
30 {
31 glutInit (&argc, argv);
32 glutInitDisplayMode (GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
33 glutInitWindowPosition (50, 50);
34 glutInitWindowSize (400, 400);
35 glutCreateWindow ("FTGL Test");
36 glutDisplayFunc (display);
37 const char *file = "font_pack/timR12-ISO8859-1.pcf.gz";
38 font = new FTPixmapFont (file);
39 if (font->Error ())
40 {
41 fprintf (stderr, "Failed to open font %s\n", file);
42 return 1;
43 }
44 glutMainLoop ();
45 }