File: FTPixmapFont-Bitmap.cpp

package info (click to toggle)
ftgl 2.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,540 kB
  • sloc: cpp: 17,918; sh: 1,073; ansic: 644; makefile: 376
file content (45 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//$LIBS_PKG_CONFIG glu gl ftgl fontconfig
//$LIBS -lglut

#include <GL/glut.h>
#include <FTGL/ftgl.h>

FTFont *font;

void display ()
{
  glClear (GL_COLOR_BUFFER_BIT);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  gluPerspective (90, 1, 1, 1000);
  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity ();
  gluLookAt (0, 0, 200, 0, 0, 0, 0, 1, 0);
  glPushMatrix ();
  glColor3f (1, 1, 1);
  glEnable (GL_BLEND);
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glTranslatef (-100, 100, 0);
  glRasterPos2i (0, 0);
  font->Render ("Test", -1, FTPoint (), FTPoint (), FTGL::RENDER_FRONT | FTGL::RENDER_BACK);
  glPopMatrix ();
  glutSwapBuffers ();
}

int main (int argc, char **argv)
{
  glutInit (&argc, argv);
  glutInitDisplayMode (GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
  glutInitWindowPosition (50, 50);
  glutInitWindowSize (400, 400);
  glutCreateWindow ("FTGL Test");
  glutDisplayFunc (display);
  const char *file = "font_pack/timR12-ISO8859-1.pcf.gz";
  font = new FTPixmapFont (file);
  if (font->Error ())
    {
      fprintf (stderr, "Failed to open font %s\n", file);
      return 1;
    }
  glutMainLoop ();
}