OpenGL::FTGL - interface to the FTGL library.


NAME

OpenGL::FTGL - interface to the FTGL library (to use arbitrary fonts in OpenGL applications).


SYNOPSIS

  #!/usr/bin/perl
  use strict;
  use warnings;
  use OpenGL ':all';
  use OpenGL::FTGL ':all';
  my $font = ftglCreateOutlineFont("/path_to/Arial.ttf")
    or die $!;
  ftglSetFontFaceSize($font, 72);
  sub display {
    glClear(GL_COLOR_BUFFER_BIT);    # clear window
    glPushMatrix();
      glTranslatef(50, 80, 0);       # translate...
      glRotatef(20, 0, 0, 1);        # and rotate the text
      ftglRenderFont($font, "Hello World!");
    glPopMatrix();
    glFlush();
  }
  glutInit();
  glutInitWindowSize(600, 300);           # 600 x 300 pixel window
  glutCreateWindow("Hello OpenGL::FTGL"); # window title
  glutDisplayFunc(\&display);  # callback invoked when window opened
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(0, 600, 0, 300);
  glMatrixMode(GL_MODELVIEW);
  glutMainLoop();              # enter event loop


DESCRIPTION

OpenGL doesn't provide direct font support. FTGL is a free, open source library which makes possible to use TrueType or OpenType fonts in an OpenGL application.

FUNCTIONS

The seven ftglCreate* functions take as parameter $fontfile which is the path to a font file. The supported formats are those of the FreeType2 library:

  - TrueType fonts (and collections)
  - Type 1 fonts
  - CID-keyed Type 1 fonts
  - CFF fonts
  - OpenType fonts (both TrueType and CFF variants)
  - SFNT-based bitmap fonts
  - X11 PCF fonts
  - Windows FNT fonts
  - BDF fonts (including anti-aliased ones)
  - PFR fonts
  - Type 42 fonts (limited support)

These functions return an FTGL $font object or undef if an error occurs.

If the variable $font goes out of scope or receives another value, the font is automatically destroyed. Don't worry yourself about the ftglDestroyFont function.

EXPORT

Nothing by default; the function names and constants must be explicitly exported.

Export Tags:


SEE ALSO

The FTGL library home page:

  http://ftgl.sourceforge.net/docs/html/index.html

The FreeType 2 home page:

  http://www.freetype.org/freetype2/


AUTHOR

J-L Morel <jl_morel@bribes.org>


COPYRIGHT AND LICENSE

Copyright (C) 2012 by J-L Morel. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.

 OpenGL::FTGL - interface to the FTGL library.