Updated the FTGL implemention in osgText to FTFL1.1.
This commit is contained in:
parent
8f4e62ced0
commit
254268030d
@ -42,7 +42,7 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "FTGL_LIBRARY_STATIC" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "OSGTEXT_LIBRARY" /D "WIN32" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
@ -68,7 +68,7 @@ LINK32=link.exe
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "FTGL_LIBRARY_STATIC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../include" /D "_DEBUG" /D "OSGTEXT_LIBRARY" /D "WIN32" /D "_WINDOWS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
@ -161,10 +161,6 @@ SOURCE=..\..\src\osgText\FTTextureGlyph.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgText\FTVectorGlyph.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgText\FTVectoriser.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -257,10 +253,6 @@ SOURCE=..\..\src\osgText\FTTextureGlyph.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgText\FTVectorGlyph.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osgText\FTVectoriser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -2,9 +2,15 @@
|
||||
|
||||
|
||||
FTCharmap::FTCharmap( FT_Face face)
|
||||
: err(0),
|
||||
ftFace( face)
|
||||
: ftFace( face),
|
||||
err(0)
|
||||
{
|
||||
// Check that the default is valid
|
||||
if( !face->charmap)
|
||||
{
|
||||
FT_Set_Charmap( ftFace, ftFace->charmaps[0]);
|
||||
}
|
||||
|
||||
ftEncoding = face->charmap->encoding;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
|
||||
FTFace::FTFace()
|
||||
: ftFace(0),
|
||||
: charMap(0),
|
||||
ftFace(0),
|
||||
numCharMaps(0),
|
||||
charMap(0),
|
||||
numGlyphs(0),
|
||||
err(0)
|
||||
{}
|
||||
|
@ -146,7 +146,7 @@ class FTGL_EXPORT FTFont
|
||||
/**
|
||||
* Number of faces in this font
|
||||
*/
|
||||
int numFaces;
|
||||
unsigned int numFaces;
|
||||
|
||||
/**
|
||||
* Current size object
|
||||
@ -161,7 +161,7 @@ class FTGL_EXPORT FTFont
|
||||
/**
|
||||
* The number of glyphs in this font
|
||||
*/
|
||||
int numGlyphs;
|
||||
unsigned int numGlyphs;
|
||||
|
||||
/**
|
||||
* Current pen or cursor position;
|
||||
|
@ -14,7 +14,19 @@
|
||||
|
||||
// non windows, doesn't require nonesense as seen below :-)
|
||||
#ifndef __gl_h_
|
||||
#include <GL/gl.h>
|
||||
#ifdef __APPLE_CC__
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#ifndef GL_TEXTURE_2D_BINDING_EXT
|
||||
#include <OpenGL/glext.h>
|
||||
#endif
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#ifndef GL_TEXTURE_2D_BINDING_EXT
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// required for compatibility with glext.h style function definitions of
|
||||
@ -64,22 +76,25 @@
|
||||
|
||||
#ifndef __gl_h_
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#ifndef GL_TEXTURE_2D_BINDING_EXT
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// #if defined(_MSC_VER)
|
||||
// # ifdef FTGL_LIBRARY_STATIC // staticLib
|
||||
// # define FTGL_EXPORT
|
||||
// # elif FTGL_LIBRARY // dynamicLib
|
||||
// # define FTGL_EXPORT __declspec(dllexport)
|
||||
// # else
|
||||
// # define FTGL_EXPORT __declspec(dllimport)
|
||||
// # endif /* FTGL_LIBRARY */
|
||||
// #else
|
||||
#if defined(_MSC_VER)
|
||||
# ifdef FTGL_LIBRARY_STATIC // staticLib
|
||||
# define FTGL_EXPORT
|
||||
# elif FTGL_LIBRARY // dynamicLib
|
||||
# define FTGL_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define FTGL_EXPORT __declspec(dllimport)
|
||||
# endif /* FTGL_LIBRARY */
|
||||
#else
|
||||
# define FTGL_EXPORT
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __FTGL__
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
|
||||
FTGLBitmapFont::FTGLBitmapFont()
|
||||
: tempGlyph(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -23,7 +22,7 @@ bool FTGLBitmapFont::MakeGlyphList()
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
tempGlyph = new FTBitmapGlyph( *ftGlyph);
|
||||
FTBitmapGlyph* tempGlyph = new FTBitmapGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
@ -40,7 +39,6 @@ void FTGLBitmapFont::render( const char* string)
|
||||
{
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
|
||||
// doing this every frame is a bad?
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
|
||||
@ -56,7 +54,6 @@ void FTGLBitmapFont::render( const wchar_t* string)
|
||||
{
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
|
||||
|
||||
// doing this every frame is a bad?
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
|
||||
|
@ -52,10 +52,5 @@ class FTGL_EXPORT FTGLBitmapFont : public FTFont
|
||||
*/
|
||||
bool MakeGlyphList();
|
||||
|
||||
/**
|
||||
* Temp variable for a FTBitmapGlyph
|
||||
*/
|
||||
FTBitmapGlyph* tempGlyph;
|
||||
|
||||
};
|
||||
#endif // __FTGLBitmapFont__
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
|
||||
FTGLOutlineFont::FTGLOutlineFont()
|
||||
: tempGlyph(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -21,7 +20,7 @@ bool FTGLOutlineFont::MakeGlyphList()
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
tempGlyph = new FTOutlineGlyph( *ftGlyph);
|
||||
FTOutlineGlyph* tempGlyph = new FTOutlineGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
@ -52,10 +52,5 @@ class FTGL_EXPORT FTGLOutlineFont : public FTFont
|
||||
*/
|
||||
bool MakeGlyphList();
|
||||
|
||||
/**
|
||||
* A temporary FTOutlineGlyph used for building the glyphList
|
||||
*/
|
||||
FTOutlineGlyph* tempGlyph;
|
||||
|
||||
};
|
||||
#endif // __FTGLOutlineFont__
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
|
||||
FTGLPixmapFont::FTGLPixmapFont()
|
||||
: tempGlyph(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -23,7 +22,7 @@ bool FTGLPixmapFont::MakeGlyphList()
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
tempGlyph = new FTPixmapGlyph( *ftGlyph);
|
||||
FTPixmapGlyph* tempGlyph = new FTPixmapGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
@ -51,11 +51,6 @@ class FTGL_EXPORT FTGLPixmapFont : public FTFont
|
||||
*/
|
||||
bool MakeGlyphList();
|
||||
|
||||
/**
|
||||
* A temporary FTPixmapGlyph used for building the glyphList
|
||||
*/
|
||||
FTPixmapGlyph* tempGlyph;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
|
||||
FTGLPolygonFont::FTGLPolygonFont()
|
||||
: tempGlyph(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -22,7 +21,7 @@ bool FTGLPolygonFont::MakeGlyphList()
|
||||
|
||||
if( ftGlyph)
|
||||
{
|
||||
tempGlyph = new FTPolyGlyph( *ftGlyph);
|
||||
FTPolyGlyph* tempGlyph = new FTPolyGlyph( *ftGlyph);
|
||||
glyphList->Add( tempGlyph);
|
||||
}
|
||||
else
|
||||
|
@ -36,12 +36,6 @@ class FTGL_EXPORT FTGLPolygonFont : public FTFont
|
||||
*/
|
||||
bool MakeGlyphList();
|
||||
|
||||
/**
|
||||
* A temporary FTPolyGlyph used for building the glyphList
|
||||
*/
|
||||
FTPolyGlyph* tempGlyph;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -4,9 +4,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unsigned long UInt32; // a mac thing?
|
||||
|
||||
inline UInt32 NextPowerOf2( UInt32 in)
|
||||
inline GLuint NextPowerOf2( GLuint in)
|
||||
{
|
||||
in -= 1;
|
||||
|
||||
@ -21,15 +19,14 @@ inline UInt32 NextPowerOf2( UInt32 in)
|
||||
|
||||
|
||||
FTGLTextureFont::FTGLTextureFont()
|
||||
: numTextures(1),
|
||||
textMem(0),
|
||||
padding(1),
|
||||
tempGlyph(0),
|
||||
maxTextSize(0),
|
||||
: maxTextSize(0),
|
||||
textureWidth(0),
|
||||
textureHeight(0),
|
||||
numTextures(1),
|
||||
textMem(0),
|
||||
glyphHeight(0),
|
||||
glyphWidth(0)
|
||||
glyphWidth(0),
|
||||
padding(1)
|
||||
{}
|
||||
|
||||
|
||||
@ -41,8 +38,6 @@ FTGLTextureFont::~FTGLTextureFont()
|
||||
|
||||
bool FTGLTextureFont::MakeGlyphList()
|
||||
{
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
|
||||
if( !maxTextSize)
|
||||
glGetIntegerv( GL_MAX_TEXTURE_SIZE, (GLint*)&maxTextSize);
|
||||
|
||||
@ -50,7 +45,7 @@ bool FTGLTextureFont::MakeGlyphList()
|
||||
glyphWidth = ( charSize.Width()) + padding;
|
||||
|
||||
GetSize();
|
||||
int totalMem;
|
||||
GLuint totalMem;
|
||||
|
||||
if( textureHeight > maxTextSize)
|
||||
{
|
||||
@ -58,7 +53,7 @@ bool FTGLTextureFont::MakeGlyphList()
|
||||
if( numTextures > 15) // FIXME
|
||||
numTextures = 15;
|
||||
|
||||
int heightRemain = NextPowerOf2( textureHeight % maxTextSize);
|
||||
GLsizei heightRemain = NextPowerOf2( textureHeight % maxTextSize);
|
||||
totalMem = ((maxTextSize * ( numTextures - 1)) + heightRemain) * textureWidth;
|
||||
|
||||
glGenTextures( numTextures, (GLuint*)&glTextureID[0]);
|
||||
@ -101,7 +96,7 @@ bool FTGLTextureFont::MakeGlyphList()
|
||||
}
|
||||
|
||||
|
||||
unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, int id, int width, int height, unsigned char* textdata)
|
||||
unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, GLuint id, GLsizei width, GLsizei height, unsigned char* textdata)
|
||||
{
|
||||
int currentTextX = padding;
|
||||
int currentTextY = padding;// + padding;
|
||||
@ -109,7 +104,6 @@ unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, int id, int w
|
||||
float currTextU = (float)padding / (float)width;
|
||||
float currTextV = (float)padding / (float)height;
|
||||
|
||||
// numGlyphs = 256; // FIXME hack
|
||||
unsigned int n;
|
||||
|
||||
for( n = glyphStart; n <= numGlyphs; ++n)
|
||||
@ -122,7 +116,7 @@ unsigned int FTGLTextureFont::FillGlyphs( unsigned int glyphStart, int id, int w
|
||||
|
||||
currTextU = (float)currentTextX / (float)width;
|
||||
|
||||
tempGlyph = new FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV);
|
||||
FTTextureGlyph* tempGlyph = new FTTextureGlyph( *ftGlyph, id, data, width, height, currTextU, currTextV);
|
||||
glyphList->Add( tempGlyph);
|
||||
|
||||
currentTextX += glyphWidth;
|
||||
@ -160,14 +154,14 @@ void FTGLTextureFont::GetSize()
|
||||
}
|
||||
|
||||
|
||||
void FTGLTextureFont::CreateTexture( int id, int width, int height, unsigned char* data)
|
||||
void FTGLTextureFont::CreateTexture( GLuint id, GLsizei width, GLsizei height, unsigned char* data)
|
||||
{
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1); //What does this do exactly?
|
||||
glBindTexture( GL_TEXTURE_2D, glTextureID[id]);
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
|
||||
}
|
||||
@ -180,13 +174,8 @@ void FTGLTextureFont::render( const char* string)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, (GLuint)FTTextureGlyph::activeTextureID);
|
||||
FTFont::render( string);
|
||||
|
||||
// QUADS are faster!? Less function call overhead?
|
||||
glBegin( GL_QUADS);
|
||||
FTFont::render( string);
|
||||
glEnd();
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
@ -198,12 +187,7 @@ void FTGLTextureFont::render( const wchar_t* string)
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, (GLuint)FTTextureGlyph::activeTextureID);
|
||||
|
||||
// QUADS are faster!? Less function call overhead?
|
||||
glBegin( GL_QUADS);
|
||||
FTFont::render( string);
|
||||
glEnd();
|
||||
FTFont::render( string);
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
@ -28,12 +28,12 @@ class FTGL_EXPORT FTGLTextureFont : public FTFont
|
||||
/**
|
||||
* Get the total width of the texture that holds this font
|
||||
*/
|
||||
virtual int TextureWidth() const { return textureWidth;}
|
||||
virtual GLsizei TextureWidth() const { return textureWidth;}
|
||||
|
||||
/**
|
||||
* Get the total height of the texture that holds this font
|
||||
*/
|
||||
virtual int TextureHeight() const { return textureHeight;}
|
||||
virtual GLsizei TextureHeight() const { return textureHeight;}
|
||||
|
||||
/**
|
||||
* Renders a string of characters
|
||||
@ -73,7 +73,7 @@ class FTGL_EXPORT FTGLTextureFont : public FTFont
|
||||
* @param textureHeight The texture height
|
||||
* @param textMem A pointer to the texture memory.
|
||||
*/
|
||||
unsigned int FillGlyphs( unsigned int glyphStart, int textID, int textureWidth, int textureHeight, unsigned char* textMem);
|
||||
unsigned int FillGlyphs( unsigned int glyphStart, GLuint textID, GLsizei textureWidth, GLsizei textureHeight, unsigned char* textMem);
|
||||
|
||||
/**
|
||||
* Get the size of a block of memory required to layout the glyphs
|
||||
@ -97,28 +97,22 @@ class FTGL_EXPORT FTGLTextureFont : public FTFont
|
||||
* @param height The number of rows of bytes.
|
||||
* @param data A pointer to the texture data
|
||||
*/
|
||||
void CreateTexture( int id, int width, int height, unsigned char* data);
|
||||
|
||||
/**
|
||||
* A temporary FTTextureGlyph used for building the glyphList
|
||||
*/
|
||||
FTTextureGlyph* tempGlyph;
|
||||
|
||||
void CreateTexture( GLuint id, GLsizei width, GLsizei height, unsigned char* data);
|
||||
|
||||
/**
|
||||
* The maximum texture dimension on this OpenGL implemetation
|
||||
*/
|
||||
long maxTextSize;
|
||||
GLsizei maxTextSize;
|
||||
|
||||
/**
|
||||
* The minimum texture width required to hold the glyphs
|
||||
*/
|
||||
int textureWidth;
|
||||
GLsizei textureWidth;
|
||||
|
||||
/**
|
||||
* The minimum texture height required to hold the glyphs
|
||||
*/
|
||||
int textureHeight;
|
||||
GLsizei textureHeight;
|
||||
|
||||
/**
|
||||
* An array of texture ids
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "FTFace.h"
|
||||
|
||||
|
||||
FTGlyphContainer::FTGlyphContainer( FTFace* f, int g, bool p)
|
||||
FTGlyphContainer::FTGlyphContainer( FTFace* f, unsigned int g, bool p)
|
||||
: preCache( p),
|
||||
numGlyphs( g),
|
||||
face( f),
|
||||
@ -60,7 +60,7 @@ FT_Vector& FTGlyphContainer::render( unsigned int index, unsigned int next, FT_V
|
||||
advance = glyphs[left]->Render( pen);
|
||||
}
|
||||
|
||||
kernAdvance.x = advance + kernAdvance.x; // FIXME float to long
|
||||
kernAdvance.x = advance + kernAdvance.x;
|
||||
// kernAdvance.y = advance.y + kernAdvance.y;
|
||||
return kernAdvance;
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ class FTGL_EXPORT FTGlyphContainer
|
||||
* @param p A flag to indicate preprocessing of glyphs.
|
||||
* Not used.
|
||||
*/
|
||||
FTGlyphContainer( FTFace* face, int numGlyphs, bool p = false);
|
||||
FTGlyphContainer( FTFace* face, unsigned int numGlyphs, bool p = false);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~FTGlyphContainer();
|
||||
virtual ~FTGlyphContainer();
|
||||
|
||||
/**
|
||||
* Adds a glyph to this glyph list.
|
||||
@ -49,9 +49,9 @@ class FTGL_EXPORT FTGlyphContainer
|
||||
/**
|
||||
* Returns the kerned advance width for a glyph.
|
||||
*
|
||||
* param index glyph index of the character
|
||||
* param next the next glyph in a string
|
||||
* return advance width
|
||||
* @param index glyph index of the character
|
||||
* @param next the next glyph in a string
|
||||
* @return advance width
|
||||
*/
|
||||
float Advance( unsigned int index, unsigned int next);
|
||||
|
||||
@ -60,7 +60,7 @@ class FTGL_EXPORT FTGlyphContainer
|
||||
* @param index the glyph to be rendered
|
||||
* @param next the next glyph in the string. Used for kerning.
|
||||
* @param pen the position to render the glyph
|
||||
* return The distance to advance the pen position after rendering
|
||||
* @return The distance to advance the pen position after rendering
|
||||
*/
|
||||
FT_Vector& render( unsigned int index, unsigned int next, FT_Vector pen);
|
||||
|
||||
|
@ -20,7 +20,7 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
|
||||
|
||||
vectoriser = new FTVectoriser( glyph);
|
||||
|
||||
vectoriser->Ingest();
|
||||
vectoriser->Process();
|
||||
numContours = vectoriser->contours();
|
||||
contourLength = new int[ numContours];
|
||||
|
||||
@ -31,7 +31,7 @@ FTOutlineGlyph::FTOutlineGlyph( FT_Glyph glyph)
|
||||
|
||||
numPoints = vectoriser->points();
|
||||
data = new double[ numPoints * 3];
|
||||
vectoriser->Output( data);
|
||||
vectoriser->MakeOutline( data);
|
||||
|
||||
advance = glyph->advance.x >> 16;
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include "FTPolyGlyph.h"
|
||||
#include "FTVectoriser.h"
|
||||
|
||||
#include "GL/glu.h"
|
||||
|
||||
#ifndef CALLBACK
|
||||
#define CALLBACK
|
||||
#endif
|
||||
@ -61,7 +59,7 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
|
||||
|
||||
vectoriser = new FTVectoriser( glyph);
|
||||
|
||||
vectoriser->Ingest();
|
||||
vectoriser->Process();
|
||||
numContours = vectoriser->contours();
|
||||
contourLength = new int[ numContours];
|
||||
|
||||
@ -72,7 +70,8 @@ FTPolyGlyph::FTPolyGlyph( FT_Glyph glyph)
|
||||
|
||||
numPoints = vectoriser->points();
|
||||
data = new double[ numPoints * 3];
|
||||
vectoriser->Output( data);
|
||||
// FIXME MakeMesh
|
||||
vectoriser->MakeOutline( data);
|
||||
|
||||
contourFlag = vectoriser->ContourFlag();
|
||||
advance = glyph->advance.x >> 16;
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
|
||||
FTSize::FTSize()
|
||||
: size(0),
|
||||
ftFace(0),
|
||||
: ftFace(0),
|
||||
size(0),
|
||||
err(0)
|
||||
{}
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
int FTTextureGlyph::activeTextureID = 0;
|
||||
|
||||
FTTextureGlyph::FTTextureGlyph( FT_Glyph glyph, int id, unsigned char* data, int stride, int height, float u, float v)
|
||||
FTTextureGlyph::FTTextureGlyph( FT_Glyph glyph, int id, unsigned char* data, GLsizei stride, GLsizei height, float u, float v)
|
||||
: FTGlyph(),
|
||||
destWidth(0),
|
||||
destHeight(0),
|
||||
@ -72,20 +70,20 @@ FTTextureGlyph::~FTTextureGlyph()
|
||||
|
||||
float FTTextureGlyph::Render( const FT_Vector& pen)
|
||||
{
|
||||
// This could be really ugly!!
|
||||
glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID);
|
||||
if( activeTextureID != glTextureID)
|
||||
{
|
||||
glEnd();
|
||||
glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
|
||||
activeTextureID = glTextureID;
|
||||
glBegin( GL_QUADS);
|
||||
}
|
||||
|
||||
glBegin( GL_QUADS);
|
||||
glTexCoord2f( uv[0].x, uv[0].y); glVertex2f( pen.x + pos.x, pen.y + pos.y);
|
||||
glTexCoord2f( uv[1].x, uv[0].y); glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y);
|
||||
glTexCoord2f( uv[1].x, uv[1].y); glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y - destHeight);
|
||||
glTexCoord2f( uv[0].x, uv[1].y); glVertex2f( pen.x + pos.x, pen.y + pos.y - destHeight);
|
||||
glEnd();
|
||||
|
||||
return advance;
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
|
||||
* @param u The texture co-ord for this glyph
|
||||
* @param v The texture co-ord for this glyph
|
||||
*/
|
||||
FTTextureGlyph( FT_Glyph glyph, int id, unsigned char* data, int stride, int height, float u, float v);
|
||||
FTTextureGlyph( FT_Glyph glyph, int id, unsigned char* data, GLsizei stride, GLsizei height, float u, float v);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -50,11 +50,11 @@ class FTGL_EXPORT FTTextureGlyph : public FTGlyph
|
||||
/**
|
||||
* The texture index of the currently active texture
|
||||
*
|
||||
* Because a a full set of glyphs may not fit on one glyph we need
|
||||
* to keep track of the current active texture to try to reduce the
|
||||
* number of texture bind operations
|
||||
* We call glGetIntegerv( GL_TEXTURE_2D_BINDING, activeTextureID);
|
||||
* to get the currently active texture to try to reduce the number
|
||||
* of texture bind operations
|
||||
*/
|
||||
static int activeTextureID;
|
||||
GLint activeTextureID;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -1,86 +0,0 @@
|
||||
#include "FTVectorGlyph.h"
|
||||
#include "FTVectoriser.h"
|
||||
#include "FTGL.h"
|
||||
|
||||
|
||||
|
||||
FTVectorGlyph::FTVectorGlyph( FT_Glyph glyph)
|
||||
: FTGlyph(),
|
||||
vectoriser(0),
|
||||
numPoints(0),
|
||||
numContours(0),
|
||||
contourLength(0),
|
||||
data(0),
|
||||
glList(0)
|
||||
{
|
||||
if( ft_glyph_format_outline != glyph->format)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vectoriser = new FTVectoriser( glyph);
|
||||
|
||||
vectoriser->Ingest();
|
||||
numContours = vectoriser->contours();
|
||||
contourLength = new int[ numContours];
|
||||
|
||||
int c;
|
||||
for( c = 0; c < numContours; ++c)
|
||||
{
|
||||
contourLength[c] = vectoriser->contourSize( c);
|
||||
}
|
||||
|
||||
numPoints = vectoriser->points();
|
||||
data = new double[ numPoints * 3];
|
||||
vectoriser->Output( data);
|
||||
|
||||
advance = glyph->advance.x >> 16;
|
||||
|
||||
delete vectoriser;
|
||||
|
||||
if ( ( numContours < 1) || ( numPoints < 3))
|
||||
return;
|
||||
|
||||
glList = glGenLists(1);
|
||||
int d = 0;
|
||||
|
||||
glNewList( glList, GL_COMPILE);
|
||||
for( c = 0; c < numContours; ++c)
|
||||
{
|
||||
glBegin( GL_LINE_LOOP);
|
||||
for( int p = 0; p < ( contourLength[c]); ++p)
|
||||
{
|
||||
glVertex2dv( data + d);
|
||||
d += 3;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
glEndList();
|
||||
|
||||
// discard glyph image (bitmap or not)
|
||||
FT_Done_Glyph( glyph); // Why does this have to be HERE
|
||||
}
|
||||
|
||||
|
||||
FTVectorGlyph::~FTVectorGlyph()
|
||||
{
|
||||
delete [] data;
|
||||
delete [] contourLength;
|
||||
}
|
||||
|
||||
|
||||
float FTVectorGlyph::Render( const FT_Vector& pen)
|
||||
{
|
||||
if( glList)
|
||||
{
|
||||
glTranslatef( pen.x, pen.y, 0);
|
||||
glCallList( glList);
|
||||
glTranslatef( -pen.x, -pen.y, 0);
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
#ifndef __FTVectorGlyph__
|
||||
#define __FTVectorGlyph__
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "FTGlyph.h"
|
||||
|
||||
class FTVectoriser;
|
||||
|
||||
class FTVectorGlyph : public FTGlyph
|
||||
{
|
||||
public:
|
||||
// methods
|
||||
FTVectorGlyph( FT_Glyph glyph);
|
||||
virtual ~FTVectorGlyph();
|
||||
virtual float Render( const FT_Vector& pen);
|
||||
|
||||
// attributes
|
||||
|
||||
private:
|
||||
// methods
|
||||
|
||||
// attributes
|
||||
FTVectoriser* vectoriser;
|
||||
int numPoints;
|
||||
int numContours;
|
||||
int* contourLength;
|
||||
double* data;
|
||||
int glList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __FTVectorGlyph__
|
@ -28,8 +28,8 @@ void FTContour::AddPoint( const float x, const float y)
|
||||
|
||||
|
||||
FTVectoriser::FTVectoriser( const FT_Glyph glyph)
|
||||
: contourFlag(0),
|
||||
contour(0),
|
||||
: contour(0),
|
||||
contourFlag(0),
|
||||
kBSTEPSIZE( 0.2)
|
||||
{
|
||||
FT_OutlineGlyph outline = (FT_OutlineGlyph)glyph;
|
||||
@ -62,7 +62,7 @@ int FTVectoriser::points()
|
||||
}
|
||||
|
||||
|
||||
bool FTVectoriser::Ingest()
|
||||
bool FTVectoriser::Process()
|
||||
{
|
||||
short first = 0;
|
||||
short last;
|
||||
@ -208,7 +208,7 @@ void FTVectoriser::evaluateCurve( const int n)
|
||||
}
|
||||
|
||||
|
||||
void FTVectoriser::Output( double* data)
|
||||
void FTVectoriser::MakeOutline( double* data)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@ -225,3 +225,4 @@ void FTVectoriser::Output( double* data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class FTGL_EXPORT ftPoint
|
||||
|
||||
|
||||
/**
|
||||
* ftPoint class is a container of points that describe an outline
|
||||
* FTContour class is a container of points that describe an outline
|
||||
* point data.
|
||||
*
|
||||
* @see FTOutlineGlyph
|
||||
@ -122,8 +122,9 @@ class FTGL_EXPORT FTContour
|
||||
|
||||
private:
|
||||
/**
|
||||
* A 'max' number of points that this contour hods. Note it can
|
||||
* hold more than this number.
|
||||
* A 'max' number of points that this contour holds. Note however it
|
||||
* can hold more than this number. It is just used to reserve space
|
||||
* in the <vector>
|
||||
*/
|
||||
const unsigned int kMAXPOINTS;
|
||||
};
|
||||
@ -159,13 +160,13 @@ class FTGL_EXPORT FTVectoriser
|
||||
*
|
||||
* @return <code>true</code> on success
|
||||
*/
|
||||
bool Ingest();
|
||||
bool Process();
|
||||
|
||||
/**
|
||||
* Copy the point data into a block of <code>doubles</code>
|
||||
* Copy the outline data into a block of <code>doubles</code>
|
||||
* @param d
|
||||
*/
|
||||
void Output( double* d);
|
||||
void MakeOutline( double* d);
|
||||
|
||||
/**
|
||||
* Get the total count of points in this outline
|
||||
|
@ -3,24 +3,23 @@ include ../../Make/makedefs
|
||||
|
||||
C++FILES = \
|
||||
FTBitmapGlyph.cpp \
|
||||
FTGLOutlineFont.cpp \
|
||||
FTGlyphContainer.cpp \
|
||||
FTSize.cpp \
|
||||
FTCharmap.cpp \
|
||||
FTGLPixmapFont.cpp \
|
||||
FTLibrary.cpp \
|
||||
FTTextureGlyph.cpp \
|
||||
FTFace.cpp \
|
||||
FTGLPolygonFont.cpp \
|
||||
FTOutlineGlyph.cpp \
|
||||
FTVectoriser.cpp \
|
||||
FTFont.cpp \
|
||||
FTGLTextureFont.cpp \
|
||||
FTPixmapGlyph.cpp \
|
||||
FTGLBitmapFont.cpp \
|
||||
FTGLOutlineFont.cpp \
|
||||
FTGLPixmapFont.cpp \
|
||||
FTGLPolygonFont.cpp \
|
||||
FTGLTextureFont.cpp \
|
||||
FTGlyphContainer.cpp \
|
||||
FTGlyph.cpp \
|
||||
FTLibrary.cpp \
|
||||
FTOutlineGlyph.cpp \
|
||||
FTPixmapGlyph.cpp \
|
||||
FTPolyGlyph.cpp \
|
||||
FTVectorGlyph.cpp \
|
||||
FTSize.cpp \
|
||||
FTTextureGlyph.cpp \
|
||||
FTVectoriser.cpp \
|
||||
Text.cpp \
|
||||
Version.cpp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user