diff --git a/source/shared_lib/CMakeLists.txt b/source/shared_lib/CMakeLists.txt index 91a60c8df..1052f39aa 100644 --- a/source/shared_lib/CMakeLists.txt +++ b/source/shared_lib/CMakeLists.txt @@ -191,8 +191,21 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST OPTION(USE_FREETYPEGL "Use Freetype-GL for on-screen fonts" ON) if(USE_FREETYPEGL) ADD_DEFINITIONS(-DUSE_FREETYPEGL) + + FIND_PACKAGE(Freetype REQUIRED) + INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_PATH}) + IF(UNIX) + SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FREETYPE_LIBRARY}) + ENDIF() + endif(USE_FREETYPEGL) + #FIND_PACKAGE(GLEW REQUIRED) + #INCLUDE_DIRECTORIES(${GLEW_INCLUDE_PATH}) + #IF(UNIX) + # SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${GLEW_LIBRARY}) + #ENDIF() + ######################################################################################### # megaglest lib diff --git a/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h b/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h index b44c7f4f3..63e007e58 100644 --- a/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h +++ b/source/shared_lib/include/graphics/freetype-gl/vertex-buffer.h @@ -33,21 +33,23 @@ #ifndef __VERTEX_BUFFER_H__ #define __VERTEX_BUFFER_H__ -#if defined(__APPLE__) - //#include -#elif defined(_WIN32) +#if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include #include #else - //#include + #include #endif #include "vector.h" #define MAX_VERTEX_ATTRIBUTE 64 +#ifdef __cplusplus +extern "C" { +#endif + /** * Generic vertex attribute. */ @@ -471,4 +473,9 @@ vertex_attribute_new( GLenum target, GL_TYPE_STRING( GLenum gtype ); +#ifdef __cplusplus +} +#endif + + #endif /* __VERTEX_BUFFER_H__ */ diff --git a/source/shared_lib/sources/graphics/freetype-gl/makefont.c b/source/shared_lib/sources/graphics/freetype-gl/makefont.c index 4e0f70bec..e9413dc67 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/makefont.c +++ b/source/shared_lib/sources/graphics/freetype-gl/makefont.c @@ -30,11 +30,24 @@ * those of the authors and should not be interpreted as representing official * policies, either expressed or implied, of Nicolas P. Rougier. * ========================================================================= */ + +/* #if defined(__APPLE__) - #include + //#include #else - #include + //#include #endif + +#if defined(_WIN32) + +#define WIN32_LEAN_AND_MEAN +#include +#include + +#else + #include +#endif + #include #include #include @@ -149,38 +162,38 @@ int main( int argc, char **argv ) // Header // ------------- fwprintf( file, - L"/* =========================================================================\n" - L" * Freetype GL - A C OpenGL Freetype engine\n" - L" * Platform: Any\n" - L" * WWW: http://code.google.com/p/freetype-gl/\n" - L" * -------------------------------------------------------------------------\n" - L" * Copyright 2011 Nicolas P. Rougier. All rights reserved.\n" - L" *\n" - L" * Redistribution and use in source and binary forms, with or without\n" - L" * modification, are permitted provided that the following conditions are met:\n" - L" *\n" - L" * 1. Redistributions of source code must retain the above copyright notice,\n" - L" * this list of conditions and the following disclaimer.\n" - L" *\n" - L" * 2. Redistributions in binary form must reproduce the above copyright\n" - L" * notice, this list of conditions and the following disclaimer in the\n" - L" * documentation and/or other materials provided with the distribution.\n" - L" *\n" - L" * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR\n" - L" * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n" - L" * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n" - L" * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n" - L" * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n" - L" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n" - L" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n" - L" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" - L" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" - L" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" - L" *\n" - L" * The views and conclusions contained in the software and documentation are\n" - L" * those of the authors and should not be interpreted as representing official\n" - L" * policies, either expressed or implied, of Nicolas P. Rougier.\n" - L" * ========================================================================= */\n" ); + L"// =========================================================================\n" + L"// Freetype GL - A C OpenGL Freetype engine\n" + L"// Platform: Any\n" + L"// WWW: http://code.google.com/p/freetype-gl/\n" + L"// -------------------------------------------------------------------------\n" + L"// Copyright 2011 Nicolas P. Rougier. All rights reserved.\n" + L"//\n" + L"// Redistribution and use in source and binary forms, with or without\n" + L"// modification, are permitted provided that the following conditions are met:\n" + L"//\n" + L"// 1. Redistributions of source code must retain the above copyright notice,\n" + L"// this list of conditions and the following disclaimer.\n" + L"//\n" + L"// 2. Redistributions in binary form must reproduce the above copyright\n" + L"// notice, this list of conditions and the following disclaimer in the\n" + L"// documentation and/or other materials provided with the distribution.\n" + L"//\n" + L"// THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR\n" + L"// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n" + L"// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n" + L"// EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n" + L"// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n" + L"// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n" + L"// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n" + L"// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + L"// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" + L"// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + L"//\n" + L"// The views and conclusions contained in the software and documentation are\n" + L"// those of the authors and should not be interpreted as representing official\n" + L"// policies, either expressed or implied, of Nicolas P. Rougier.\n" + L"// ========================================================================= \n" ); @@ -269,38 +282,36 @@ int main( int argc, char **argv ) { TextureGlyph *glyph = (TextureGlyph *) vector_get( font->glyphs, i ); -/* - // Debugging information - wprintf( L"glyph : '%lc'\n", - glyph->charcode ); - wprintf( L" size : %dx%d\n", - glyph->width, glyph->height ); - wprintf( L" offset : %+d%+d\n", - glyph->offset_x, glyph->offset_y ); - wprintf( L" advance : %f, %f\n", - glyph->advance_x, glyph->advance_y ); - wprintf( L" tex coords.: %f, %f, %f, %f\n", - glyph->u0, glyph->v0, glyph->u1, glyph->v1 ); - - wprintf( L" kerning : " ); - if( glyph->kerning_count ) - { - for( j=0; j < glyph->kerning_count; ++j ) - { - wprintf( L"('%lc', %f)", - glyph->kerning[j].charcode, glyph->kerning[j].kerning ); - if( j < (glyph->kerning_count-1) ) - { - wprintf( L", " ); - } - } - } - else - { - wprintf( L"None" ); - } - wprintf( L"\n\n" ); -*/ +// // Debugging information +// wprintf( L"glyph : '%lc'\n", +// glyph->charcode ); +// wprintf( L" size : %dx%d\n", +// glyph->width, glyph->height ); +// wprintf( L" offset : %+d%+d\n", +// glyph->offset_x, glyph->offset_y ); +// wprintf( L" advance : %f, %f\n", +// glyph->advance_x, glyph->advance_y ); +// wprintf( L" tex coords.: %f, %f, %f, %f\n", +// glyph->u0, glyph->v0, glyph->u1, glyph->v1 ); +// +// wprintf( L" kerning : " ); +// if( glyph->kerning_count ) +// { +// for( j=0; j < glyph->kerning_count; ++j ) +// { +// wprintf( L"('%lc', %f)", +// glyph->kerning[j].charcode, glyph->kerning[j].kerning ); +// if( j < (glyph->kerning_count-1) ) +// { +// wprintf( L", " ); +// } +// } +// } +// else +// { +// wprintf( L"None" ); +// } +// wprintf( L"\n\n" ); // TextureFont if( (glyph->charcode == L'\'' ) || (glyph->charcode == L'\\' ) ) @@ -347,3 +358,4 @@ int main( int argc, char **argv ) return 0; } +*/ diff --git a/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c b/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c index e4fee448c..ef3dec104 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c +++ b/source/shared_lib/sources/graphics/freetype-gl/texture-atlas.c @@ -39,8 +39,9 @@ #ifdef WIN32 #include -#endif -#include +#endif + +//#include #include //#include diff --git a/source/shared_lib/sources/graphics/freetype-gl/texture-font.c b/source/shared_lib/sources/graphics/freetype-gl/texture-font.c index f12860d21..725c6678a 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/texture-font.c +++ b/source/shared_lib/sources/graphics/freetype-gl/texture-font.c @@ -244,11 +244,12 @@ 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 ((FREETYPE_MAJOR <= 2) && ((FREETYPE_MINOR < 3))) +//#error "Need FreeType 2.3.0 or newer" +#else + if( self->lcd_filter ) { FT_Library_SetLcdFilterWeights( library, self->lcd_weights ); @@ -360,10 +361,10 @@ texture_font_get_glyph( TextureFont *self, if( texture_font_cache_glyphs( self, buffer ) == 0 ) { - free(buffer); + //free(buffer); return (TextureGlyph *) vector_back( self->glyphs ); } - free(buffer); + //free(buffer); return NULL; } diff --git a/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c b/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c index 96684b1dd..4fa607769 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c +++ b/source/shared_lib/sources/graphics/freetype-gl/texture-glyph.c @@ -30,13 +30,14 @@ * those of the authors and should not be interpreted as representing official * policies, either expressed or implied, of Nicolas P. Rougier. * ========================================================================= */ -#if defined(__APPLE__) - //#include +#if defined(_WIN32) + +#define WIN32_LEAN_AND_MEAN +#include +#include + #else - -//#define WIN32_LEAN_AND_MEAN -//#include -#include + #include #endif #include diff --git a/source/shared_lib/sources/graphics/freetype-gl/vector.c b/source/shared_lib/sources/graphics/freetype-gl/vector.c index 4a36777ff..1500c03b8 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/vector.c +++ b/source/shared_lib/sources/graphics/freetype-gl/vector.c @@ -80,7 +80,11 @@ vector_get( const Vector *self, assert( self->size ); assert( index < self->size ); +#ifdef _WIN32 return (char *)self->items + index * self->item_size; +#else + return self->items + index * self->item_size; +#endif } @@ -205,8 +209,15 @@ vector_set( Vector *self, assert( self ); assert( self->size ); assert( index < self->size ); + +#ifdef _WIN32 memcpy( (char *)self->items + index * self->item_size, item, self->item_size ); +#else + memcpy( self->items + index * self->item_size, + item, self->item_size ); + +#endif } @@ -226,9 +237,16 @@ vector_insert( Vector *self, } if( index < self->size ) { +#ifdef _WIN32 memmove( (char *)self->items + (index + 1) * self->item_size, (char *)self->items + (index + 0) * self->item_size, (self->size - index) * self->item_size); +#else + memmove( self->items + (index + 1) * self->item_size, + self->items + (index + 0) * self->item_size, + (self->size - index) * self->item_size); + +#endif } self->size++; vector_set( self, index, item ); @@ -246,9 +264,16 @@ vector_erase_range( Vector *self, assert( first < self->size ); assert( last < self->size+1 ); assert( first < last ); + +#ifdef _WIN32 memmove( (char *)self->items + first * self->item_size, (char *)self->items + last * self->item_size, (self->size - last) * self->item_size); +#else + memmove( self->items + first * self->item_size, + self->items + last * self->item_size, + (self->size - last) * self->item_size); +#endif self->size -= (last-first); } @@ -321,8 +346,15 @@ vector_push_back_data( Vector *self, { vector_reserve(self, self->size+count); } + +#ifdef _WIN32 memmove( (char *)self->items + self->size * self->item_size, data, count*self->item_size ); +#else + memmove( self->items + self->size * self->item_size, data, + count*self->item_size ); +#endif + self->size += count; } @@ -344,11 +376,22 @@ vector_insert_data( Vector *self, { vector_reserve(self, self->size+count); } + +#ifdef _WIN32 memmove( (char *)self->items + (index + count ) * self->item_size, (char *)self->items + (index ) * self->item_size, count*self->item_size ); memmove( (char *)self->items + index * self->item_size, data, count*self->item_size ); +#else + memmove( self->items + (index + count ) * self->item_size, + self->items + (index ) * self->item_size, + count*self->item_size ); + memmove( self->items + index * self->item_size, data, + count*self->item_size ); + +#endif + self->size += count; } diff --git a/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c b/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c index 38607b9de..658d2e1a0 100644 --- a/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c +++ b/source/shared_lib/sources/graphics/freetype-gl/vertex-buffer.c @@ -80,7 +80,12 @@ vertex_buffer_new( const char *format ) free(desc); attribute->pointer = pointer; stride += attribute->size*GL_TYPE_SIZE( attribute->type ); + +#ifdef _WIN32 pointer = (char *)pointer + attribute->size*GL_TYPE_SIZE( attribute->type ); +#else + pointer += attribute->size*GL_TYPE_SIZE( attribute->type ); +#endif self->attributes[index] = attribute; index++; } diff --git a/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp b/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp index 3e239b2eb..8006fdf6e 100644 --- a/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp +++ b/source/shared_lib/sources/graphics/gl/font_text_freetypegl.cpp @@ -12,7 +12,7 @@ #ifdef USE_FREETYPEGL #include "font_text_freetypegl.h" -#include "vectort.h" +#include "vector.h" //#include "opengl.h" #include