- got freetype-gl working under windows
This commit is contained in:
parent
ca40f8d0ab
commit
ab9243ea38
|
@ -163,7 +163,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="dsound.lib dxguid.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib opengl32.lib glu32.lib wsock32.lib libglest.lib mmc.lib lua5.1.lib xerces-c_3.lib Dbghelp.lib libpng.lib jpeg.lib zlib.lib sdl.lib sdlmain.lib winmm.lib openal32.lib iphlpapi.lib libstreflop.lib libcurl.lib ws2_32.lib libircclient.lib ftgl_static.lib freetype244MT.lib"
|
||||
AdditionalDependencies="dsound.lib dxguid.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib opengl32.lib glu32.lib wsock32.lib libglest.lib mmc.lib lua5.1.lib xerces-c_3.lib Dbghelp.lib libpng.lib jpeg.lib zlib.lib sdl.lib sdlmain.lib winmm.lib openal32.lib iphlpapi.lib libstreflop.lib libcurl.lib ws2_32.lib libircclient.lib ftgl_static.lib freetype244MT.lib glew32s.lib"
|
||||
OutputFile="$(OutDir)\megaglest.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../../source/win32_deps/lib;"../../build/$(ConfigurationName)/libglest";../../source/shared_lib/sources/streflop/libstreflop;../../source/win32_deps/libircclient/build/lib"
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../source/shared_lib/include;../../source/shared_lib/include/graphics;../../source/shared_lib/include/graphics/gl;../../source/shared_lib/include/platform;../../source/shared_lib/include/platform/win32;../../source/shared_lib/include/sound;../../source/shared_lib/include/sound/ds8;../../source/shared_lib/include/util;../../source/shared_lib/include/lua;../../source/shared_lib/include/xml;../../source/win32_deps/include;"../../source/win32_deps/xerces-c-3.0.1/src";"../../source/win32_deps/xerces-c-3.0.1/src/xercesc/xinclude";../../source/win32_deps/lpng141;"../../source/win32_deps/jpeg-8a";"../../source/win32_deps/SDL-1.2.x/include";../../source/shared_lib/include/platform/sdl;"../../source/win32_deps/openal-soft-1.12.854/include";../../source/shared_lib/include/sound/openal;../../source/shared_lib/include/platform/posix;../../source/shared_lib/include/streflop;../../source/shared_lib/include/streflop/libm_flt32_source;../../source/shared_lib/include/platform/common;"../../source/win32_deps/curl-7.21.3/include";../../source/shared_lib/include/map;../../source/shared_lib/include/platform/miniupnpc;../../source/shared_lib/include/libircclient/include;../../source/shared_lib/include/feathery_ftp;"../../source/win32_deps/glew-1.7.0/include";../../source/shared_lib/include/graphics/md5"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;USE_PCH=1;USE_STREFLOP;STREFLOP_SSE;STREFLOP_RANDOM_GEN_SIZE=32;LIBM_COMPILING_FLT32;CURL_STATICLIB;UNICODE;STATICLIB"
|
||||
AdditionalIncludeDirectories="../../source/shared_lib/include;../../source/shared_lib/include/graphics;../../source/shared_lib/include/graphics/gl;../../source/shared_lib/include/platform;../../source/shared_lib/include/platform/win32;../../source/shared_lib/include/sound;../../source/shared_lib/include/sound/ds8;../../source/shared_lib/include/util;../../source/shared_lib/include/lua;../../source/shared_lib/include/xml;../../source/win32_deps/include;"../../source/win32_deps/xerces-c-3.0.1/src";"../../source/win32_deps/xerces-c-3.0.1/src/xercesc/xinclude";../../source/win32_deps/lpng141;"../../source/win32_deps/jpeg-8a";"../../source/win32_deps/SDL-1.2.x/include";../../source/shared_lib/include/platform/sdl;"../../source/win32_deps/openal-soft-1.12.854/include";../../source/shared_lib/include/sound/openal;../../source/shared_lib/include/platform/posix;../../source/shared_lib/include/streflop;../../source/shared_lib/include/streflop/libm_flt32_source;../../source/shared_lib/include/platform/common;"../../source/win32_deps/curl-7.21.3/include";../../source/shared_lib/include/map;../../source/shared_lib/include/platform/miniupnpc;../../source/shared_lib/include/libircclient/include;../../source/shared_lib/include/feathery_ftp;"../../source/win32_deps/glew-1.7.0/include";../../source/shared_lib/include/graphics/md5;"../../source/shared_lib/include/graphics/freetype-gl""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;USE_PCH=1;USE_STREFLOP;STREFLOP_SSE;STREFLOP_RANDOM_GEN_SIZE=32;LIBM_COMPILING_FLT32;CURL_STATICLIB;UNICODE;STATICLIB;GLEW_STATIC"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -120,8 +120,8 @@
|
|||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories="../../source/shared_lib/include;../../source/shared_lib/include/graphics;../../source/shared_lib/include/graphics/gl;../../source/shared_lib/include/platform;../../source/shared_lib/include/platform/win32;../../source/shared_lib/include/sound;../../source/shared_lib/include/sound/ds8;../../source/shared_lib/include/util;../../source/shared_lib/include/lua;../../source/shared_lib/include/xml;../../source/win32_deps/include;"../../source/win32_deps/xerces-c-3.0.1/src";"../../source/win32_deps/xerces-c-3.0.1/src/xercesc/xinclude";../../source/win32_deps/lpng141;"../../source/win32_deps/jpeg-8a";"../../source/win32_deps/SDL-1.2.x/include";../../source/shared_lib/include/platform/sdl;"../../source/win32_deps/openal-soft-1.12.854/include";../../source/shared_lib/include/sound/openal;../../source/shared_lib/include/platform/posix;../../source/shared_lib/include/streflop;../../source/shared_lib/include/streflop/libm_flt32_source;../../source/shared_lib/include/platform/common;"../../source/win32_deps/curl-7.21.3/include";../../source/shared_lib/include/map;../../source/shared_lib/include/platform/miniupnpc;../../source/shared_lib/include/libircclient/include;../../source/shared_lib/include/feathery_ftp;"../../source/win32_deps/ftgl-2.1.3-rc5/src";"../../source/win32_deps/freetype-2.4.4/include";"../../source/win32_deps/glew-1.7.0/include";../../source/shared_lib/include/graphics/md5;$(NOINHERIT)"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;USE_PCH=1;USE_STREFLOP;STREFLOP_SSE;STREFLOP_RANDOM_GEN_SIZE=32;LIBM_COMPILING_FLT32;CURL_STATICLIB;UNICODE;USE_FTGL;TA3D_PLATFORM_MSVC;TA3D_PLATFORM_WINDOWS;STATICLIB"
|
||||
AdditionalIncludeDirectories="../../source/shared_lib/include;../../source/shared_lib/include/graphics;../../source/shared_lib/include/graphics/gl;../../source/shared_lib/include/platform;../../source/shared_lib/include/platform/win32;../../source/shared_lib/include/sound;../../source/shared_lib/include/sound/ds8;../../source/shared_lib/include/util;../../source/shared_lib/include/lua;../../source/shared_lib/include/xml;../../source/win32_deps/include;"../../source/win32_deps/xerces-c-3.0.1/src";"../../source/win32_deps/xerces-c-3.0.1/src/xercesc/xinclude";../../source/win32_deps/lpng141;"../../source/win32_deps/jpeg-8a";"../../source/win32_deps/SDL-1.2.x/include";../../source/shared_lib/include/platform/sdl;"../../source/win32_deps/openal-soft-1.12.854/include";../../source/shared_lib/include/sound/openal;../../source/shared_lib/include/platform/posix;../../source/shared_lib/include/streflop;../../source/shared_lib/include/streflop/libm_flt32_source;../../source/shared_lib/include/platform/common;"../../source/win32_deps/curl-7.21.3/include";../../source/shared_lib/include/map;../../source/shared_lib/include/platform/miniupnpc;../../source/shared_lib/include/libircclient/include;../../source/shared_lib/include/feathery_ftp;"../../source/win32_deps/ftgl-2.1.3-rc5/src";"../../source/win32_deps/freetype-2.4.4/include";"../../source/win32_deps/glew-1.7.0/include";../../source/shared_lib/include/graphics/md5;"../../source/shared_lib/include/graphics/freetype-gl";$(NOINHERIT)"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;USE_PCH=1;USE_STREFLOP;STREFLOP_SSE;STREFLOP_RANDOM_GEN_SIZE=32;LIBM_COMPILING_FLT32;CURL_STATICLIB;UNICODE;USE_FTGL;TA3D_PLATFORM_MSVC;TA3D_PLATFORM_WINDOWS;STATICLIB;GLEW_STATIC"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="2"
|
||||
RuntimeLibrary="0"
|
||||
|
@ -248,10 +248,22 @@
|
|||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\edtaa3func.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\font-manager.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\font_text.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\gl\font_text_freetypegl.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\feathery_ftp\ftpAccount.c"
|
||||
>
|
||||
|
@ -376,6 +388,10 @@
|
|||
RelativePath="..\..\source\shared_lib\sources\map\map_preview.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\markup.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\streflop\Random.cpp"
|
||||
>
|
||||
|
@ -396,6 +412,26 @@
|
|||
RelativePath="..\..\source\shared_lib\sources\util\string_utils.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\texture-atlas.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\texture-font.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\texture-glyph.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\vector.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\freetype-gl\vertex-buffer.c"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="graphics"
|
||||
>
|
||||
|
@ -500,11 +536,11 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\texture.cpp"
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\md5\Texture.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\md5\Texture.cpp"
|
||||
RelativePath="..\..\source\shared_lib\sources\graphics\texture.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
|
|
@ -32,20 +32,22 @@
|
|||
* ========================================================================= */
|
||||
#ifndef __VERTEX_BUFFER_H__
|
||||
#define __VERTEX_BUFFER_H__
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <Glut/glut.h>
|
||||
//#include <Glut/glut.h>
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
//#include <GL/glut.h>
|
||||
#endif
|
||||
#include "vector.h"
|
||||
|
||||
#define MAX_VERTEX_ATTRIBUTE 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Generic vertex attribute.
|
||||
*/
|
||||
|
@ -133,8 +135,6 @@ typedef struct
|
|||
VertexAttribute *attributes[MAX_VERTEX_ATTRIBUTE];
|
||||
} VertexBuffer;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates an empty vertex buffer.
|
||||
*
|
||||
|
@ -470,8 +470,5 @@ vertex_attribute_new( GLenum target,
|
|||
char *
|
||||
GL_TYPE_STRING( GLenum gtype );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __VERTEX_BUFFER_H__ */
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
* those of the authors and should not be interpreted as representing official
|
||||
* policies, either expressed or implied, of Nicolas P. Rougier.
|
||||
* ========================================================================= */
|
||||
#ifdef HAVE_FONTCONFIG
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
|
@ -122,6 +125,7 @@ font_manager_get_from_description( FontManager *self,
|
|||
{
|
||||
assert( self );
|
||||
|
||||
{
|
||||
TextureFont *font;
|
||||
char *filename = font_manager_match_description( self, family, size, bold, italic );
|
||||
// fprintf(stderr, "Matched filename for %s: %s\n", family, filename);
|
||||
|
@ -132,6 +136,7 @@ font_manager_get_from_description( FontManager *self,
|
|||
font = font_manager_get_from_filename( self, filename, size );
|
||||
free( filename );
|
||||
return font;
|
||||
}
|
||||
}
|
||||
|
||||
TextureFont *
|
||||
|
@ -140,10 +145,12 @@ font_manager_get_from_markup( FontManager *self,
|
|||
{
|
||||
assert( self );
|
||||
assert( markup );
|
||||
{
|
||||
TextureFont *font =
|
||||
font_manager_get_from_description( self, markup->family, markup->size,
|
||||
markup->bold, markup->italic );
|
||||
return font;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,6 +162,8 @@ font_manager_match_description( FontManager *self,
|
|||
const int italic )
|
||||
{
|
||||
char *filename = 0;
|
||||
|
||||
#ifdef HAVE_FONTCONFIG
|
||||
int weight = FC_WEIGHT_REGULAR;
|
||||
int slant = FC_SLANT_ROMAN;
|
||||
if ( bold )
|
||||
|
@ -196,6 +205,8 @@ font_manager_match_description( FontManager *self,
|
|||
}
|
||||
}
|
||||
FcPatternDestroy( match );
|
||||
#endif
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,19 @@
|
|||
* policies, either expressed or implied, of Nicolas P. Rougier.
|
||||
* ========================================================================= */
|
||||
#if defined(__APPLE__)
|
||||
#include <Glut/glut.h>
|
||||
//#include <Glut/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
//#include <GL/glut.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
//#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
//#include <glprocs.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
@ -55,6 +63,7 @@ texture_atlas_new( size_t width, size_t height, size_t depth )
|
|||
{
|
||||
assert( (depth == 1) || (depth == 3) );
|
||||
|
||||
{
|
||||
TextureAtlas *self = (TextureAtlas *) malloc( sizeof(TextureAtlas) );
|
||||
if( !self )
|
||||
{
|
||||
|
@ -65,18 +74,22 @@ texture_atlas_new( size_t width, size_t height, size_t depth )
|
|||
self->width = width;
|
||||
self->height = height;
|
||||
self->depth = depth;
|
||||
|
||||
{
|
||||
Node node = {0,0,width};
|
||||
vector_push_back( self->nodes, &node );
|
||||
self->texid = 0;
|
||||
self->data = (unsigned char *)
|
||||
calloc( width*height*depth, sizeof(unsigned char) );
|
||||
|
||||
|
||||
{
|
||||
// This is a special region that is used for background and underlined
|
||||
// decorations of glyphs
|
||||
int n = 4;
|
||||
unsigned char buffer[n*n];
|
||||
//unsigned char buffer[n*n];
|
||||
unsigned char buffer[16];
|
||||
memset(buffer, 255, n*n);
|
||||
{
|
||||
Region r = texture_atlas_get_region( self, n, n );
|
||||
texture_atlas_set_region( self, r.x, r.y, r.width, r.height, buffer, 1);
|
||||
self->black.x = r.x + 1;
|
||||
|
@ -85,6 +98,10 @@ texture_atlas_new( size_t width, size_t height, size_t depth )
|
|||
self->black.height= r.height - 2;
|
||||
|
||||
return self;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,6 +166,7 @@ texture_atlas_set_region( TextureAtlas *self,
|
|||
assert( (x + width) <= self->width);
|
||||
assert( y < self->height);
|
||||
assert( (y + height) <= self->height);
|
||||
{
|
||||
size_t i;
|
||||
size_t depth = self->depth;
|
||||
size_t charsize = sizeof(char);
|
||||
|
@ -157,6 +175,7 @@ texture_atlas_set_region( TextureAtlas *self,
|
|||
memcpy( self->data+((y+i)*self->width + x ) * charsize * depth,
|
||||
data + (i*stride) * charsize, width * charsize * depth );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,6 +243,7 @@ texture_atlas_get_region( TextureAtlas *self,
|
|||
assert( width );
|
||||
assert( height );
|
||||
*/
|
||||
{
|
||||
int y, best_height, best_width, best_index;
|
||||
Node *node, *prev;
|
||||
Region region = {0,0,width,height};
|
||||
|
@ -294,6 +314,7 @@ texture_atlas_get_region( TextureAtlas *self,
|
|||
texture_atlas_merge( self );
|
||||
self->used += width * height;
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -304,21 +325,28 @@ texture_atlas_clear( TextureAtlas *self )
|
|||
|
||||
vector_clear( self->nodes );
|
||||
self->used = 0;
|
||||
{
|
||||
Node node = {0,0,self->width};
|
||||
vector_push_back( self->nodes, &node );
|
||||
|
||||
memset( self->data, 0, self->width*self->height*self->depth );
|
||||
|
||||
|
||||
{
|
||||
// This is a special region that is used for background and underlined
|
||||
// decorations of glyphs
|
||||
int n = 4;
|
||||
unsigned char buffer[n*n];
|
||||
//unsigned char buffer[n*n];
|
||||
unsigned char buffer[16];
|
||||
memset(buffer, 255, n*n);
|
||||
{
|
||||
Region r = texture_atlas_get_region( self, n, n );
|
||||
texture_atlas_set_region( self, r.x, r.y, r.width, r.height, buffer, 1);
|
||||
self->black.x = r.x + 1;
|
||||
self->black.y = r.y + 1;
|
||||
self->black.width = r.width - 2;
|
||||
self->black.height= r.height - 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include FT_FREETYPE_H
|
||||
// #include FT_ADVANCES_H
|
||||
#include FT_LCD_FILTER_H
|
||||
#include <stdint.h>
|
||||
//#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
@ -83,6 +83,7 @@ texture_font_new( TextureAtlas *atlas,
|
|||
self->lcd_weights[3] = 0;
|
||||
self->lcd_weights[4] = 0;
|
||||
|
||||
{
|
||||
/* Get font metrics at high resolution */
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
|
@ -91,6 +92,7 @@ texture_font_new( TextureAtlas *atlas,
|
|||
return self;
|
||||
}
|
||||
|
||||
{
|
||||
FT_Size_Metrics metrics = face->size->metrics;
|
||||
self->ascender = (metrics.ascender >> 6) / 100.0;
|
||||
self->descender = (metrics.descender >> 6) / 100.0;
|
||||
|
@ -98,6 +100,8 @@ texture_font_new( TextureAtlas *atlas,
|
|||
self->linegap = self->height - self->ascender + self->descender;
|
||||
|
||||
return self;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,6 +228,7 @@ texture_font_cache_glyphs( TextureFont *self,
|
|||
{
|
||||
glyph_index = FT_Get_Char_Index( face, charcodes[i] );
|
||||
|
||||
{
|
||||
// WARNING: We use texture-atlas depth to guess if user wants
|
||||
// LCD subpixel rendering
|
||||
FT_Int32 flags = FT_LOAD_RENDER;
|
||||
|
@ -239,12 +244,16 @@ texture_font_cache_glyphs( TextureFont *self,
|
|||
|
||||
if( depth == 3 )
|
||||
{
|
||||
#if ((FREETYPE_MAJOR <= 2) && ((FREETYPE_MINOR < 3)))
|
||||
//#error "Need FreeType 2.3.0 or newer"
|
||||
#else
|
||||
FT_Library_SetLcdFilter( library, FT_LCD_FILTER_LIGHT );
|
||||
flags |= FT_LOAD_TARGET_LCD;
|
||||
if( self->lcd_filter )
|
||||
{
|
||||
FT_Library_SetLcdFilterWeights( library, self->lcd_weights );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
error = FT_Load_Glyph( face, glyph_index, flags );
|
||||
|
||||
|
@ -309,6 +318,7 @@ texture_font_cache_glyphs( TextureFont *self,
|
|||
vector_push_back( self->glyphs, glyph );
|
||||
texture_glyph_delete( glyph );
|
||||
}
|
||||
}
|
||||
FT_Done_Face( face );
|
||||
FT_Done_FreeType( library );
|
||||
texture_atlas_upload( self->atlas );
|
||||
|
@ -350,8 +360,10 @@ texture_font_get_glyph( TextureFont *self,
|
|||
|
||||
if( texture_font_cache_glyphs( self, buffer ) == 0 )
|
||||
{
|
||||
free(buffer);
|
||||
return (TextureGlyph *) vector_back( self->glyphs );
|
||||
}
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,14 @@
|
|||
* policies, either expressed or implied, of Nicolas P. Rougier.
|
||||
* ========================================================================= */
|
||||
#if defined(__APPLE__)
|
||||
#include <Glut/glut.h>
|
||||
//#include <Glut/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
//#include <windows.h>
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "texture-font.h"
|
||||
|
@ -84,6 +88,7 @@ texture_glyph_render( TextureGlyph *self,
|
|||
{
|
||||
assert( self );
|
||||
|
||||
{
|
||||
int x = pen->x + self->offset_x;
|
||||
int y = pen->y + self->offset_y + markup->rise;
|
||||
int w = self->width;
|
||||
|
@ -108,6 +113,7 @@ texture_glyph_render( TextureGlyph *self,
|
|||
|
||||
pen->x += self->advance_x + markup->spacing;
|
||||
pen->y += self->advance_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,6 +156,8 @@ texture_glyph_add_to_vertex_buffer( const TextureGlyph *self,
|
|||
g = markup->background_color.g;
|
||||
b = markup->background_color.b;
|
||||
a = markup->background_color.a;
|
||||
|
||||
{
|
||||
GLuint index = buffer->vertices->size;
|
||||
GLuint indices[] = {index, index+1, index+2,
|
||||
index, index+2, index+3};
|
||||
|
@ -160,6 +168,7 @@ texture_glyph_add_to_vertex_buffer( const TextureGlyph *self,
|
|||
vertex_buffer_push_back_indices( buffer, indices, 6 );
|
||||
vertex_buffer_push_back_vertices( buffer, vertices, 4 );
|
||||
}
|
||||
}
|
||||
|
||||
// Underline
|
||||
|
||||
|
@ -177,6 +186,8 @@ texture_glyph_add_to_vertex_buffer( const TextureGlyph *self,
|
|||
b = markup->foreground_color.b;
|
||||
a = markup->foreground_color.a;
|
||||
}
|
||||
|
||||
{
|
||||
int x0 = (int)( pen->x + self->offset_x );
|
||||
int y0 = (int)( pen->y + self->offset_y + rise );
|
||||
int x1 = (int)( x0 + self->width );
|
||||
|
@ -197,6 +208,7 @@ texture_glyph_add_to_vertex_buffer( const TextureGlyph *self,
|
|||
|
||||
pen->x += self->advance_x + spacing;
|
||||
pen->y += self->advance_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ vector_new( size_t item_size )
|
|||
{
|
||||
assert( item_size );
|
||||
|
||||
{
|
||||
Vector *self = (Vector *) malloc( sizeof(Vector) );
|
||||
if( !self )
|
||||
{
|
||||
|
@ -54,6 +55,7 @@ vector_new( size_t item_size )
|
|||
self->capacity = 1;
|
||||
self->items = malloc( self->item_size * self->capacity );
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,7 +79,8 @@ vector_get( const Vector *self,
|
|||
assert( self );
|
||||
assert( self->size );
|
||||
assert( index < self->size );
|
||||
return self->items + index * self->item_size;
|
||||
|
||||
return (char *)self->items + index * self->item_size;
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,7 +205,7 @@ vector_set( Vector *self,
|
|||
assert( self );
|
||||
assert( self->size );
|
||||
assert( index < self->size );
|
||||
memcpy( self->items + index * self->item_size,
|
||||
memcpy( (char *)self->items + index * self->item_size,
|
||||
item, self->item_size );
|
||||
}
|
||||
|
||||
|
@ -223,8 +226,8 @@ vector_insert( Vector *self,
|
|||
}
|
||||
if( index < self->size )
|
||||
{
|
||||
memmove( self->items + (index + 1) * self->item_size,
|
||||
self->items + (index + 0) * self->item_size,
|
||||
memmove( (char *)self->items + (index + 1) * self->item_size,
|
||||
(char *)self->items + (index + 0) * self->item_size,
|
||||
(self->size - index) * self->item_size);
|
||||
}
|
||||
self->size++;
|
||||
|
@ -243,8 +246,8 @@ vector_erase_range( Vector *self,
|
|||
assert( first < self->size );
|
||||
assert( last < self->size+1 );
|
||||
assert( first < last );
|
||||
memmove( self->items + first * self->item_size,
|
||||
self->items + last * self->item_size,
|
||||
memmove( (char *)self->items + first * self->item_size,
|
||||
(char *)self->items + last * self->item_size,
|
||||
(self->size - last) * self->item_size);
|
||||
self->size -= (last-first);
|
||||
}
|
||||
|
@ -318,7 +321,7 @@ vector_push_back_data( Vector *self,
|
|||
{
|
||||
vector_reserve(self, self->size+count);
|
||||
}
|
||||
memmove( self->items + self->size * self->item_size, data,
|
||||
memmove( (char *)self->items + self->size * self->item_size, data,
|
||||
count*self->item_size );
|
||||
self->size += count;
|
||||
}
|
||||
|
@ -341,10 +344,10 @@ vector_insert_data( Vector *self,
|
|||
{
|
||||
vector_reserve(self, self->size+count);
|
||||
}
|
||||
memmove( self->items + (index + count ) * self->item_size,
|
||||
self->items + (index ) * self->item_size,
|
||||
memmove( (char *)self->items + (index + count ) * self->item_size,
|
||||
(char *)self->items + (index ) * self->item_size,
|
||||
count*self->item_size );
|
||||
memmove( self->items + index * self->item_size, data,
|
||||
memmove( (char *)self->items + index * self->item_size, data,
|
||||
count*self->item_size );
|
||||
self->size += count;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ vertex_buffer_new( const char *format )
|
|||
do
|
||||
{
|
||||
end = (char *) (strchr(start+1, ':'));
|
||||
{
|
||||
char *desc = 0;
|
||||
if (end == NULL)
|
||||
{
|
||||
|
@ -72,14 +73,18 @@ vertex_buffer_new( const char *format )
|
|||
{
|
||||
desc = strndup(start, end-start);
|
||||
}
|
||||
|
||||
{
|
||||
VertexAttribute *attribute = vertex_attribute_parse( desc );
|
||||
start = end+1;
|
||||
free(desc);
|
||||
attribute->pointer = pointer;
|
||||
stride += attribute->size*GL_TYPE_SIZE( attribute->type );
|
||||
pointer+= attribute->size*GL_TYPE_SIZE( attribute->type );
|
||||
pointer = (char *)pointer + attribute->size*GL_TYPE_SIZE( attribute->type );
|
||||
self->attributes[index] = attribute;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
} while ( end && (index < MAX_VERTEX_ATTRIBUTE) );
|
||||
|
||||
for( i=0; i<index; ++i )
|
||||
|
@ -156,6 +161,7 @@ vertex_buffer_print( VertexBuffer * self )
|
|||
{
|
||||
assert(self);
|
||||
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
fprintf( stderr, "%ld vertices, %ld indices\n",
|
||||
|
@ -205,6 +211,7 @@ vertex_buffer_print( VertexBuffer * self )
|
|||
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -269,6 +276,7 @@ vertex_buffer_render ( VertexBuffer *self,
|
|||
glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );
|
||||
|
||||
{
|
||||
size_t i;
|
||||
for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i )
|
||||
{
|
||||
|
@ -303,6 +311,7 @@ vertex_buffer_render ( VertexBuffer *self,
|
|||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
|
||||
glPopClientAttrib( );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -499,18 +508,24 @@ vertex_attribute_parse( char *format )
|
|||
int size, index;
|
||||
char ctype;
|
||||
sscanf( format, "%dgn%d%c", &index, &size, &ctype );
|
||||
|
||||
{
|
||||
GLenum type = GL_TYPE( ctype );
|
||||
return vertex_attribute_new( 0, index, size, type, GL_TRUE, 0, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int size, index;
|
||||
char ctype;
|
||||
sscanf( format, "%dg%d%c", &index, &size, &ctype );
|
||||
|
||||
{
|
||||
GLenum type = GL_TYPE( ctype );
|
||||
return vertex_attribute_new( 0, index, size, type, GL_FALSE, 0, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Known attribute
|
||||
p = strpbrk ( format, "vcntfse" );
|
||||
|
@ -519,10 +534,13 @@ vertex_attribute_parse( char *format )
|
|||
int size;
|
||||
char ctarget, ctype;
|
||||
sscanf( format, "%c%d%c", &ctarget, &size, &ctype );
|
||||
|
||||
{
|
||||
GLenum type = GL_TYPE( ctype );
|
||||
GLenum target = GL_VERTEX_ATTRIBUTE_TARGET( ctarget );
|
||||
return vertex_attribute_new( target, 0, size, type, GL_FALSE, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "Vertex attribute format not understood\n");
|
||||
return 0;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifdef USE_FREETYPEGL
|
||||
|
||||
#include "font_text_freetypegl.h"
|
||||
#include "vector.h"
|
||||
#include "vectort.h"
|
||||
|
||||
//#include "opengl.h"
|
||||
#include <stdexcept>
|
||||
|
@ -22,10 +22,12 @@
|
|||
#include <fontconfig/fontconfig.h>
|
||||
#endif
|
||||
|
||||
#include "platform_common.h"
|
||||
#include "util.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Shared::Util;
|
||||
using namespace Shared::PlatformCommon;
|
||||
|
||||
namespace Shared { namespace Graphics { namespace Gl {
|
||||
|
||||
|
@ -67,7 +69,7 @@ void TextFreetypeGL::init(string fontName, int fontSize) {
|
|||
this->buffer = vertex_buffer_new( "v3f:t2f:c4f" );
|
||||
|
||||
//font = texture_font_new( atlas, "Verdana", minsize );
|
||||
this->font = texture_font_new( atlas, fontFile, fontFaceSize );
|
||||
this->font = texture_font_new( atlas, fontFile, (float)fontFaceSize );
|
||||
//font = texture_font_new( atlas, font_manager_match_description( 0, "Verdana", minsize, bold, italic ), minsize );
|
||||
|
||||
int missed = texture_font_cache_glyphs( font, cache );
|
||||
|
@ -95,10 +97,10 @@ void TextFreetypeGL::Render(const char* str, const int len) {
|
|||
|
||||
vertex_buffer_clear( this->buffer );
|
||||
|
||||
float currentColor[4];
|
||||
float currentColor[4] = { 0,0,0,1 };
|
||||
glGetFloatv(GL_CURRENT_COLOR,currentColor);
|
||||
|
||||
Markup markup = { 0, this->fontFaceSize, 0, 0, 0.0, 0.0,
|
||||
Markup markup = { 0, (float)this->fontFaceSize, 0, 0, 0.0, 0.0,
|
||||
{currentColor[0],currentColor[1],currentColor[2],currentColor[3]}, {0,0,0,0},
|
||||
0, {0,0,0,1}, 0, {0,0,0,1},
|
||||
0, {0,0,0,1}, 0, {0,0,0,1}, 0 };
|
||||
|
@ -118,10 +120,10 @@ void TextFreetypeGL::Render(const char* str, const int len) {
|
|||
TextureGlyph *glyph = texture_font_get_glyph( this->font, thisChar );
|
||||
|
||||
// Take kerning into account if necessary
|
||||
int kx = texture_glyph_get_kerning( glyph, prevChar );
|
||||
float kx = texture_glyph_get_kerning( glyph, prevChar );
|
||||
|
||||
// Add glyph to the vertex buffer
|
||||
texture_glyph_add_to_vertex_buffer( glyph, this->buffer, &markup, &pen, kx );
|
||||
texture_glyph_add_to_vertex_buffer( glyph, this->buffer, &markup, &pen, (int)kx );
|
||||
}
|
||||
|
||||
//glBindTexture( GL_TEXTURE_2D, manager->atlas->texid );
|
||||
|
@ -130,6 +132,7 @@ void TextFreetypeGL::Render(const char* str, const int len) {
|
|||
glEnable( GL_BLEND );
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
|
||||
vertex_buffer_render( this->buffer, GL_TRIANGLES, "vtc" );
|
||||
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
|
@ -149,10 +152,10 @@ void TextFreetypeGL::Render(const wchar_t* str, const int len) {
|
|||
|
||||
vertex_buffer_clear( this->buffer );
|
||||
|
||||
float currentColor[4];
|
||||
GLfloat currentColor[4] = { 0,0,0,1 };
|
||||
glGetFloatv(GL_CURRENT_COLOR,currentColor);
|
||||
|
||||
Markup markup = { 0, this->fontFaceSize, 0, 0, 0.0, 0.0,
|
||||
Markup markup = { 0, (float)this->fontFaceSize, 0, 0, 0.0, 0.0,
|
||||
{currentColor[0],currentColor[1],currentColor[2],currentColor[3]}, {0,0,0,0},
|
||||
0, {0,0,0,1}, 0, {0,0,0,1},
|
||||
0, {0,0,0,1}, 0, {0,0,0,1}, 0 };
|
||||
|
@ -163,10 +166,10 @@ void TextFreetypeGL::Render(const wchar_t* str, const int len) {
|
|||
TextureGlyph *glyph = texture_font_get_glyph( this->font, text[i] );
|
||||
|
||||
// Take kerning into account if necessary
|
||||
int kx = texture_glyph_get_kerning( glyph, text[i-1] );
|
||||
float kx = texture_glyph_get_kerning( glyph, text[i-1] );
|
||||
|
||||
// Add glyph to the vertex buffer
|
||||
texture_glyph_add_to_vertex_buffer( glyph, this->buffer, &markup, &pen, kx );
|
||||
texture_glyph_add_to_vertex_buffer( glyph, this->buffer, &markup, &pen, (int)kx );
|
||||
}
|
||||
|
||||
//glBindTexture( GL_TEXTURE_2D, manager->atlas->texid );
|
||||
|
@ -202,7 +205,7 @@ float TextFreetypeGL::LineHeight(const char* str, const int len) {
|
|||
float result = 0;
|
||||
if(strlen(str) > 0) {
|
||||
TextureGlyph *glyph = texture_font_get_glyph( font, str[0] );
|
||||
result = glyph->height;
|
||||
result = (float)glyph->height;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -211,7 +214,7 @@ float TextFreetypeGL::LineHeight(const wchar_t* str, const int len) {
|
|||
float result = 0;
|
||||
if(wcslen(str) > 0) {
|
||||
TextureGlyph *glyph = texture_font_get_glyph( font, str[0] );
|
||||
result = glyph->height;
|
||||
result = (float)glyph->height;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user