mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
fixed new font rendering on Linux and removed glew dependency
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -33,21 +33,23 @@
|
||||
#ifndef __VERTEX_BUFFER_H__
|
||||
#define __VERTEX_BUFFER_H__
|
||||
|
||||
#if defined(__APPLE__)
|
||||
//#include <Glut/glut.h>
|
||||
#elif defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#else
|
||||
//#include <GL/glut.h>
|
||||
#include <GL/glu.h>
|
||||
#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__ */
|
||||
|
@@ -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 <Glut/glut.h>
|
||||
//#include <Glut/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
//#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
@@ -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;
|
||||
}
|
||||
*/
|
||||
|
@@ -40,7 +40,8 @@
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
|
||||
//#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
//#include <glprocs.h>
|
||||
|
||||
|
@@ -244,11 +244,12 @@ texture_font_cache_glyphs( TextureFont *self,
|
||||
|
||||
if( depth == 3 )
|
||||
{
|
||||
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
|
||||
FT_Library_SetLcdFilter( library, FT_LCD_FILTER_LIGHT );
|
||||
flags |= FT_LOAD_TARGET_LCD;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -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 <Glut/glut.h>
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
//#include <windows.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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++;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#ifdef USE_FREETYPEGL
|
||||
|
||||
#include "font_text_freetypegl.h"
|
||||
#include "vectort.h"
|
||||
#include "vector.h"
|
||||
|
||||
//#include "opengl.h"
|
||||
#include <stdexcept>
|
||||
|
Reference in New Issue
Block a user