Commit 33b23386 authored by David C. Lonie's avatar David C. Lonie

Remove the ftgl third party module.

It's no longer needed since Rendering/FreeTypeOpenGL was removed, and
is causing issues on android.
parent 3a1cd1f1
......@@ -13,7 +13,6 @@ vtk_module(vtkRenderingFreeType
DEPENDS
vtkRenderingCore
vtkfreetype
vtkftgl
TEST_DEPENDS
${optional_test_depends}
vtkTestingRendering
......
......@@ -28,10 +28,6 @@
#include "vtkStdString.h"
#include "vtkUnicodeString.h"
// FTGL
#include "vtkftglConfig.h"
#include "FTLibrary.h"
// The embedded fonts
#include "fonts/vtkEmbeddedFonts.h"
......@@ -45,10 +41,6 @@
#include <map>
#include <vector>
#ifdef FTGL_USE_NAMESPACE
using namespace ftgl;
#endif
// Print debug info
#define VTK_FTFC_DEBUG 0
#define VTK_FTFC_DEBUG_CD 0
......@@ -133,41 +125,12 @@ struct EmbeddedFontStruct
unsigned char *ptr;
};
//----------------------------------------------------------------------------
// This callback will be called by the FTGLibrary singleton cleanup destructor
// if it happens to be destroyed before our singleton (this order is not
// deterministic). It will destroy our singleton, if needed.
static void vtkFreeTypeToolsCleanupCallback ()
{
#if VTK_FTFC_DEBUG_CD
printf("vtkFreeTypeToolsCleanupCallback\n");
#endif
vtkFreeTypeTools::SetInstance(NULL);
}
//----------------------------------------------------------------------------
// Create the singleton cleanup
// Register our singleton cleanup callback against the FTLibrary so that
// it might be called before the FTLibrary singleton is destroyed.
vtkFreeTypeToolsCleanup::vtkFreeTypeToolsCleanup()
{
#if VTK_FTFC_DEBUG_CD
printf("vtkFreeTypeToolsCleanup::vtkFreeTypeToolsCleanup\n");
#endif
FTLibraryCleanup::AddDependency(&vtkFreeTypeToolsCleanupCallback);
}
//----------------------------------------------------------------------------
// Delete the singleton cleanup
// The callback called here might have been called by the FTLibrary singleton
// cleanup first (depending on the destruction order), but in case ours is
// destroyed first, let's call it too.
//------------------------------------------------------------------------------
// Clean up the vtkFreeTypeTools instance at exit. Using a separate class allows
// us to delay initialization of the vtkFreeTypeTools class.
vtkFreeTypeToolsCleanup::~vtkFreeTypeToolsCleanup()
{
#if VTK_FTFC_DEBUG_CD
printf("vtkFreeTypeToolsCleanup::~vtkFreeTypeToolsCleanup\n");
#endif
vtkFreeTypeToolsCleanupCallback();
vtkFreeTypeTools::SetInstance(NULL);
}
//----------------------------------------------------------------------------
......@@ -225,6 +188,18 @@ vtkFreeTypeTools::vtkFreeTypeTools()
this->ImageCache = NULL;
this->CMapCache = NULL;
this->ScaleToPowerTwo = true;
// Ideally this should be thread-local to support SMP:
FT_Error err;
this->Library = new FT_Library;
err = FT_Init_FreeType(this->Library);
if (err)
{
vtkErrorMacro("FreeType library initialization failed with error code: "
<< err << ".");
delete this->Library;
this->Library = NULL;
}
}
//----------------------------------------------------------------------------
......@@ -235,6 +210,9 @@ vtkFreeTypeTools::~vtkFreeTypeTools()
#endif
this->ReleaseCacheManager();
delete TextPropertyLookup;
FT_Done_FreeType(*this->Library);
this->Library = NULL;
}
//----------------------------------------------------------------------------
......@@ -244,13 +222,7 @@ FT_Library* vtkFreeTypeTools::GetLibrary()
printf("vtkFreeTypeTools::GetLibrary\n");
#endif
FTLibrary * ftgl_lib = FTLibrary::GetInstance();
if (ftgl_lib)
{
return ftgl_lib->GetLibrary();
}
return NULL;
return this->Library;
}
//----------------------------------------------------------------------------
......
......@@ -49,7 +49,6 @@ class vtkTextPropertyLookup;
class VTKRENDERINGFREETYPE_EXPORT vtkFreeTypeToolsCleanup
{
public:
vtkFreeTypeToolsCleanup();
~vtkFreeTypeToolsCleanup();
};
......@@ -304,6 +303,10 @@ protected:
// Lookup table that maps free type font cache face ids to vtkTextProperties
vtkTextPropertyLookup *TextPropertyLookup;
// Description:
// FreeType library instance.
FT_Library *Library;
// Description:
// The cache manager, image cache and charmap cache
FTC_Manager *CacheManager;
......
PROJECT (VTKFTGL)
set(vtkftgl_THIRD_PARTY 1)
set(vtkftgl_LIBRARIES vtkftgl)
set(vtkftgl_INCLUDE_DIRS ${VTKFTGL_SOURCE_DIR}/src)
vtk_module_export_info()
set(VTK_FREETYPE_LIBRARIES ${vtkfreetype_LIBRARIES})
#
# Dependency mask
#
INCLUDE_REGULAR_EXPRESSION(".*")
#
# Collect the required libs
#
SET (VTKFTGL_LIBS "")
#
# Do not use the STL (portability issue)
#
SET (VTKFTGL_DO_NOT_USE_STL 1)
#
# Source files
#
SET (FTGL_SRCS
src/FTBitmapGlyph.cpp
src/FTBitmapGlyphRenderOpenGL.cpp
src/FTCharmap.cpp
src/FTFace.cpp
src/FTFont.cpp
src/FTGLBitmapFont.cpp
src/FTGLBitmapFontRenderOpenGL.cpp
src/FTGLPixmapFont.cpp
src/FTGLPixmapFontRenderOpenGL.cpp
src/FTGlyph.cpp
src/FTGlyphContainer.cpp
src/FTLibrary.cpp
src/FTPixmapGlyph.cpp
src/FTPixmapGlyphRenderOpenGL.cpp
src/FTSize.cpp
)
#
# Do not use texture fonts (crash on Type1 fonts)
#
SET (VTKFTGL_DO_NOT_USE_TEXTURE_FONT 1)
IF (NOT VTKFTGL_DO_NOT_USE_TEXTURE_FONT)
SET (FTGL_SRCS ${FTGL_SRCS}
src/FTGLTextureFont.cpp
src/FTTextureGlyph.cpp
)
ENDIF ()
#
# Do not use vector fonts (we only need pixmap and bitmaps and vector fonts
# needs glu). Might be an option at some point, but set it to 'true' for now.
#
SET (VTKFTGL_DO_NOT_USE_VECTORISER 1)
IF (NOT VTKFTGL_DO_NOT_USE_VECTORISER)
SET (FTGL_SRCS ${FTGL_SRCS}
src/FTExtrdGlyph.cpp
src/FTGLExtrdFont.cpp
src/FTGLOutlineFont.cpp
src/FTGLPolygonFont.cpp
src/FTOutlineGlyph.cpp
src/FTPolyGlyph.cpp
)
ENDIF ()
#
# Shared/static lib settings)
#
IF (BUILD_SHARED_LIBS)
SET (VTKFTGL_DLL 1)
ELSE ()
SET (VTKFTGL_STATIC 1)
ENDIF ()
#
# Win32 flags (and shared/static lib settings)
#
IF (WIN32)
# This will add -DUSE_STD_NAMESPACE and -DWIN32
SET (VTKFTGL_WIN32_FLAGS 1)
ENDIF ()
#
# Unix flags
#
IF (UNIX)
IF(CMAKE_SYSTEM MATCHES "HP-UX.*")
SET (VTKFTGL_HPUX_SOURCE 1)
ENDIF()
ENDIF ()
include(vtkOpenGL)
IF (OPENGL_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${OPENGL_INCLUDE_PATH})
ENDIF ()
#
# We obviously need FreeType
#
SET (VTKFTGL_LIBS "${VTKFTGL_LIBS};${VTK_FREETYPE_LIBRARIES}")
#
# Define the library (and install it)
#
VTK_ADD_LIBRARY (vtkftgl ${FTGL_SRCS})
vtk_opengl_link(vtkftgl)
TARGET_LINK_LIBRARIES(vtkftgl LINK_PRIVATE ${VTKFTGL_LIBS})
#
# Create the configuration file
#
ADD_DEFINITIONS (-DVTKFTGL)
CONFIGURE_FILE(${VTKFTGL_SOURCE_DIR}/vtkftglConfig.h.in
${VTKFTGL_BINARY_DIR}/vtkftglConfig.h)
#
# Build examples (testing purposes)
# (Warning, they use Glut)
#
#OPTION (FTGL_BUILD_EXAMPLES "Build FTGL examples (warning: you need Glut)" OFF)
#MARK_AS_ADVANCED (FTGL_BUILD_EXAMPLES)
SET(FTGL_BUILD_EXAMPLES 0)
IF (FTGL_BUILD_EXAMPLES)
#
# Need GLU and GLUT
#
FIND_PACKAGE(GLU)
FIND_PACKAGE(GLUT)
IF (GLU_LIBRARY AND GLUT_LIBRARY)
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_LIBS}")
IF (GLUT_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${GLUT_INCLUDE_PATH})
ENDIF ()
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${GLUT_LIBRARY}")
IF (GLU_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${GLU_INCLUDE_PATH})
ENDIF ()
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${GLU_LIBRARY}")
#
# Do we need X ?
#
IF (VTK_USE_X)
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};-lXt")
FIND_LIBRARY (XMU_LIBRARY Xmu
/usr/lib
/usr/local/lib
/opt/graphics/OpenGL/lib
/usr/openwin/lib
/usr/X11R6/lib
/usr/contrib/X11R6/lib
)
MARK_AS_ADVANCED (XMU_LIBRARY)
IF (XMU_LIBRARY)
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${XMU_LIBRARY}")
ENDIF ()
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${X11_LIBRARIES}")
ENDIF ()
#
# Win32 flags
#
IF (WIN32)
# - Avoid the glutCreateMenu_ATEXIT_HACK pb.
# - Sort-of a hack to avoid the bug in glut.h to avoid
# ambiguity between 'std::exit(int)' and 'std::exit(int)' in function
ADD_DEFINITIONS (-DGLUT_DISABLE_ATEXIT_HACK)
ADD_DEFINITIONS (-DGLUT_BUILDING_LIB)
ENDIF ()
#
# Apple libraries.
#
IF (APPLE)
SET (VTKFTGL_EXAMPLES_LIBS "-framework OpenGL" "-framework GLUT" ${VTKFTGL_EXAMPLES_LIBS})
ENDIF ()
#
# Link examples to FTGL and Freetype
#
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};vtkftgl;${VTK_FREETYPE_LIBRARIES}")
#
# Example 1
#
SET(FTGL_DEMO_SRCS
demo/tb.c
demo/trackball.c
demo/FTGLDemo.cpp
)
ADD_EXECUTABLE (ftgl_demo ${FTGL_DEMO_SRCS})
vtk_opengl_link(ftgl_demo)
TARGET_LINK_LIBRARIES(ftgl_demo LINK_PRIVATE ${VTKFTGL_EXAMPLES_LIBS})
#
# Example 2
#
ADD_EXECUTABLE (ftgl_demo2 demo/demo.cpp)
vtk_opengl_link(ftgl_demo2)
TARGET_LINK_LIBRARIES(ftgl_demo2 LINK_PRIVATE ${VTKFTGL_EXAMPLES_LIBS})
ENDIF ()
ENDIF ()
This directory contains a subset of the FTGL library (1.32).
We only include enough of distribution to build it.
We'd like to thank Henry Maddocks for distributing this library.
henryj@paradise.net.nz
http://homepages.paradise.net.nz/henryj/code/index.html#FTGL
Modifications
-------------
A lot (including new code in src/NoSTL, speedups, portability issues).
FTGL 1.32
April 23 2002
DESCRIPTION:
FTGL is a free open source library to enable developers to use arbitrary
fonts in their OpenGL (www.opengl.org) applications.
Unlike other OpenGL font libraries FTGL uses standard font file formats
so doesn't need a preprocessing step to convert the high quality font data
into a lesser quality, proprietary format.
FTGL uses the Freetype (www.freetype.org) font library to open and 'decode'
the fonts. It then takes that output and stores it in a format most efficient
for OpenGL rendering.
Rendering modes supported are
- Bit maps
- Antialiased Pix maps
- Texture maps
- Outlines
- Polygon meshes
- Extruded polygon meshes
FTGL is designed to be used in commercial quality software. It has been
written with performance, robustness and simplicity in mind.
USAGE:
FTGLPixmapFont font;
font.Open( "Fonts:Arial");
font.FaceSize( 72);
font.render( "Hello World!");
This library was inspired by gltt, Copyright (C) 1998-1999 Stephane Rehel
(http://gltt.sourceforge.net)
Bezier curve code contributed by Jed Soane.
Demo, Linux port, extrusion code and gltt maintainance by Gerard Lanois
Linux port by Matthias Kretz
Windows port by Max Rheiner & Ellers
Bug fixes by Robert Osfield, Marcelo E. Magallon, Markku Rontu
Please contact me if you have any suggestions, feature requests, or problems.
Henry Maddocks
henryj@paradise.net.nz
http://homepages.paradise.net.nz/henryj/
//==============================================================================
Version 2??????
My initial design of FTGL was in 2 distinct parts...the freetype stuff and
the FTGL stuff. The freetype side contained wrappers for the freetype stuff
(surprise) and the ftgl side handled all the opengl stuff. All communication
was done via FTFace <-> FTFont. This felt right from a design point of view
because conceptually it made sense, it was clean, simple and it insulated
FTGL from changes in freetype. Up to version 1.3 I have rigidly stuck to
this 'rule'. Unfortunately this has been at the expense of the code. This
became most evident when dealing with char maps. Common sense would argue
that charmaps and the glyph container are intimately related, but because
of the 'rule' the communication path between them is...
FTGlyphContainer <-> FTFont <-> FTFace <-> FTCharMap
This is bollocks and has lead to some ugly code.
I am not about abandon the design completely, just the rule that says all
communication should be via FTFace <-> FTFont. I will still maintain
wrappers for freetype objects, but they will interface with ftgl in places
that make the most sense from a code efficiency point of view.
move glyph creation out of constructor, but load the freetype glyph and get
the metrics.
Change all dim stuff to float. Make my own floating point version of
FT_Vector.
Move Charmap to be owned by glyph container. See above
Try out cbloom sorted vector in charmap. faster than std::map?
Enable access to raw glyph data
State handling...
inline base class methods
Extreme Programming...
Things to think about...
The whole char size thing is major headache.
At the moment if you call font.CharSize( x) the glyph list is destroyed and
rebuilt, which will be really, really, really inefficient if you change sizes
often. Will the freetype cache stuff help? What about the new (FT 2.0.5)
FTSize public api.
When is the best time to construct the glyphList? After the call to Size(x)
is the earliest but what happens if the client doesn't set the char size?
Define a default size, check if glyphlist is valid in render function, if
not call size with default size.
good sites...
http://cgm.cs.mcgill.ca/~luc/
http://www.blackpawn.com/texts/lightmaps/default.html
glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID);
should really check at run time.
Check that I do this properly..
============================
Dave Williss a ecrit :
Question:
If I do this...
TT_New_Glyph(face, &glyph);
for (i = 0 ; i < n ; ++i) {
TT_Load_Glyph(instance, glyph, index[i], flags);
... use glyph...
}
TT_Done_Glyph(glyph)
Will I be leaking memory on each call to Load Glyph or
should I create and destroy the glyph handle for each call?
Seems terribily inefficient but to do that, but doing it as
above I seem to be leaking memory.
No, this is the correct behavior. Each call to TT_Load_Glyph
overwrites the previous content.. and this was designed on
purpose because the real content of a TT_Glyph object is
_really_ complex with TrueType, and you don't want to create
them on each glyph load..
This diff is collapsed.
FTGL Version 1.3 Demo
This demo demonstrates the different rendering styles available with FTGL.
Press <spacebar> to change the font rendering style.
Press <enter> to enable edit mode.
When compiling you will need to check the paths to the font files as they are
hard coded. See #define FONT_FILE and #define FONT_INFO in FTGLDemo.c
Please contact me if you have any suggestions, feature requests, or problems.
Henry Maddocks
henryj@paradise.net.nz
http://homepages.paradise.net.nz/henryj/
// source changed by mrn@paus.ch/ max rheiner
// original source: henryj@paradise.net.nz
#include <stdio.h>
#include <stdlib.h> // exit()
#include "FTGL.h"
#ifdef __APPLE_CC__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#ifndef FTGL_DO_NOT_USE_VECTORISER
#include "FTGLOutlineFont.h"
#include "FTGLPolygonFont.h"
#endif
#ifndef FTGL_DO_NOT_USE_TEXTURE_FONT
#include "FTGLTextureFont.h"
#endif
#include "FTGLBitmapFont.h"
#include "FTGLPixmapFont.h"
static FTFont* fonts[5];
static int width;
static int height;
static int point_size = 24;
#ifdef __linux__
const char* DEFAULT_FONT = "/usr/share/fonts/truetype/arial.ttf";
#else
#ifdef __APPLE_CC__
const char* DEFAULT_FONT = "/Users/henry/Development/PROJECTS/FTGL/ftglcvs/FTGL/demo/arial.ttf";
#else
#ifdef WIN32
const char* DEFAULT_FONT = "C:\\WINNT\\Fonts\\arial.ttf";
#else
const char* DEFAULT_FONT = "arial.ttf";
#endif
#endif
#endif
int file_exists( const char * filename );
void draw_scene();
void
my_init( const char* font_filename )
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#ifndef FTGL_DO_NOT_USE_VECTORISER
fonts[0] = new FTGLOutlineFont;
fonts[1] = new FTGLPolygonFont;
#else
fonts[0] =
fonts[1] = 0;
#endif
#ifndef FTGL_DO_NOT_USE_TEXTURE_FONT
fonts[2] = new FTGLTextureFont;
#else
fonts[2] = 0;
#endif
fonts[3] = new FTGLBitmapFont;
fonts[4] = new FTGLPixmapFont;
for (int i=0; i< 5; i++) {
if(!fonts[i])
{
continue;
}
if (!fonts[i]->Open(font_filename)) {
printf("Reading font %d from %s\n", i, font_filename);
fprintf(stderr, "ERROR: Unable to open file %s\n", font_filename);
}
else {
printf("Reading font %d from %s\n", i, font_filename);
if (!fonts[i]->FaceSize(point_size)) {
fprintf(stderr, "ERROR: Unable to set font face size %d\n", point_size);
}
// Try to load AFM font metrics
const char* ext = strrchr(font_filename, '.');
if (ext && !strcmp(ext, ".pfb"))
{
char *metrics = new char[strlen(font_filename)];
strncpy(metrics, font_filename, ext - font_filename);
strcpy(metrics + (ext - font_filename), ".afm");
if (file_exists(metrics))
{
printf("Attaching font metrics from %s\n", metrics);;
fonts[i]->Attach(metrics);
}
}
}
}
}
static void
do_ortho()
{
int w;
int h;
GLdouble size;
GLdouble aspect;
w = width;
h = height;
aspect = (GLdouble)w / (GLdouble)h;
// Use the whole window.
glViewport(0, 0, w, h);
// We are going to do some 2-D orthographic drawing.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
size = (GLdouble)((w >= h) ? w : h) / 2.0;
if (w <= h) {
aspect = (GLdouble)h/(GLdouble)w;
glOrtho(-size, size, -size*aspect, size*aspect,
-100000.0, 100000.0);
}
else {
aspect = (GLdouble)w/(GLdouble)h;
glOrtho(-size*aspect, size*aspect, -size, size,
-100000.0, 100000.0);
}
// Make the world and window coordinates coincide so that 1.0 in
// model space equals one pixel in window space.
glScaled(aspect, aspect, 1.0);
// Now determine where to draw things.
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
#ifndef GLUTCALLBACK
#define GLUTCALLBACK
#endif
extern "C" {
void
GLUTCALLBACK my_display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
draw_scene();
glutSwapBuffers();
}
void
GLUTCALLBACK my_reshape(int w, int h)
{
width = w;
height = h;
do_ortho( );
}
void
GLUTCALLBACK my_handle_key(unsigned char key, int, int)
{
switch (key) {
//!!ELLERS
case 'q': // Esc or 'q' Quits the program.
case 27:
{
for (int i=0; i<5; i++) {
if (fonts[i]) {
delete fonts[i];
fonts[i] = 0;
}
}
exit(1);
}
break;
default: