Commit 1f2b4fe1 authored by Pierre-Emmanuel Lallemant's avatar Pierre-Emmanuel Lallemant

merge

parents 51755a24 d2d37943
......@@ -31,3 +31,7 @@ fonts/Verdana.ttf
CMakeFiles
CMakeCache.txt
*.o
libfreetype-gl.a
demo-make
cmake_install.cmake
Makefile
......@@ -26,7 +26,10 @@ install:
- cd ~/
- rm -rf AntTweakBar_116.zip
- rm -rf AntTweakBar
- cd build/rougier/freetype-gl
# another requirement
#
- cd build/rougier/freetype-gl
- sudo apt-get install libxmu-dev libxi-dev
script:
- make
- cmake . && make
......@@ -35,6 +35,7 @@ SET( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules"
"${CMAKE_MODULE_PATH}" )
OPTION(freetype-gl_BUILD_DEMOS "Build the freetype-gl example programs" ON)
OPTION(freetype-gl_LIBS_SUPPLIED "Required libraries are supplied as part of parent build" OFF)
# Get required and optional library
FIND_PACKAGE( OpenGL REQUIRED )
......@@ -45,7 +46,7 @@ IF( WIN32 OR WIN64 )
${CMAKE_CURRENT_SOURCE_DIR}/windows/glut )
SET( GLUT_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/windows/glut/glut32.lib )
SET( GLEW_INCLUDE_DIR
SET( GLEW_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/windows/glew/include )
SET( GLEW_LIBRARY
${CMAKE_CURRENT_SOURCE_DIR}/windows/glew/lib/glew32.lib )
......@@ -65,9 +66,20 @@ IF( WIN32 OR WIN64 )
${CMAKE_CURRENT_SOURCE_DIR}/windows/include )
SET( ANT_TWEAK_BAR_FOUND "YES" )
ELSE( WIN32 OR WIN64 )
FIND_PACKAGE( GLUT REQUIRED )
FIND_PACKAGE( Freetype REQUIRED )
FIND_PACKAGE( GLEW REQUIRED )
IF ( freetype-gl_LIBS_SUPPLIED )
FIND_PACKAGE( GLUT )
FIND_PACKAGE( Freetype )
IF ( NOT APPLE )
FIND_PACKAGE( GLEW )
ENDIF()
ELSE ( freetype-gl_LIBS_SUPPLIED )
FIND_PACKAGE( GLUT REQUIRED )
FIND_PACKAGE( Freetype REQUIRED )
IF ( NOT APPLE )
FIND_PACKAGE( GLEW )
ENDIF()
ENDIF ( freetype-gl_LIBS_SUPPLIED )
FIND_PACKAGE( FontConfig )
FIND_LIBRARY( MATH_LIBRARY m )
#FIND_LIBRARY( STDC_LIBRARY stdc++) #Buggy Cmake can't find libstdc++
......@@ -78,10 +90,9 @@ ENDIF( WIN32 OR WIN64 )
INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${VS789FIX_INCLUDE_DIR}
${GLEW_INCLUDE_DIR})
${GLEW_INCLUDE_PATH})
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
......@@ -108,12 +119,13 @@ LINK_DIRECTORIES(${PROJECT_SOURCE_DIR})
MACRO( DEMO _target _sources)
add_executable(${_target} ${_sources})
include_directories(${WINDOWS_DIR} ${GLUT_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} ${ANT_TWEAK_BAR_INCLUDE_PATH})
include_directories(${WINDOWS_DIR} ${GLUT_INCLUDE_DIR} ${GLEW_INCLUDE_PATH} ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2} ${ANT_TWEAK_BAR_INCLUDE_PATH})
if(NOT APPLE)
target_link_libraries(${_target} ${GLEW_LIBRARY})
endif()
target_link_libraries(${_target} freetype-gl)
target_link_libraries(${_target} ${OPENGL_LIBRARY})
target_link_libraries(${_target} ${GLUT_LIBRARY})
target_link_libraries(${_target} ${GLEW_LIBRARY})
target_link_libraries(${_target} ${FREETYPE_LIBRARY})
IF( MATH_LIBRARY )
target_link_libraries(${_target} ${MATH_LIBRARY})
......
# =========================================================================
# Freetype GL - A C OpenGL Freetype engine
# Platform: Any
# WWW: http://code.google.com/p/freetype-gl/
# -------------------------------------------------------------------------
# Copyright 2011,2012,2013 Nicolas P. Rougier. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of Nicolas P. Rougier.
# =========================================================================
PLATFORM = $(shell uname)
CC = gcc
CFLAGS = -Wno-deprecated-declarations -Wall `freetype-config --cflags` \
-I/usr/X11/include -O3 -I/opt/X11/include
LIBS = -lGLEW -lGL -lglut -lGLU -lm \
`freetype-config --libs`
ifeq ($(PLATFORM), Darwin)
LIBS = -framework OpenGL -framework GLUT -lGLEW -lm \
`freetype-config --libs` -L/usr/X11/lib -L/opt/X11/lib
endif
DEMOS := $(patsubst %.c,%,$(wildcard demo-*.c))
DEMOS_ATB := demo-atb-agg
DEMOS_MKP := demo-markup
DEMOS := $(filter-out $(DEMOS_ATB), $(DEMOS))
DEMOS := $(filter-out $(DEMOS_MKP), $(DEMOS))
TESTS := $(patsubst %.c,%,$(wildcard test-*.c))
HEADERS := $(wildcard *.h)
SOURCES := $(filter-out $(wildcard demo-*.c), $(wildcard *.c))
SOURCES := $(filter-out makefont.c, $(SOURCES))
OBJECTS := $(SOURCES:.c=.o)
.PHONY: all clean distclean
all: $(DEMOS) makefont demo-atb-agg demo-markup
demos: $(DEMOS)
tests: $(TESTS)
define DEMO_template
$(1): $(1).o $(OBJECTS) $(HEADERS)
@echo "Building $$@... "
@$(CC) $(OBJECTS) $(1).o $(LIBS) -o $$@
endef
$(foreach demo,$(DEMOS),$(eval $(call DEMO_template,$(demo))))
%.o : %.c
@echo "Building $@... "
@$(CC) -c $(CFLAGS) $< -o $@
demo-atb-agg: demo-atb-agg.o $(OBJECTS) $(HEADERS)
# fonts/Arial.ttf fonts/Tahoma.ttf fonts/Verdana.ttf fonts/Times.ttf fonts/Georgia.ttf
@echo "Building $@... "
@g++ $(OBJECTS) $@.o $(LIBS) -lAntTweakBar -o $@
demo-markup: demo-markup.o $(OBJECTS) $(HEADERS)
@echo "Building $@... "
@$(CC) $(OBJECTS) $@.o $(LIBS) -lfontconfig -o $@
makefont: makefont.o $(OBJECTS) $(HEADERS)
@echo "Building $@... "
@$(CC) $(OBJECTS) $@.o $(LIBS) -o $@
clean:
@-rm -f $(DEMOS) $(DEMOS_ATB) $(DEMOS_MKP) makefont *.o
@-rm -f $(TESTS) *.o
distclean: clean
@-rm -f *~
......@@ -78,3 +78,9 @@ Contributors:
* PJ O'Halloran (svn to git migration)
* William Light (Face creation from memory)
* Jan Niklas Hasse (Bug report & fix + README.md)
* Pierre-Emmnauel Lallemant (Bug report & fix)
* Robert Conde (Bug report & fix)
* Mikołaj Siedlarek (Build system bug fix)
* Preet Desai (Bug report & fix)
* Andy Staton (CMake fix and added namespace safeguard (avoiding glm collisions))
* Daniel Burke (Removed GLEW dependency and fix problems with font licences)
......@@ -34,6 +34,7 @@
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
typedef struct
......@@ -69,7 +70,7 @@ typedef struct
} texture_font_t;
texture_font_t font = {
128, 128, 1,
128, 128, 1,
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
......@@ -581,8 +582,8 @@ texture_font_t font = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
16.000000f, 18.400000f, 0.530000f, 14.480000f, -3.390000f, 96,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
16.000000f, 18.400000f, 0.530000f, 14.480000f, -3.390000f, 96,
{
{L'\0', 0, 0, 0, 0, 0.000000f, 0.000000f, 0.023438f, 0.023438f, 0.031250f, 0.031250f, 0, { } },
{L' ', 0, 0, 0, 0, 4.453125f, 0.000000f, 0.046875f, 0.007812f, 0.046875f, 0.007812f, 5, { {L'A', -0.882812f}, {L'L', -0.593750f}, {L'P', -0.289062f}, {L'T', -0.289062f}, {L'Y', -0.289062f}} },
......@@ -684,4 +685,5 @@ texture_font_t font = {
};
#ifdef __cplusplus
}
}
#endif
......@@ -310,6 +310,8 @@ int main( int argc, char **argv )
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -318,6 +320,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
buffer = text_buffer_new( LCD_FILTERING_OFF );
vec4 black = {{0.0, 0.0, 0.0, 1.0}};
......
......@@ -55,11 +55,11 @@
typedef enum {
VERA = 1,
VERA_MONO,
GEORGIA,
TIMES,
VERDANA,
TAHOMA,
ARIAL,
LUCKIEST_GUY,
SOURCE_SANS,
SOURCE_CODE,
OLD_STANDARD,
LOBSTER,
} font_family_e;
#define NUM_FONTS 7
......@@ -124,7 +124,7 @@ build_buffer( void )
}
markup_t markup = {
.family = "Arial",
.family = "Source Sans Pro",
.size = 10.0,
.bold = 0,
.italic = 0,
......@@ -154,25 +154,25 @@ build_buffer( void )
{
font = texture_font_new_from_file( atlas, p_size, "fonts/VeraMono.ttf" );
}
else if( p_family == GEORGIA)
else if( p_family == LUCKIEST_GUY)
{
font = texture_font_new_from_file( atlas, p_size, "fonts/Georgia.ttf" );
font = texture_font_new_from_file( atlas, p_size, "fonts/LuckiestGuy.ttf" );
}
else if( p_family == TIMES )
else if( p_family == SOURCE_SANS )
{
font = texture_font_new_from_file( atlas, p_size, "fonts/Times.ttf" );
font = texture_font_new_from_file( atlas, p_size, "fonts/SourceSansPro-Regular.ttf" );
}
else if( p_family == TAHOMA )
else if( p_family == SOURCE_CODE )
{
font = texture_font_new_from_file( atlas, p_size, "fonts/Tahoma.ttf" );
font = texture_font_new_from_file( atlas, p_size, "fonts/SourceCodePro-Regular.ttf" );
}
else if( p_family == ARIAL )
else if( p_family == OLD_STANDARD )
{
font = texture_font_new_from_file( atlas, p_size, "fonts/Arial.ttf" );
font = texture_font_new_from_file( atlas, p_size, "fonts/OldStandard-Regular.ttf" );
}
else if( p_family == VERDANA )
else if( p_family == LOBSTER )
{
font = texture_font_new_from_file( atlas, p_size, "fonts/Verdana.ttf" );
font = texture_font_new_from_file( atlas, p_size, "fonts/Lobster-Regular.ttf" );
}
else
{
......@@ -511,6 +511,7 @@ int main(int argc, char *argv[])
glutCreateWindow( "Font rendering advanced tweaking" );
glutCreateMenu( NULL );
#ifndef __APPLE__
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -519,7 +520,7 @@ int main(int argc, char *argv[])
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
glutDisplayFunc( display );
glutReshapeFunc( reshape );
......@@ -548,13 +549,13 @@ int main(int argc, char *argv[])
{
TwEnumVal familyEV[NUM_FONTS] = {
{VERA, "Vera"},
{VERA_MONO, "Vera Mono"},
{GEORGIA, "Georgia"},
{TIMES, "Times"},
{VERDANA, "Verdana"},
{TAHOMA, "Tahoma"},
{ARIAL, "Arial"} };
{VERA, "Vera"},
{VERA_MONO, "Vera Mono"},
{LUCKIEST_GUY, "Luckiest Guy"},
{SOURCE_SANS, "Source Sans Pro"},
{SOURCE_CODE, "Source Code Pro"},
{OLD_STANDARD, "Old Standard TT"},
{LOBSTER, "Lobster"} };
TwType family_type = TwDefineEnum("Family", familyEV, NUM_FONTS);
TwAddVarCB(bar, "Family", family_type, set_family, get_family, NULL,
"label = 'Family' "
......
......@@ -78,7 +78,7 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
texture_glyph_t *glyph = texture_font_get_glyph( font, text[i] );
if( glyph != NULL )
{
int kerning = 0;
float kerning = 0.0f;
if( i > 0)
{
kerning = texture_glyph_get_kerning( glyph, text[i-1] );
......@@ -217,7 +217,8 @@ int main( int argc, char **argv )
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
glutIdleFunc( idle );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -226,7 +227,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
atlas = texture_atlas_new( 512, 512, 1 );
font = texture_font_new_from_file( atlas, 12, "fonts/VeraMono.ttf" );
buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
......
......@@ -32,7 +32,9 @@
* ========================================================================= */
#include <stdio.h>
#include <wchar.h>
#include "freetype-gl.h"
#include "vertex-buffer.h"
#include "markup.h"
#include "shader.h"
......@@ -115,7 +117,7 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
for( i=0; i<wcslen(text); ++i )
{
texture_glyph_t *glyph = texture_font_get_glyph( font, text[i] );
float kerning = 0;
float kerning = 0.0f;
if( i > 0)
{
kerning = texture_glyph_get_kerning( glyph, text[i-1] );
......@@ -148,7 +150,7 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
// ------------------------------------------------------------------- main ---
int main( int argc, char **argv )
{
size_t width = 800, height = 200;
size_t width = 850, height = 200;
glutInit( &argc, argv );
glutInitWindowSize( width, height );
......@@ -157,7 +159,7 @@ int main( int argc, char **argv )
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -166,11 +168,11 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
atlas = texture_atlas_new( 1024, 1024, 1 );
buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
texture_font_t *font =
texture_font_new_from_file( atlas, 128, "fonts/ObelixPro.ttf" );
texture_font_new_from_file( atlas, 128, "fonts/LuckiestGuy.ttf" );
vec2 pen = {{50, 50}};
vec4 black = {{0.0, 0.0, 0.0, 1.0}};
......
......@@ -704,7 +704,8 @@ main( int argc, char **argv )
glutKeyboardFunc( on_key_press );
glutSpecialFunc( on_special_key_press );
glutReshapeWindow( 600,400 );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -713,7 +714,7 @@ main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
console = console_new();
console_print( console,
L"OpenGL Freetype console\n"
......
......@@ -149,7 +149,8 @@ int main( int argc, char **argv )
glutKeyboardFunc( keyboard );
//glutTimerFunc( 1000/60, timer, 1000/60 ); // not working on some systems (bug in GLUT)
glutIdleFunc(display);
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -158,7 +159,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
typedef struct { float x,y,z;} xyz;
typedef struct { float r,g,b,a;} rgba;
......
......@@ -52,10 +52,13 @@
#endif
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
// ------------------------------------------------------- typedef & struct ---
typedef struct {
......@@ -153,7 +156,7 @@ add_text( vertex_buffer_t * buffer, texture_font_t * font,
texture_glyph_t *glyph = texture_font_get_glyph( font, text[i] );
if( glyph != NULL )
{
int kerning = 0;
float kerning = 0.0f;
if( i > 0)
{
kerning = texture_glyph_get_kerning( glyph, text[i-1] );
......@@ -215,8 +218,8 @@ make_distance_map( unsigned char *img,
}
// Compute outside = edtaa3(bitmap); % Transform background (0's)
computegradient( data, height, width, gx, gy);
edtaa3(data, gx, gy, height, width, xdist, ydist, outside);
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, width, height, xdist, ydist, outside);
for( i=0; i<width*height; ++i)
if( outside[i] < 0 )
outside[i] = 0.0;
......@@ -226,8 +229,8 @@ make_distance_map( unsigned char *img,
memset(gy, 0, sizeof(double)*width*height );
for( i=0; i<width*height; ++i)
data[i] = 1 - data[i];
computegradient( data, height, width, gx, gy);
edtaa3(data, gx, gy, height, width, xdist, ydist, inside);
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, width, height, xdist, ydist, inside);
for( i=0; i<width*height; ++i)
if( inside[i] < 0 )
inside[i] = 0.0;
......@@ -268,7 +271,8 @@ main( int argc, char **argv )
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -277,7 +281,7 @@ main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
texture_font_t *font = 0;
texture_atlas_t *atlas = texture_atlas_new( 512, 512, 1 );
const char * filename = "fonts/Vera.ttf";
......
......@@ -37,6 +37,7 @@
#include "shader.h"
#include "texture-font.h"
#include "texture-atlas.h"
#include "platform.h"
#if defined(__APPLE__)
#include <Glut/glut.h>
......@@ -48,8 +49,13 @@
#include <GL/glut.h>
#endif
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
// ------------------------------------------------------- global variables ---
......@@ -71,7 +77,7 @@ distance_map( double *data, unsigned int width, unsigned int height )
int i;
// Compute outside = edtaa3(bitmap); % Transform background (0's)
computegradient( data, height, width, gx, gy);
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, width, height, xdist, ydist, outside);
for( i=0; i<width*height; ++i)
{
......@@ -86,7 +92,7 @@ distance_map( double *data, unsigned int width, unsigned int height )
memset( gy, 0, sizeof(double)*width*height );
for( i=0; i<width*height; ++i)
data[i] = 1 - data[i];
computegradient( data, height, width, gx, gy );
computegradient( data, width, height, gx, gy );
edtaa3( data, gx, gy, width, height, xdist, ydist, inside );
for( i=0; i<width*height; ++i )
{
......@@ -424,7 +430,8 @@ main( int argc, char **argv )
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
glutTimerFunc( 1000.0/60, timer, 60 );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -433,7 +440,7 @@ main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
program = shader_load( "shaders/distance-field.vert",
"shaders/distance-field-3.frag" );
glUseProgram( program );
......
......@@ -48,8 +48,13 @@
#include <GL/glut.h>
#endif
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
// ------------------------------------------------------- typedef & struct ---
......@@ -196,7 +201,7 @@ make_distance_map( unsigned char *img,
// Compute outside = edtaa3(bitmap); % Transform background (0's)
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, height, width, xdist, ydist, outside);
edtaa3(data, gx, gy, width, height, xdist, ydist, outside);
for( i=0; i<width*height; ++i)
if( outside[i] < 0 )
outside[i] = 0.0;
......@@ -207,7 +212,7 @@ make_distance_map( unsigned char *img,
for( i=0; i<width*height; ++i)
data[i] = 1 - data[i];
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, height, width, xdist, ydist, inside);
edtaa3(data, gx, gy, width, height, xdist, ydist, inside);
for( i=0; i<width*height; ++i)
if( inside[i] < 0 )
inside[i] = 0.0;
......@@ -250,7 +255,8 @@ main( int argc, char **argv )
glutMotionFunc( mouse_drag );
glutPassiveMotionFunc( mouse_motion );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -259,7 +265,7 @@ main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
unsigned char *map;
texture_font_t * font;
......
......@@ -119,7 +119,7 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
texture_glyph_t *glyph = texture_font_get_glyph( font, text[i] );
if( glyph != NULL )
{
int kerning = 0;
float kerning = 0.0f;
if( i > 0)
{
kerning = texture_glyph_get_kerning( glyph, text[i-1] );
......@@ -155,7 +155,8 @@ int main( int argc, char **argv )
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -164,7 +165,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
size_t i;
texture_font_t *font = 0;
texture_atlas_t *atlas = texture_atlas_new( 512, 512, 1 );
......
......@@ -128,7 +128,8 @@ int main( int argc, char **argv )
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -137,7 +138,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
buffer = text_buffer_new( LCD_FILTERING_OFF );
vec4 white = {{1.0, 1.0, 1.0, 1.0}};
vec4 black = {{0.0, 0.0, 0.0, 1.0}};
......
......@@ -146,7 +146,7 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
texture_glyph_t *glyph = texture_font_get_glyph( font, text[i] );
if( glyph != NULL )
{
int kerning = 0;
float kerning = 0.0f;
if( i > 0)
{
kerning = texture_glyph_get_kerning( glyph, text[i-1] );
......@@ -185,7 +185,8 @@ int main( int argc, char **argv )
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -194,7 +195,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );
}
fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) );
#endif
vec4 blue = {{0,0,1,1}};
vec4 black = {{0,0,0,1}};
......
......@@ -133,7 +133,7 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
texture_glyph_t *glyph = texture_font_get_glyph( font, text[i] );
if( glyph != NULL )
{
int kerning = 0;
float kerning = 0.0f;
if( i > 0)
{
kerning = texture_glyph_get_kerning( glyph, text[i-1] );
......@@ -172,7 +172,8 @@ int main( int argc, char **argv )
glutReshapeFunc( reshape );
glutDisplayFunc( display );
glutKeyboardFunc( keyboard );
#ifndef __APPLE__
glewExperimental = GL_TRUE;
GLenum err = glewInit();
if (GLEW_OK != err)
{
......@@ -181,7 +182,7 @@ int main( int argc, char **argv )
exit( EXIT_FAILURE );