Browse Source

Remove references to freetype

gh-pages
falkTX 11 years ago
parent
commit
304054af33
31 changed files with 0 additions and 184197 deletions
  1. +0
    -12
      dgl/Makefile
  2. +0
    -270
      dgl/src/freetype-gl/font-manager.c
  3. +0
    -205
      dgl/src/freetype-gl/font-manager.h
  4. +0
    -241
      dgl/src/freetype-gl/freetype-errors.h
  5. +0
    -44
      dgl/src/freetype-gl/freetype-gl.h
  6. +0
    -191
      dgl/src/freetype-gl/markup.h
  7. +0
    -263
      dgl/src/freetype-gl/mat4.c
  8. +0
    -117
      dgl/src/freetype-gl/mat4.h
  9. +0
    -37
      dgl/src/freetype-gl/opengl.h
  10. +0
    -71
      dgl/src/freetype-gl/platform.h
  11. +0
    -124
      dgl/src/freetype-gl/shader.c
  12. +0
    -119
      dgl/src/freetype-gl/shader.h
  13. +0
    -448
      dgl/src/freetype-gl/text-buffer.c
  14. +0
    -285
      dgl/src/freetype-gl/text-buffer.h
  15. +0
    -345
      dgl/src/freetype-gl/texture-atlas.c
  16. +0
    -225
      dgl/src/freetype-gl/texture-atlas.h
  17. +0
    -713
      dgl/src/freetype-gl/texture-font.c
  18. +0
    -451
      dgl/src/freetype-gl/texture-font.h
  19. +0
    -237
      dgl/src/freetype-gl/vec234.h
  20. +0
    -362
      dgl/src/freetype-gl/vector.c
  21. +0
    -353
      dgl/src/freetype-gl/vector.h
  22. +0
    -168
      dgl/src/freetype-gl/vertex-attribute.c
  23. +0
    -320
      dgl/src/freetype-gl/vertex-attribute.h
  24. +0
    -662
      dgl/src/freetype-gl/vertex-buffer.c
  25. +0
    -350
      dgl/src/freetype-gl/vertex-buffer.h
  26. +0
    -169
      dgl/src/freetype/FTL.TXT
  27. +0
    -166730
      dgl/src/freetype/FreeTypeAmalgam.c
  28. +0
    -10275
      dgl/src/freetype/FreeTypeAmalgam.h
  29. +0
    -340
      dgl/src/freetype/GPLv2.TXT
  30. +0
    -34
      dgl/src/freetype/LICENSE.TXT
  31. +0
    -36
      dgl/src/freetype/README.md

+ 0
- 12
dgl/Makefile View File

@@ -31,18 +31,6 @@ else
OBJS += src/Window.cpp.o OBJS += src/Window.cpp.o
endif endif


# freetype-gl
# OBJS += \
# src/freetype-gl/font-manager.c.o \
# src/freetype-gl/mat4.c.o \
# src/freetype-gl/shader.c.o \
# src/freetype-gl/text-buffer.c.o \
# src/freetype-gl/texture-atlas.c.o \
# src/freetype-gl/texture-font.c.o \
# src/freetype-gl/vector.c.o \
# src/freetype-gl/vertex-attribute.c.o \
# src/freetype-gl/vertex-buffer.c.o

TARGET = ../libdgl.a TARGET = ../libdgl.a


# -------------------------------------------------------------- # --------------------------------------------------------------


+ 0
- 270
dgl/src/freetype-gl/font-manager.c View File

@@ -1,270 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#if 0
# if !defined(_WIN32) && !defined(_WIN64)
# include <fontconfig/fontconfig.h>
# endif
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "font-manager.h"
// ------------------------------------------------------------ file_exists ---
int
file_exists( const char * filename )
{
FILE * file = fopen( filename, "r" );
if ( file )
{
fclose(file);
return 1;
}
return 0;
}
// ------------------------------------------------------- font_manager_new ---
font_manager_t *
font_manager_new( size_t width, size_t height, size_t depth )
{
font_manager_t *self;
texture_atlas_t *atlas = texture_atlas_new( width, height, depth );
self = (font_manager_t *) malloc( sizeof(font_manager_t) );
if( !self )
{
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__ );
exit( EXIT_FAILURE );
}
self->atlas = atlas;
self->fonts = vector_new( sizeof(texture_font_t *) );
self->cache = wcsdup( L" " );
return self;
}
// ---------------------------------------------------- font_manager_delete ---
void
font_manager_delete( font_manager_t * self )
{
size_t i;
texture_font_t *font;
assert( self );
for( i=0; i<vector_size( self->fonts ); ++i)
{
font = *(texture_font_t **) vector_get( self->fonts, i );
texture_font_delete( font );
}
vector_delete( self->fonts );
texture_atlas_delete( self->atlas );
if( self->cache )
{
free( self->cache );
}
free( self );
}
// ----------------------------------------------- font_manager_delete_font ---
void
font_manager_delete_font( font_manager_t * self,
texture_font_t * font)
{
size_t i;
texture_font_t *other;
assert( self );
assert( font );
for( i=0; i<self->fonts->size;++i )
{
other = (texture_font_t *) vector_get( self->fonts, i );
if ( (strcmp(font->filename, other->filename) == 0)
&& ( font->size == other->size) )
{
vector_erase( self->fonts, i);
break;
}
}
texture_font_delete( font );
}
// ----------------------------------------- font_manager_get_from_filename ---
texture_font_t *
font_manager_get_from_filename( font_manager_t *self,
const char * filename,
const float size )
{
size_t i;
texture_font_t *font;
assert( self );
for( i=0; i<vector_size(self->fonts); ++i )
{
font = * (texture_font_t **) vector_get( self->fonts, i );
if( (strcmp(font->filename, filename) == 0) && ( font->size == size) )
{
return font;
}
}
font = texture_font_new_from_file( self->atlas, size, filename );
if( font )
{
vector_push_back( self->fonts, &font );
texture_font_load_glyphs( font, self->cache );
return font;
}
fprintf( stderr, "Unable to load \"%s\" (size=%.1f)\n", filename, size );
return 0;
}
// ----------------------------------------- font_manager_get_from_description ---
texture_font_t *
font_manager_get_from_description( font_manager_t *self,
const char * family,
const float size,
const int bold,
const int italic )
{
texture_font_t *font;
char *filename = 0;
assert( self );
if( file_exists( family ) )
{
filename = strdup( family );
}
else
{
#if defined(_WIN32) || defined(_WIN64)
fprintf( stderr, "\"font_manager_get_from_description\" not implemented yet.\n" );
return 0;
#endif
filename = font_manager_match_description( self, family, size, bold, italic );
if( !filename )
{
fprintf( stderr, "No \"%s (size=%.1f, bold=%d, italic=%d)\" font available.\n",
family, size, bold, italic );
return 0;
}
}
font = font_manager_get_from_filename( self, filename, size );
free( filename );
return font;
}
// ------------------------------------------- font_manager_get_from_markup ---
texture_font_t *
font_manager_get_from_markup( font_manager_t *self,
const markup_t *markup )
{
assert( self );
assert( markup );
return font_manager_get_from_description( self, markup->family, markup->size,
markup->bold, markup->italic );
}
// ----------------------------------------- font_manager_match_description ---
char *
font_manager_match_description( font_manager_t * self,
const char * family,
const float size,
const int bold,
const int italic )
{
// Use of fontconfig is disabled by default.
#if 1
return 0;
#else
# if defined _WIN32 || defined _WIN64
fprintf( stderr, "\"font_manager_match_description\" not implemented for windows.\n" );
return 0;
# endif
char *filename = 0;
int weight = FC_WEIGHT_REGULAR;
int slant = FC_SLANT_ROMAN;
if ( bold )
{
weight = FC_WEIGHT_BOLD;
}
if( italic )
{
slant = FC_SLANT_ITALIC;
}
FcInit();
FcPattern *pattern = FcPatternCreate();
FcPatternAddDouble( pattern, FC_SIZE, size );
FcPatternAddInteger( pattern, FC_WEIGHT, weight );
FcPatternAddInteger( pattern, FC_SLANT, slant );
FcPatternAddString( pattern, FC_FAMILY, (FcChar8*) family );
FcConfigSubstitute( 0, pattern, FcMatchPattern );
FcDefaultSubstitute( pattern );
FcResult result;
FcPattern *match = FcFontMatch( 0, pattern, &result );
FcPatternDestroy( pattern );
if ( !match )
{
fprintf( stderr, "fontconfig error: could not match family '%s'", family );
return 0;
}
else
{
FcValue value;
FcResult result = FcPatternGet( match, FC_FILE, 0, &value );
if ( result )
{
fprintf( stderr, "fontconfig error: could not match family '%s'", family );
}
else
{
filename = strdup( (char *)(value.u.s) );
}
}
FcPatternDestroy( match );
return filename;
#endif
}

+ 0
- 205
dgl/src/freetype-gl/font-manager.h View File

@@ -1,205 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __FONT_MANAGER_H__
#define __FONT_MANAGER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "vector.h"
#include "markup.h"
#include "texture-font.h"
#include "texture-atlas.h"
/**
* @file font-manager.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup font-manager Font manager
*
* Structure in charge of caching fonts.
*
* <b>Example Usage</b>:
* @code
* #include "font-manager.h"
*
* int main( int arrgc, char *argv[] )
* {
* font_manager_t * manager = manager_new( 512, 512, 1 );
* texture_font_t * font = font_manager_get( manager, "Mono", 12, 0, 0 );
*
* return 0;
* }
* @endcode
*
* @{
*/
/**
* Structure in charge of caching fonts.
*/
typedef struct font_manager_t {
/**
* Texture atlas to hold font glyphs.
*/
texture_atlas_t * atlas;
/**
* Cached textures.
*/
vector_t * fonts;
/**
* Default glyphs to be loaded when loading a new font.
*/
wchar_t * cache;
} font_manager_t;
/**
* Creates a new empty font manager.
*
* @param width width of the underlying atlas
* @param height height of the underlying atlas
* @param depth bit depth of the underlying atlas
*
* @return a new font manager.
*
*/
font_manager_t *
font_manager_new( size_t width,
size_t height,
size_t depth );
/**
* Deletes a font manager.
*
* @param self a font manager.
*/
void
font_manager_delete( font_manager_t *self );
/**
* Deletes a font from the font manager.
*
* Note that font glyphs are not removed from the atlas.
*
* @param self a font manager.
* @param font font to be deleted
*
*/
void
font_manager_delete_font( font_manager_t * self,
texture_font_t * font );
/**
* Request for a font based on a filename.
*
* @param self a font manager.
* @param filename font filename
* @param size font size
*
* @return Requested font
*/
texture_font_t *
font_manager_get_from_filename( font_manager_t * self,
const char * filename,
const float size );
/**
* Request for a font based on a description
*
* @param self a font manager
* @param family font family
* @param size font size
* @param bold whether font is bold
* @param italic whether font is italic
*
* @return Requested font
*/
texture_font_t *
font_manager_get_from_description( font_manager_t * self,
const char * family,
const float size,
const int bold,
const int italic );
/**
* Request for a font based on a markup
*
* @param self a font manager
* @param markup Markup describing a font
*
* @return Requested font
*/
texture_font_t *
font_manager_get_from_markup( font_manager_t *self,
const markup_t *markup );
/**
* Search for a font filename that match description.
*
* @param self a font manager
* @param family font family
* @param size font size
* @param bold whether font is bold
* @param italic whether font is italic
*
* @return Requested font filename
*/
char *
font_manager_match_description( font_manager_t * self,
const char * family,
const float size,
const int bold,
const int italic );
/** @} */
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif /* __FONT_MANAGER_H__ */

+ 0
- 241
dgl/src/freetype-gl/freetype-errors.h View File

@@ -1,241 +0,0 @@

/* this macro is used to define an error */
#define FT_ERRORDEF_( e, v, s ) \
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )

/* this is only used for <module>_Err_Ok, which must be 0! */
#define FT_NOERRORDEF_( e, v, s ) \
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )

FT_ERROR_START_LIST

/*******************************************************************/
/*******************************************************************/
/***** *****/
/***** LIST OF ERROR CODES/MESSAGES *****/
/***** *****/
/*******************************************************************/
/*******************************************************************/

/* You need to define both FT_ERRORDEF_ and FT_NOERRORDEF_ before */
/* including this file. */

/* generic errors */

FT_NOERRORDEF_( Ok, 0x00, \
"no error" )

FT_ERRORDEF_( Cannot_Open_Resource, 0x01, \
"cannot open resource" )
FT_ERRORDEF_( Unknown_File_Format, 0x02, \
"unknown file format" )
FT_ERRORDEF_( Invalid_File_Format, 0x03, \
"broken file" )
FT_ERRORDEF_( Invalid_Version, 0x04, \
"invalid FreeType version" )
FT_ERRORDEF_( Lower_Module_Version, 0x05, \
"module version is too low" )
FT_ERRORDEF_( Invalid_Argument, 0x06, \
"invalid argument" )
FT_ERRORDEF_( Unimplemented_Feature, 0x07, \
"unimplemented feature" )
FT_ERRORDEF_( Invalid_Table, 0x08, \
"broken table" )
FT_ERRORDEF_( Invalid_Offset, 0x09, \
"broken offset within table" )
FT_ERRORDEF_( Array_Too_Large, 0x0A, \
"array allocation size too large" )
FT_ERRORDEF_( Missing_Module, 0x0B, \
"missing module" )
FT_ERRORDEF_( Missing_Property, 0x0C, \
"missing property" )

/* glyph/character errors */

FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, \
"invalid glyph index" )
FT_ERRORDEF_( Invalid_Character_Code, 0x11, \
"invalid character code" )
FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, \
"unsupported glyph image format" )
FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, \
"cannot render this glyph format" )
FT_ERRORDEF_( Invalid_Outline, 0x14, \
"invalid outline" )
FT_ERRORDEF_( Invalid_Composite, 0x15, \
"invalid composite glyph" )
FT_ERRORDEF_( Too_Many_Hints, 0x16, \
"too many hints" )
FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, \
"invalid pixel size" )

/* handle errors */

FT_ERRORDEF_( Invalid_Handle, 0x20, \
"invalid object handle" )
FT_ERRORDEF_( Invalid_Library_Handle, 0x21, \
"invalid library handle" )
FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, \
"invalid module handle" )
FT_ERRORDEF_( Invalid_Face_Handle, 0x23, \
"invalid face handle" )
FT_ERRORDEF_( Invalid_Size_Handle, 0x24, \
"invalid size handle" )
FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, \
"invalid glyph slot handle" )
FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, \
"invalid charmap handle" )
FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, \
"invalid cache manager handle" )
FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, \
"invalid stream handle" )

/* driver errors */

FT_ERRORDEF_( Too_Many_Drivers, 0x30, \
"too many modules" )
FT_ERRORDEF_( Too_Many_Extensions, 0x31, \
"too many extensions" )

/* memory errors */

FT_ERRORDEF_( Out_Of_Memory, 0x40, \
"out of memory" )
FT_ERRORDEF_( Unlisted_Object, 0x41, \
"unlisted object" )

/* stream errors */

FT_ERRORDEF_( Cannot_Open_Stream, 0x51, \
"cannot open stream" )
FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, \
"invalid stream seek" )
FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, \
"invalid stream skip" )
FT_ERRORDEF_( Invalid_Stream_Read, 0x54, \
"invalid stream read" )
FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, \
"invalid stream operation" )
FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, \
"invalid frame operation" )
FT_ERRORDEF_( Nested_Frame_Access, 0x57, \
"nested frame access" )
FT_ERRORDEF_( Invalid_Frame_Read, 0x58, \
"invalid frame read" )

/* raster errors */

FT_ERRORDEF_( Raster_Uninitialized, 0x60, \
"raster uninitialized" )
FT_ERRORDEF_( Raster_Corrupted, 0x61, \
"raster corrupted" )
FT_ERRORDEF_( Raster_Overflow, 0x62, \
"raster overflow" )
FT_ERRORDEF_( Raster_Negative_Height, 0x63, \
"negative height while rastering" )

/* cache errors */

FT_ERRORDEF_( Too_Many_Caches, 0x70, \
"too many registered caches" )

/* TrueType and SFNT errors */

FT_ERRORDEF_( Invalid_Opcode, 0x80, \
"invalid opcode" )
FT_ERRORDEF_( Too_Few_Arguments, 0x81, \
"too few arguments" )
FT_ERRORDEF_( Stack_Overflow, 0x82, \
"stack overflow" )
FT_ERRORDEF_( Code_Overflow, 0x83, \
"code overflow" )
FT_ERRORDEF_( Bad_Argument, 0x84, \
"bad argument" )
FT_ERRORDEF_( Divide_By_Zero, 0x85, \
"division by zero" )
FT_ERRORDEF_( Invalid_Reference, 0x86, \
"invalid reference" )
FT_ERRORDEF_( Debug_OpCode, 0x87, \
"found debug opcode" )
FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, \
"found ENDF opcode in execution stream" )
FT_ERRORDEF_( Nested_DEFS, 0x89, \
"nested DEFS" )
FT_ERRORDEF_( Invalid_CodeRange, 0x8A, \
"invalid code range" )
FT_ERRORDEF_( Execution_Too_Long, 0x8B, \
"execution context too long" )
FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, \
"too many function definitions" )
FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, \
"too many instruction definitions" )
FT_ERRORDEF_( Table_Missing, 0x8E, \
"SFNT font table missing" )
FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, \
"horizontal header (hhea) table missing" )
FT_ERRORDEF_( Locations_Missing, 0x90, \
"locations (loca) table missing" )
FT_ERRORDEF_( Name_Table_Missing, 0x91, \
"name table missing" )
FT_ERRORDEF_( CMap_Table_Missing, 0x92, \
"character map (cmap) table missing" )
FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, \
"horizontal metrics (hmtx) table missing" )
FT_ERRORDEF_( Post_Table_Missing, 0x94, \
"PostScript (post) table missing" )
FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, \
"invalid horizontal metrics" )
FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, \
"invalid character map (cmap) format" )
FT_ERRORDEF_( Invalid_PPem, 0x97, \
"invalid ppem value" )
FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, \
"invalid vertical metrics" )
FT_ERRORDEF_( Could_Not_Find_Context, 0x99, \
"could not find context" )
FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, \
"invalid PostScript (post) table format" )
FT_ERRORDEF_( Invalid_Post_Table, 0x9B, \
"invalid PostScript (post) table" )

/* CFF, CID, and Type 1 errors */

FT_ERRORDEF_( Syntax_Error, 0xA0, \
"opcode syntax error" )
FT_ERRORDEF_( Stack_Underflow, 0xA1, \
"argument stack underflow" )
FT_ERRORDEF_( Ignore, 0xA2, \
"ignore" )
FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, \
"no Unicode glyph name found" )
FT_ERRORDEF_( Glyph_Too_Big, 0xA4, \
"glyph to big for hinting" )

/* BDF errors */

FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, \
"`STARTFONT' field missing" )
FT_ERRORDEF_( Missing_Font_Field, 0xB1, \
"`FONT' field missing" )
FT_ERRORDEF_( Missing_Size_Field, 0xB2, \
"`SIZE' field missing" )
FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \
"`FONTBOUNDINGBOX' field missing" )
FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \
"`CHARS' field missing" )
FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \
"`STARTCHAR' field missing" )
FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \
"`ENCODING' field missing" )
FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \
"`BBX' field missing" )
FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \
"`BBX' too big" )
FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \
"Font header corrupted or missing fields" )
FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \
"Font glyphs corrupted or missing fields" )

/* END */

FT_ERROR_END_LIST

+ 0
- 44
dgl/src/freetype-gl/freetype-gl.h View File

@@ -1,44 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __FREETYPE_GL_H__
#define __FREETYPE_GL_H__

/* Mandatory */
#include "opengl.h"
#include "vec234.h"
#include "vector.h"
#include "texture-atlas.h"
#include "texture-font.h"

#endif /* FREETYPE_GL_H */

+ 0
- 191
dgl/src/freetype-gl/markup.h View File

@@ -1,191 +0,0 @@
/* =========================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* -------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ========================================================================= */
#ifndef __MARKUP_H__
#define __MARKUP_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "texture-font.h"
#include "vec234.h"
/**
* @file markup.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup markup Markup
*
* Simple structure that describes text properties.
*
* <b>Example Usage</b>:
* @code
* #include "markup.h"
*
* ...
*
* vec4 black = {{0.0, 0.0, 0.0, 1.0}};
* vec4 white = {{1.0, 1.0, 1.0, 1.0}};
* vec4 none = {{1.0, 1.0, 1.0, 0.0}};
*
* markup_t normal = {
* .family = "Droid Serif",
* .size = 24.0,
* .bold = 0,
* .italic = 0,
* .rise = 0.0,
* .spacing = 1.0,
* .gamma = 1.0,
* .foreground_color = black, .background_color = none,
* .underline = 0, .underline_color = black,
* .overline = 0, .overline_color = black,
* .strikethrough = 0, .strikethrough_color = black,
* .font = 0,
* };
*
* ...
*
* @endcode
*
* @{
*/
/**
* Simple structure that describes text properties.
*/
typedef struct markup_t
{
/**
* A font family name such as "normal", "sans", "serif" or "monospace".
*/
char * family;
/**
* Font size.
*/
float size;
/**
* Whether text is bold.
*/
int bold;
/**
* Whether text is italic.
*/
int italic;
/**
* Vertical displacement from the baseline.
*/
float rise;
/**
* Spacing between letters.
*/
float spacing;
/**
* Gamma correction.
*/
float gamma;
/**
* Text color.
*/
vec4 foreground_color;
/**
* Background color.
*/
vec4 background_color;
/**
* Whether outline is active.
*/
int outline;
/**
* Outline color.
*/
vec4 outline_color;
/**
* Whether underline is active.
*/
int underline;
/**
* Underline color.
*/
vec4 underline_color;
/**
* Whether overline is active.
*/
int overline;
/**
* Overline color.
*/
vec4 overline_color;
/**
* Whether strikethrough is active.
*/
int strikethrough;
/**
* Strikethrough color.
*/
vec4 strikethrough_color;
/**
* Pointer on the corresponding font (family/size/bold/italic)
*/
texture_font_t * font;
} markup_t;
extern markup_t default_markup;
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* __MARKUP_H__ */

+ 0
- 263
dgl/src/freetype-gl/mat4.c View File

@@ -1,263 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "mat4.h"

#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif

mat4 *
mat4_new( void )
{
mat4 *self = (mat4 *) malloc( sizeof(mat4) );
return self;

}

void
mat4_set_zero( mat4 *self )
{
assert( self );

memset( self, 0, sizeof( mat4 ));
}

void
mat4_set_identity( mat4 *self )
{
assert( self );

memset( self, 0, sizeof( mat4 ));
self->m00 = 1.0;
self->m11 = 1.0;
self->m22 = 1.0;
self->m33 = 1.0;
}

void
mat4_multiply( mat4 *self, mat4 *other )
{
mat4 m;
size_t i;

assert( self );
assert( other );

for( i=0; i<4; ++i )
{
m.data[i*4+0] =
(self->data[i*4+0] * other->data[0*4+0]) +
(self->data[i*4+1] * other->data[1*4+0]) +
(self->data[i*4+2] * other->data[2*4+0]) +
(self->data[i*4+3] * other->data[3*4+0]) ;

m.data[i*4+1] =
(self->data[i*4+0] * other->data[0*4+1]) +
(self->data[i*4+1] * other->data[1*4+1]) +
(self->data[i*4+2] * other->data[2*4+1]) +
(self->data[i*4+3] * other->data[3*4+1]) ;
m.data[i*4+2] =
(self->data[i*4+0] * other->data[0*4+2]) +
(self->data[i*4+1] * other->data[1*4+2]) +
(self->data[i*4+2] * other->data[2*4+2]) +
(self->data[i*4+3] * other->data[3*4+2]) ;
m.data[i*4+3] =
(self->data[i*4+0] * other->data[0*4+3]) +
(self->data[i*4+1] * other->data[1*4+3]) +
(self->data[i*4+2] * other->data[2*4+3]) +
(self->data[i*4+3] * other->data[3*4+3]) ;
}
memcpy( self, &m, sizeof( mat4 ) );

}


void
mat4_set_orthographic( mat4 *self,
float left, float right,
float bottom, float top,
float znear, float zfar )
{
assert( self );
assert( right != left );
assert( bottom != top );
assert( znear != zfar );

mat4_set_zero( self );

self->m00 = +2.0/(right-left);
self->m30 = -(right+left)/(right-left);
self->m11 = +2.0/(top-bottom);
self->m31 = -(top+bottom)/(top-bottom);
self->m22 = -2.0/(zfar-znear);
self->m32 = -(zfar+znear)/(zfar-znear);
self->m33 = 1.0;
}

void
mat4_set_perspective( mat4 *self,
float fovy, float aspect,
float znear, float zfar)
{
float h, w;
assert( self );
assert( znear != zfar );

h = tan(fovy / 360.0 * M_PI) * znear;
w = h * aspect;
mat4_set_frustum( self, -w, w, -h, h, znear, zfar );
}

void
mat4_set_frustum( mat4 *self,
float left, float right,
float bottom, float top,
float znear, float zfar )
{
assert( self );
assert( right != left );
assert( bottom != top );
assert( znear != zfar );

mat4_set_zero( self );

self->m00 = (2.0*znear)/(right-left);
self->m20 = (right+left)/(right-left);

self->m11 = (2.0*znear)/(top-bottom);
self->m21 = (top+bottom)/(top-bottom);

self->m22 = -(zfar+znear)/(zfar-znear);
self->m32 = -(2.0*zfar*znear)/(zfar-znear);

self->m23 = -1.0;
}

void
mat4_set_rotation( mat4 *self,
float angle,
float x, float y, float z)
{
float c, s, norm;
assert( self );

c = cos( M_PI*angle/180.0 );
s = sin( M_PI*angle/180.0 );
norm = sqrt(x*x+y*y+z*z);

x /= norm; y /= norm; z /= norm;

mat4_set_identity( self );

self->m00 = x*x*(1-c)+c;
self->m10 = y*x*(1-c)-z*s;
self->m20 = z*x*(1-c)+y*s;

self->m01 = x*y*(1-c)+z*s;
self->m11 = y*y*(1-c)+c;
self->m21 = z*y*(1-c)-x*s;

self->m02 = x*z*(1-c)-y*s;
self->m12 = y*z*(1-c)+x*s;
self->m22 = z*z*(1-c)+c;
}

void
mat4_set_translation( mat4 *self,
float x, float y, float z)
{
assert( self );

mat4_set_identity( self );
self-> m30 = x;
self-> m31 = y;
self-> m32 = z;
}

void
mat4_set_scaling( mat4 *self,
float x, float y, float z)
{
assert( self );

mat4_set_identity( self );
self-> m00 = x;
self-> m11 = y;
self-> m22 = z;
}

void
mat4_rotate( mat4 *self,
float angle,
float x, float y, float z)
{
mat4 m;
assert( self );

mat4_set_rotation( &m, angle, x, y, z);
mat4_multiply( self, &m );
}

void
mat4_translate( mat4 *self,
float x, float y, float z)
{
mat4 m;
assert( self );

mat4_set_translation( &m, x, y, z);
mat4_multiply( self, &m );
}

void
mat4_scale( mat4 *self,
float x, float y, float z)
{
mat4 m;
assert( self );

mat4_set_scaling( &m, x, y, z);
mat4_multiply( self, &m );
}

+ 0
- 117
dgl/src/freetype-gl/mat4.h View File

@@ -1,117 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __MAT4_H__
#define __MAT4_H__

#ifdef __cplusplus
extern "C" {
#endif


/**
*
*/
typedef union
{
float data[16]; /**< All compoments at once */
struct {
float m00, m01, m02, m03;
float m10, m11, m12, m13;
float m20, m21, m22, m23;
float m30, m31, m32, m33;
};
} mat4;


mat4 *
mat4_new( void );

void
mat4_set_identity( mat4 *self );

void
mat4_set_zero( mat4 *self );

void
mat4_multiply( mat4 *self, mat4 *other );

void
mat4_set_orthographic( mat4 *self,
float left, float right,
float bottom, float top,
float znear, float zfar );

void
mat4_set_perspective( mat4 *self,
float fovy, float aspect,
float zNear, float zFar);

void
mat4_set_frustum( mat4 *self,
float left, float right,
float bottom, float top,
float znear, float zfar );

void
mat4_set_rotation( mat4 *self,
float angle,
float x, float y, float z);

void
mat4_set_translation( mat4 *self,
float x, float y, float z);

void
mat4_set_scaling( mat4 *self,
float x, float y, float z);

void
mat4_rotate( mat4 *self,
float angle,
float x, float y, float z);

void
mat4_translate( mat4 *self,
float x, float y, float z);

void
mat4_scale( mat4 *self,
float x, float y, float z);


#ifdef __cplusplus
}
#endif

#endif /* __MAT4_H__ */

+ 0
- 37
dgl/src/freetype-gl/opengl.h View File

@@ -1,37 +0,0 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "../../../distrho/src/DistrhoDefines.h"

/* GL includes */
#ifdef DISTRHO_OS_MAC
# include <OpenGL/gl.h>
#else
# include <GL/gl.h>
#endif

/* missing GL defines */
#if defined(GL_BGR_EXT) && ! defined(GL_BGR)
# define GL_BGR GL_BGR_EXT
#endif

#if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
# define GL_BGRA GL_BGRA_EXT
#endif

#ifndef GL_CLAMP_TO_BORDER
# define GL_CLAMP_TO_BORDER 0x812D
#endif

+ 0
- 71
dgl/src/freetype-gl/platform.h View File

@@ -1,71 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#include <stdlib.h>
//-------------------------------------------------
// stdint.h is not available on VS2008 or lower
//-------------------------------------------------
#ifdef _MSC_VER
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif // _MSC_VER
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __APPLE__
/* strndup() was only added in OSX lion */
char * strndup( const char *s1, size_t n);
#elif defined(_WIN32) || defined(_WIN64)
/* does not exist on windows */
char * strndup( const char *s1, size_t n);
# if !defined(_MSC_VER) || _MSC_VER < 1800
double round(double v);
# endif // _MSC_VER
# pragma warning (disable: 4244) // suspend warnings
#endif // _WIN32 || _WIN64
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /* __PLATFORM_H__ */

+ 0
- 124
dgl/src/freetype-gl/shader.c View File

@@ -1,124 +0,0 @@
// ----------------------------------------------------------------------------
// OpenGL Anti-Grain Geometry (GL-AGG) - Version 0.1
// A high quality OpenGL rendering engine for C
// Copyright (C) 2012 Nicolas P. Rougier. All rights reserved.
// Contact: Nicolas.Rougier@gmail.com
// http://code.google.com/p/gl-agg/
//
// 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.
// ----------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "opengl.h"
#include "shader.h"


// ------------------------------------------------------------ shader_read ---
char *
shader_read( const char *filename )
{
FILE * file;
char * buffer;
size_t size;

file = fopen( filename, "rb" );
if( !file )
{
fprintf( stderr, "Unable to open file \"%s\".\n", filename );
return 0;
}
fseek( file, 0, SEEK_END );
size = ftell( file );
fseek(file, 0, SEEK_SET );
buffer = (char *) malloc( (size+1) * sizeof( char *) );
fread( buffer, sizeof(char), size, file );
buffer[size] = 0;
fclose( file );
return buffer;
}



// --------------------------------------------------------- shader_compile ---
GLuint
shader_compile( const char* source,
const GLenum type )
{
GLint compile_status;
GLuint handle = glCreateShader( type );
glShaderSource( handle, 1, &source, 0 );
glCompileShader( handle );

glGetShaderiv( handle, GL_COMPILE_STATUS, &compile_status );
if( compile_status == GL_FALSE )
{
GLchar messages[256];
glGetShaderInfoLog( handle, sizeof(messages), 0, &messages[0] );
fprintf( stderr, "%s\n", messages );
exit( EXIT_FAILURE );
}
return handle;
}


// ------------------------------------------------------------ shader_load ---
GLuint
shader_load( const char * vert_filename,
const char * frag_filename )
{
GLuint handle = glCreateProgram( );
GLint link_status;

if( vert_filename && strlen( vert_filename ) )
{
char *vert_source = shader_read( vert_filename );
GLuint vert_shader = shader_compile( vert_source, GL_VERTEX_SHADER);
glAttachShader( handle, vert_shader);
glDeleteShader( vert_shader );
free( vert_source );
}
if( frag_filename && strlen( frag_filename ) )
{
char *frag_source = shader_read( frag_filename );
GLuint frag_shader = shader_compile( frag_source, GL_FRAGMENT_SHADER);
glAttachShader( handle, frag_shader);
glDeleteShader( frag_shader );
free( frag_source );
}

glLinkProgram( handle );

glGetProgramiv( handle, GL_LINK_STATUS, &link_status );
if (link_status == GL_FALSE)
{
GLchar messages[256];
glGetProgramInfoLog( handle, sizeof(messages), 0, &messages[0] );
fprintf( stderr, "%s\n", messages );
exit(1);
}
return handle;
}

+ 0
- 119
dgl/src/freetype-gl/shader.h View File

@@ -1,119 +0,0 @@
/* ============================================================================
* 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.
* ----------------------------------------------------------------------------
*/
#ifndef __SHADER_H__
#define __SHADER_H__

#include "opengl.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @file shader.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup shader Shader
*
* Simple functions for loading/building a shader from sources.
*
* <b>Example Usage</b>:
* @code
* #include "shader.h"
*
* int main( int arrgc, char *argv[] )
* {
* GLuint shader = shader_load("shader.vert", "shader.frag");
*
* return 0;
* }
* @endcode
*
* @{
*/

/**
* Read a fragment or vertex shader from a file
*
* @param filename file to read shader from
* @return a newly-allocated text buffer containing code. This buffer
* must be freed after usage.
*
*/
char *
shader_read( const char *filename );


/**
* Compile a shader from a text buffer.
*
* @param source code of the shader
* @param type type of the shader
*
* @return a handle on the compiled program
*
*/
GLuint
shader_compile( const char* source,
const GLenum type );


/**
* Load a vertex and fragment shader sources and build program
*
* @param vert_filename vertex shader filename
* @param frag_filename fragment shader filename
*
* @return a handle on the built program
*
*/
GLuint
shader_load( const char * vert_filename,
const char * frag_filename );


/**
*
*/
GLuint
shader_get( GLuint self,
const char * name );

/** @} */

#ifdef __cplusplus
}
#endif

#endif /* __SHADER_H__ */

+ 0
- 448
dgl/src/freetype-gl/text-buffer.c View File

@@ -1,448 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include "opengl.h"
#include "text-buffer.h"


#define SET_GLYPH_VERTEX(value,x0,y0,z0,s0,t0,r,g,b,a,sh,gm) { \
glyph_vertex_t *gv=&value; \
gv->x=x0; gv->y=y0; gv->z=z0; \
gv->u=s0; gv->v=t0; \
gv->r=r; gv->g=g; gv->b=b; gv->a=a; \
gv->shift=sh; gv->gamma=gm;}


// ----------------------------------------------------------------------------
text_buffer_t *
text_buffer_new( size_t depth )
{
text_buffer_t *self = (text_buffer_t *) malloc (sizeof(text_buffer_t));
self->buffer = vertex_buffer_new(
"vertex:3f,tex_coord:2f,color:4f,ashift:1f,agamma:1f" );
self->manager = font_manager_new( 512, 512, depth );
self->shader = shader_load("shaders/text.vert",
"shaders/text.frag");
self->shader_texture = glGetUniformLocation(self->shader, "texture");
self->shader_pixel = glGetUniformLocation(self->shader, "pixel");
self->line_start = 0;
self->line_ascender = 0;
self->base_color.r = 0.0;
self->base_color.g = 0.0;
self->base_color.b = 0.0;
self->base_color.a = 1.0;
self->line_descender = 0;
return self;
}

// ----------------------------------------------------------------------------
void
text_buffer_delete( text_buffer_t * self )
{
vertex_buffer_delete( self->buffer );
glDeleteProgram( self->shader );
free( self );
}

// ----------------------------------------------------------------------------
void
text_buffer_clear( text_buffer_t * self )
{
assert( self );

vertex_buffer_clear( self->buffer );
self->line_start = 0;
self->line_ascender = 0;
self->line_descender = 0;
}


// ----------------------------------------------------------------------------
void
text_buffer_render( text_buffer_t * self )
{
glEnable( GL_BLEND );

glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, self->manager->atlas->id );

if( self->manager->atlas->depth == 1 )
{
//glDisable( GL_COLOR_MATERIAL );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glBlendColor( 1, 1, 1, 1 );
}
else
{
//glEnable( GL_COLOR_MATERIAL );
//glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
//glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
//glBlendColor( 1.0, 1.0, 1.0, 1.0 );
//glBlendFunc( GL_CONSTANT_COLOR_EXT, GL_ONE_MINUS_SRC_COLOR );
//glBlendColor( self->base_color.r,
//self->base_color.g,
//self->base_color.b,
//self->base_color.a );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glBlendColor( 1, 1, 1, 1 );
}

glUseProgram( self->shader );
glUniform1i( self->shader_texture, 0 );
glUniform3f( self->shader_pixel,
1.0/self->manager->atlas->width,
1.0/self->manager->atlas->height,
self->manager->atlas->depth );
vertex_buffer_render( self->buffer, GL_TRIANGLES );
glUseProgram( 0 );
}

// ----------------------------------------------------------------------------
void
text_buffer_printf( text_buffer_t * self, vec2 *pen, ... )
{
markup_t *markup;
wchar_t *text;
va_list args;

if( vertex_buffer_size( self->buffer ) == 0 )
{
self->origin = *pen;
}

va_start ( args, pen );
do {
markup = va_arg( args, markup_t * );
if( markup == NULL )
{
return;
}
text = va_arg( args, wchar_t * );
text_buffer_add_text( self, pen, markup, text, wcslen(text) );
} while( markup != 0 );
va_end ( args );
}

// ----------------------------------------------------------------------------
void
text_buffer_move_last_line( text_buffer_t * self, float dy )
{
size_t i, j;
for( i=self->line_start; i < vector_size( self->buffer->items ); ++i )
{
ivec4 *item = (ivec4 *) vector_get( self->buffer->items, i);
for( j=item->vstart; j<item->vstart+item->vcount; ++j)
{
glyph_vertex_t * vertex =
(glyph_vertex_t *) vector_get( self->buffer->vertices, j );
vertex->y -= dy;
}
}
}


// ----------------------------------------------------------------------------
void
text_buffer_add_text( text_buffer_t * self,
vec2 * pen, markup_t * markup,
wchar_t * text, size_t length )
{
font_manager_t * manager = self->manager;
size_t i;

if( markup == NULL )
{
return;
}

if( !markup->font )
{
markup->font = font_manager_get_from_markup( manager, markup );
if( ! markup->font )
{
fprintf( stderr, "Houston, we've got a problem !\n" );
exit( EXIT_FAILURE );
}
}

if( length == 0 )
{
length = wcslen(text);
}
if( vertex_buffer_size( self->buffer ) == 0 )
{
self->origin = *pen;
}

text_buffer_add_wchar( self, pen, markup, text[0], 0 );
for( i=1; i<length; ++i )
{
text_buffer_add_wchar( self, pen, markup, text[i], text[i-1] );
}
}

// ----------------------------------------------------------------------------
void
text_buffer_add_wchar( text_buffer_t * self,
vec2 * pen, markup_t * markup,
wchar_t current, wchar_t previous )
{
size_t vcount = 0;
size_t icount = 0;
vertex_buffer_t * buffer = self->buffer;
texture_font_t * font = markup->font;
float gamma = markup->gamma;

// Maximum number of vertices is 20 (= 5x2 triangles) per glyph:
// - 2 triangles for background
// - 2 triangles for overline
// - 2 triangles for underline
// - 2 triangles for strikethrough
// - 2 triangles for glyph
glyph_vertex_t vertices[4*5];
GLuint indices[6*5];
texture_glyph_t *glyph;
texture_glyph_t *black;
float kerning = 0;
if( current == L'\n' )
{
pen->x = self->origin.x;
pen->y += self->line_descender;
self->line_descender = 0;
self->line_ascender = 0;
self->line_start = vector_size( self->buffer->items );
return;
}

if( markup->font->ascender > self->line_ascender )
{
float y = pen->y;
pen->y -= (markup->font->ascender - self->line_ascender);
text_buffer_move_last_line( self, (int)(y-pen->y) );
self->line_ascender = markup->font->ascender;
}
if( markup->font->descender < self->line_descender )
{
self->line_descender = markup->font->descender;
}

glyph = texture_font_get_glyph( font, current );
black = texture_font_get_glyph( font, -1 );
if( glyph == NULL )
{
return;
}
if( previous && markup->font->kerning )
{
kerning = texture_glyph_get_kerning( glyph, previous );
}
pen->x += kerning;
// Background
if( markup->background_color.alpha > 0 )
{
float r = markup->background_color.r;
float g = markup->background_color.g;
float b = markup->background_color.b;
float a = markup->background_color.a;
float x0 = ( pen->x -kerning );
float y0 = (int)( pen->y + font->descender );
float x1 = ( x0 + glyph->advance_x );
float y1 = (int)( y0 + font->height + font->linegap );
float s0 = black->s0;
float t0 = black->t0;
float s1 = black->s1;
float t1 = black->t1;

SET_GLYPH_VERTEX(vertices[vcount+0],
(int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+1],
(int)x0,y1,0, s0,t1, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+2],
(int)x1,y1,0, s1,t1, r,g,b,a, x1-((int)x1), gamma );
SET_GLYPH_VERTEX(vertices[vcount+3],
(int)x1,y0,0, s1,t0, r,g,b,a, x1-((int)x1), gamma );
indices[icount + 0] = vcount+0;
indices[icount + 1] = vcount+1;
indices[icount + 2] = vcount+2;
indices[icount + 3] = vcount+0;
indices[icount + 4] = vcount+2;
indices[icount + 5] = vcount+3;
vcount += 4;
icount += 6;
}
// Underline
if( markup->underline )
{
float r = markup->underline_color.r;
float g = markup->underline_color.g;
float b = markup->underline_color.b;
float a = markup->underline_color.a;
float x0 = ( pen->x - kerning );
float y0 = (int)( pen->y + font->underline_position );
float x1 = ( x0 + glyph->advance_x );
float y1 = (int)( y0 + font->underline_thickness );
float s0 = black->s0;
float t0 = black->t0;
float s1 = black->s1;
float t1 = black->t1;

SET_GLYPH_VERTEX(vertices[vcount+0],
(int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+1],
(int)x0,y1,0, s0,t1, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+2],
(int)x1,y1,0, s1,t1, r,g,b,a, x1-((int)x1), gamma );
SET_GLYPH_VERTEX(vertices[vcount+3],
(int)x1,y0,0, s1,t0, r,g,b,a, x1-((int)x1), gamma );
indices[icount + 0] = vcount+0;
indices[icount + 1] = vcount+1;
indices[icount + 2] = vcount+2;
indices[icount + 3] = vcount+0;
indices[icount + 4] = vcount+2;
indices[icount + 5] = vcount+3;
vcount += 4;
icount += 6;
}
// Overline
if( markup->overline )
{
float r = markup->overline_color.r;
float g = markup->overline_color.g;
float b = markup->overline_color.b;
float a = markup->overline_color.a;
float x0 = ( pen->x -kerning );
float y0 = (int)( pen->y + (int)font->ascender );
float x1 = ( x0 + glyph->advance_x );
float y1 = (int)( y0 + (int)font->underline_thickness );
float s0 = black->s0;
float t0 = black->t0;
float s1 = black->s1;
float t1 = black->t1;
SET_GLYPH_VERTEX(vertices[vcount+0],
(int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+1],
(int)x0,y1,0, s0,t1, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+2],
(int)x1,y1,0, s1,t1, r,g,b,a, x1-((int)x1), gamma );
SET_GLYPH_VERTEX(vertices[vcount+3],
(int)x1,y0,0, s1,t0, r,g,b,a, x1-((int)x1), gamma );
indices[icount + 0] = vcount+0;
indices[icount + 1] = vcount+1;
indices[icount + 2] = vcount+2;
indices[icount + 3] = vcount+0;
indices[icount + 4] = vcount+2;
indices[icount + 5] = vcount+3;
vcount += 4;
icount += 6;
}
/* Strikethrough */
if( markup->strikethrough )
{
float r = markup->strikethrough_color.r;
float g = markup->strikethrough_color.g;
float b = markup->strikethrough_color.b;
float a = markup->strikethrough_color.a;
float x0 = ( pen->x -kerning );
float y0 = (int)( pen->y + (int)font->ascender*.33);
float x1 = ( x0 + glyph->advance_x );
float y1 = (int)( y0 + (int)font->underline_thickness );
float s0 = black->s0;
float t0 = black->t0;
float s1 = black->s1;
float t1 = black->t1;
SET_GLYPH_VERTEX(vertices[vcount+0],
(int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+1],
(int)x0,y1,0, s0,t1, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+2],
(int)x1,y1,0, s1,t1, r,g,b,a, x1-((int)x1), gamma );
SET_GLYPH_VERTEX(vertices[vcount+3],
(int)x1,y0,0, s1,t0, r,g,b,a, x1-((int)x1), gamma );
indices[icount + 0] = vcount+0;
indices[icount + 1] = vcount+1;
indices[icount + 2] = vcount+2;
indices[icount + 3] = vcount+0;
indices[icount + 4] = vcount+2;
indices[icount + 5] = vcount+3;
vcount += 4;
icount += 6;
}
{
// Actual glyph
float r = markup->foreground_color.red;
float g = markup->foreground_color.green;
float b = markup->foreground_color.blue;
float a = markup->foreground_color.alpha;
float x0 = ( pen->x + glyph->offset_x );
float y0 = (int)( pen->y + glyph->offset_y );
float x1 = ( x0 + glyph->width );
float y1 = (int)( y0 - glyph->height );
float s0 = glyph->s0;
float t0 = glyph->t0;
float s1 = glyph->s1;
float t1 = glyph->t1;

SET_GLYPH_VERTEX(vertices[vcount+0],
(int)x0,y0,0, s0,t0, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+1],
(int)x0,y1,0, s0,t1, r,g,b,a, x0-((int)x0), gamma );
SET_GLYPH_VERTEX(vertices[vcount+2],
(int)x1,y1,0, s1,t1, r,g,b,a, x1-((int)x1), gamma );
SET_GLYPH_VERTEX(vertices[vcount+3],
(int)x1,y0,0, s1,t0, r,g,b,a, x1-((int)x1), gamma );
indices[icount + 0] = vcount+0;
indices[icount + 1] = vcount+1;
indices[icount + 2] = vcount+2;
indices[icount + 3] = vcount+0;
indices[icount + 4] = vcount+2;
indices[icount + 5] = vcount+3;
vcount += 4;
icount += 6;
vertex_buffer_push_back( buffer, vertices, vcount, indices, icount );
pen->x += glyph->advance_x * (1.0 + markup->spacing);
}
}

+ 0
- 285
dgl/src/freetype-gl/text-buffer.h View File

@@ -1,285 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __TEXT_BUFFER_H__
#define __TEXT_BUFFER_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "vertex-buffer.h"
#include "font-manager.h"
#include "markup.h"
#include "shader.h"


/**
* Use LCD filtering
*/
#define LCD_FILTERING_ON 3

/**
* Do not use LCD filtering
*/
#define LCD_FILTERING_OFF 1

/**
* @file text-buffer.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup text-buffer Text buffer
*
*
* <b>Example Usage</b>:
* @code
* #include "shader.h"
*
* int main( int arrgc, char *argv[] )
* {
*
* return 0;
* }
* @endcode
*
* @{
*/

/**
* Text buffer structure
*/
typedef struct text_buffer_t {
/**
* Vertex buffer
*/
vertex_buffer_t *buffer;

/**
* Font manager
*/
font_manager_t *manager;

/**
* Base color for text
*/
vec4 base_color;


/**
* Pen origin
*/
vec2 origin;

/**
* Index (in the vertex buffer) of the line start
*/
size_t line_start;

/**
* Current line ascender
*/
float line_ascender;

/**
* Current line decender
*/
float line_descender;

/**
* Shader handler
*/
GLuint shader;

/**
* Shader "texture" location
*/
GLuint shader_texture;

/**
* Shader "pixel" location
*/
GLuint shader_pixel;

} text_buffer_t;



/**
* Glyph vertex structure
*/
typedef struct glyph_vertex_t {
/**
* Vertex x coordinates
*/
float x;

/**
* Vertex y coordinates
*/
float y;

/**
* Vertex z coordinates
*/
float z;

/**
* Texture first coordinate
*/
float u;

/**
* Texture second coordinate
*/
float v;

/**
* Color red component
*/
float r;

/**
* Color green component
*/
float g;

/**
* Color blue component
*/
float b;

/**
* Color alpha component
*/
float a;

/**
* Shift along x
*/
float shift;

/**
* Color gamma correction
*/
float gamma;

} glyph_vertex_t;



/**
* Creates a new empty text buffer.
*
* @param depth Underlying atlas bit depth (1 or 3)
*
* @return a new empty text buffer.
*
*/
text_buffer_t *
text_buffer_new( size_t depth );

/**
* Deletes texture buffer and its associated shader and vertex buffer.
*
* @param self texture buffer to delete
*
*/
void
text_buffer_delete( text_buffer_t * self );

/**
* Render a text buffer.
*
* @param self a text buffer
*
*/
void
text_buffer_render( text_buffer_t * self );


/**
* Print some text to the text buffer
*
* @param self a text buffer
* @param pen position of text start
* @param ... a series of markup_t *, wchar_t * ended by NULL
*
*/
void
text_buffer_printf( text_buffer_t * self, vec2 * pen, ... );


/**
* Add some text to the text buffer
*
* @param self a text buffer
* @param pen position of text start
* @param markup Markup to be used to add text
* @param text Text to be added
* @param length Length of text to be added
*/
void
text_buffer_add_text( text_buffer_t * self,
vec2 * pen, markup_t * markup,
wchar_t * text, size_t length );

/**
* Add a char to the text buffer
*
* @param self a text buffer
* @param pen position of text start
* @param markup markup to be used to add text
* @param current charactr to be added
* @param previous previous character (if any)
*/
void
text_buffer_add_wchar( text_buffer_t * self,
vec2 * pen, markup_t * markup,
wchar_t current, wchar_t previous );

/**
* Clear text buffer
*
* @param self a text buffer
*/
void
text_buffer_clear( text_buffer_t * self );


/** @} */

#ifdef __cplusplus
}
#endif

#endif /* #define __TEXT_BUFFER_H__ */

+ 0
- 345
dgl/src/freetype-gl/texture-atlas.c View File

@@ -1,345 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include "opengl.h"
#include "texture-atlas.h"
// ------------------------------------------------------ texture_atlas_new ---
texture_atlas_t *
texture_atlas_new( const size_t width,
const size_t height,
const size_t depth )
{
texture_atlas_t *self = (texture_atlas_t *) malloc( sizeof(texture_atlas_t) );
// We want a one pixel border around the whole atlas to avoid any artefact when
// sampling texture
ivec3 node = {{1,1,width-2}};
assert( (depth == 1) || (depth == 3) || (depth == 4) );
if( self == NULL)
{
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__ );
exit( EXIT_FAILURE );
}
self->nodes = vector_new( sizeof(ivec3) );
self->used = 0;
self->width = width;
self->height = height;
self->depth = depth;
self->id = 0;
vector_push_back( self->nodes, &node );
self->data = (unsigned char *)
calloc( width*height*depth, sizeof(unsigned char) );
if( self->data == NULL)
{
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__ );
exit( EXIT_FAILURE );
}
return self;
}
// --------------------------------------------------- texture_atlas_delete ---
void
texture_atlas_delete( texture_atlas_t *self )
{
assert( self );
vector_delete( self->nodes );
if( self->data )
{
free( self->data );
}
if( self->id )
{
glDeleteTextures( 1, &self->id );
}
free( self );
}
// ----------------------------------------------- texture_atlas_set_region ---
void
texture_atlas_set_region( texture_atlas_t * self,
const size_t x,
const size_t y,
const size_t width,
const size_t height,
const unsigned char * data,
const size_t stride )
{
size_t i;
size_t depth;
size_t charsize;
assert( self );
assert( x > 0);
assert( y > 0);
assert( x < (self->width-1));
assert( (x + width) <= (self->width-1));
assert( y < (self->height-1));
assert( (y + height) <= (self->height-1));
depth = self->depth;
charsize = sizeof(char);
for( i=0; i<height; ++i )
{
memcpy( self->data+((y+i)*self->width + x ) * charsize * depth,
data + (i*stride) * charsize, width * charsize * depth );
}
}
// ------------------------------------------------------ texture_atlas_fit ---
int
texture_atlas_fit( texture_atlas_t * self,
const size_t index,
const size_t width,
const size_t height )
{
ivec3 *node;
int x, y, width_left;
size_t i;
assert( self );
node = (ivec3 *) (vector_get( self->nodes, index ));
x = node->x;
y = node->y;
width_left = width;
i = index;
if ( (x + width) > (self->width-1) )
{
return -1;
}
y = node->y;
while( width_left > 0 )
{
node = (ivec3 *) (vector_get( self->nodes, i ));
if( node->y > y )
{
y = node->y;
}
if( (y + height) > (self->height-1) )
{
return -1;
}
width_left -= node->z;
++i;
}
return y;
}
// ---------------------------------------------------- texture_atlas_merge ---
void
texture_atlas_merge( texture_atlas_t * self )
{
ivec3 *node, *next;
size_t i;
assert( self );
for( i=0; i< self->nodes->size-1; ++i )
{
node = (ivec3 *) (vector_get( self->nodes, i ));
next = (ivec3 *) (vector_get( self->nodes, i+1 ));
if( node->y == next->y )
{
node->z += next->z;
vector_erase( self->nodes, i+1 );
--i;
}
}
}
// ----------------------------------------------- texture_atlas_get_region ---
ivec4
texture_atlas_get_region( texture_atlas_t * self,
const size_t width,
const size_t height )
{
int y, best_height, best_width, best_index;
ivec3 *node, *prev;
ivec4 region = {{0,0,width,height}};
size_t i;
assert( self );
best_height = INT_MAX;
best_index = -1;
best_width = INT_MAX;
for( i=0; i<self->nodes->size; ++i )
{
y = texture_atlas_fit( self, i, width, height );
if( y >= 0 )
{
node = (ivec3 *) vector_get( self->nodes, i );
if( ( (y + height) < best_height ) ||
( ((y + height) == best_height) && (node->z < best_width)) )
{
best_height = y + height;
best_index = i;
best_width = node->z;
region.x = node->x;
region.y = y;
}
}
}
if( best_index == -1 )
{
region.x = -1;
region.y = -1;
region.width = 0;
region.height = 0;
return region;
}
node = (ivec3 *) malloc( sizeof(ivec3) );
if( node == NULL)
{
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__ );
exit( EXIT_FAILURE );
}
node->x = region.x;
node->y = region.y + height;
node->z = width;
vector_insert( self->nodes, best_index, node );
free( node );
for(i = best_index+1; i < self->nodes->size; ++i)
{
node = (ivec3 *) vector_get( self->nodes, i );
prev = (ivec3 *) vector_get( self->nodes, i-1 );
if (node->x < (prev->x + prev->z) )
{
int shrink = prev->x + prev->z - node->x;
node->x += shrink;
node->z -= shrink;
if (node->z <= 0)
{
vector_erase( self->nodes, i );
--i;
}
else
{
break;
}
}
else
{
break;
}
}
texture_atlas_merge( self );
self->used += width * height;
return region;
}
// ---------------------------------------------------- texture_atlas_clear ---
void
texture_atlas_clear( texture_atlas_t * self )
{
ivec3 node = {{1,1,1}};
assert( self );
assert( self->data );
vector_clear( self->nodes );
self->used = 0;
// We want a one pixel border around the whole atlas to avoid any artefact when
// sampling texture
node.z = self->width-2;
vector_push_back( self->nodes, &node );
memset( self->data, 0, self->width*self->height*self->depth );
}
// --------------------------------------------------- texture_atlas_upload ---
void
texture_atlas_upload( texture_atlas_t * self )
{
assert( self );
assert( self->data );
if( !self->id )
{
glGenTextures( 1, &self->id );
}
glBindTexture( GL_TEXTURE_2D, self->id );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
if( self->depth == 4 )
{
#ifdef GL_UNSIGNED_INT_8_8_8_8_REV
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, self->width, self->height,
0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, self->data );
#else
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, self->width, self->height,
0, GL_RGBA, GL_UNSIGNED_BYTE, self->data );
#endif
}
else if( self->depth == 3 )
{
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, self->width, self->height,
0, GL_RGB, GL_UNSIGNED_BYTE, self->data );
}
else
{
glTexImage2D( GL_TEXTURE_2D, 0, GL_RED, self->width, self->height,
0, GL_RED, GL_UNSIGNED_BYTE, self->data );
}
}

+ 0
- 225
dgl/src/freetype-gl/texture-atlas.h View File

@@ -1,225 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*
* This source is based on the article by Jukka Jylänki :
* "A Thousand Ways to Pack the Bin - A Practical Approach to
* Two-Dimensional Rectangle Bin Packing", February 27, 2010.
*
* More precisely, this is an implementation of the Skyline Bottom-Left
* algorithm based on C++ sources provided by Jukka Jylänki at:
* http://clb.demon.fi/files/RectangleBinPack/
*
* ============================================================================
*/
#ifndef __TEXTURE_ATLAS_H__
#define __TEXTURE_ATLAS_H__
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "vector.h"
#include "vec234.h"
/**
* @file texture-atlas.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup texture-atlas Texture atlas
*
* A texture atlas is used to pack several small regions into a single texture.
*
* The actual implementation is based on the article by Jukka Jylänki : "A
* Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional
* Rectangle Bin Packing", February 27, 2010.
* More precisely, this is an implementation of the Skyline Bottom-Left
* algorithm based on C++ sources provided by Jukka Jylänki at:
* http://clb.demon.fi/files/RectangleBinPack/
*
*
* Example Usage:
* @code
* #include "texture-atlas.h"
*
* ...
*
* / Creates a new atlas of 512x512 with a depth of 1
* texture_atlas_t * atlas = texture_atlas_new( 512, 512, 1 );
*
* // Allocates a region of 20x20
* ivec4 region = texture_atlas_get_region( atlas, 20, 20 );
*
* // Fill region with some data
* texture_atlas_set_region( atlas, region.x, region.y, region.width, region.height, data, stride )
*
* ...
*
* @endcode
*
* @{
*/
/**
* A texture atlas is used to pack several small regions into a single texture.
*/
typedef struct texture_atlas_t
{
/**
* Allocated nodes
*/
vector_t * nodes;
/**
* Width (in pixels) of the underlying texture
*/
size_t width;
/**
* Height (in pixels) of the underlying texture
*/
size_t height;
/**
* Depth (in bytes) of the underlying texture
*/
size_t depth;
/**
* Allocated surface size
*/
size_t used;
/**
* Texture identity (OpenGL)
*/
unsigned int id;
/**
* Atlas data
*/
unsigned char * data;
} texture_atlas_t;
/**
* Creates a new empty texture atlas.
*
* @param width width of the atlas
* @param height height of the atlas
* @param depth bit depth of the atlas
* @return a new empty texture atlas.
*
*/
texture_atlas_t *
texture_atlas_new( const size_t width,
const size_t height,
const size_t depth );
/**
* Deletes a texture atlas.
*
* @param self a texture atlas structure
*
*/
void
texture_atlas_delete( texture_atlas_t * self );
/**
* Upload atlas to video memory.
*
* @param self a texture atlas structure
*
*/
void
texture_atlas_upload( texture_atlas_t * self );
/**
* Allocate a new region in the atlas.
*
* @param self a texture atlas structure
* @param width width of the region to allocate
* @param height height of the region to allocate
* @return Coordinates of the allocated region
*
*/
ivec4
texture_atlas_get_region( texture_atlas_t * self,
const size_t width,
const size_t height );
/**
* Upload data to the specified atlas region.
*
* @param self a texture atlas structure
* @param x x coordinate the region
* @param y y coordinate the region
* @param width width of the region
* @param height height of the region
* @param data data to be uploaded into the specified region
* @param stride stride of the data
*
*/
void
texture_atlas_set_region( texture_atlas_t * self,
const size_t x,
const size_t y,
const size_t width,
const size_t height,
const unsigned char *data,
const size_t stride );
/**
* Remove all allocated regions from the atlas.
*
* @param self a texture atlas structure
*/
void
texture_atlas_clear( texture_atlas_t * self );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* __TEXTURE_ATLAS_H__ */

+ 0
- 713
dgl/src/freetype-gl/texture-font.c View File

@@ -1,713 +0,0 @@
/* ===========================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#include "../freetype/FreeTypeAmalgam.h"
#include "../freetype/FreeTypeAmalgam.c"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <wchar.h>
#include "texture-font.h"
#include "platform.h"

#define HRES 64
#define HRESf 64.f
#define DPI 72

#undef __FTERRORS_H__
#define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_START_LIST {
#define FT_ERROR_END_LIST { 0, 0 } };
const struct {
int code;
const char* message;
} FT_Errors[] =
#include "freetype-errors.h"

// ------------------------------------------------- texture_font_load_face ---
static int
texture_font_load_face(texture_font_t *self, float size,
FT_Library *library, FT_Face *face)
{
FT_Error error;
FT_Matrix matrix = {
(int)((1.0/HRES) * 0x10000L),
(int)((0.0) * 0x10000L),
(int)((0.0) * 0x10000L),
(int)((1.0) * 0x10000L)};

assert(library);
assert(size);

/* Initialize library */
error = FT_Init_FreeType(library);
if(error) {
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
return 0;
}

/* Load face */
switch (self->location) {
case TEXTURE_FONT_FILE:
error = FT_New_Face(*library, self->filename, 0, face);
break;

case TEXTURE_FONT_MEMORY:
error = FT_New_Memory_Face(*library,
self->memory.base, self->memory.size, 0, face);
break;
}

if(error) {
fprintf(stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message);
FT_Done_FreeType(*library);
return 0;
}

/* Select charmap */
error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE);
if(error) {
fprintf(stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face(*face);
FT_Done_FreeType(*library);
return 0;
}

/* Set char size */
error = FT_Set_Char_Size(*face, (int)(size * HRES), 0, DPI * HRES, DPI);

if(error) {
fprintf(stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face(*face);
FT_Done_FreeType(*library);
return 0;
}

/* Set transform matrix */
FT_Set_Transform(*face, &matrix, NULL);

return 1;
}

static int
texture_font_get_face_with_size(texture_font_t *self, float size,
FT_Library *library, FT_Face *face)
{
return texture_font_load_face(self, size, library, face);
}

static int
texture_font_get_face(texture_font_t *self,
FT_Library *library, FT_Face *face)
{
return texture_font_get_face_with_size(self, self->size, library, face);
}

static int
texture_font_get_hires_face(texture_font_t *self,
FT_Library *library, FT_Face *face)
{
return texture_font_get_face_with_size(self,
self->size * 100.f, library, face);
}

// ------------------------------------------------------ texture_glyph_new ---
texture_glyph_t *
texture_glyph_new(void)
{
texture_glyph_t *self = (texture_glyph_t *) malloc( sizeof(texture_glyph_t) );
if(self == NULL) {
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__);
return NULL;
}

self->id = 0;
self->width = 0;
self->height = 0;
self->outline_type = 0;
self->outline_thickness = 0.0;
self->offset_x = 0;
self->offset_y = 0;
self->advance_x = 0.0;
self->advance_y = 0.0;
self->s0 = 0.0;
self->t0 = 0.0;
self->s1 = 0.0;
self->t1 = 0.0;
self->kerning = vector_new( sizeof(kerning_t) );
return self;
}


// --------------------------------------------------- texture_glyph_delete ---
void
texture_glyph_delete( texture_glyph_t *self )
{
assert( self );
vector_delete( self->kerning );
free( self );
}

// ---------------------------------------------- texture_glyph_get_kerning ---
float
texture_glyph_get_kerning( const texture_glyph_t * self,
const wchar_t charcode )
{
size_t i;

assert( self );
for( i=0; i<vector_size(self->kerning); ++i )
{
kerning_t * kerning = (kerning_t *) vector_get( self->kerning, i );
if( kerning->charcode == charcode )
{
return kerning->kerning;
}
}
return 0;
}


// ------------------------------------------ texture_font_generate_kerning ---
void
texture_font_generate_kerning( texture_font_t *self )
{
size_t i, j;
FT_Library library;
FT_Face face;
FT_UInt glyph_index, prev_index;
texture_glyph_t *glyph, *prev_glyph;
FT_Vector kerning;

assert( self );

/* Load font */
if(!texture_font_get_face(self, &library, &face))
return;

/* For each glyph couple combination, check if kerning is necessary */
/* Starts at index 1 since 0 is for the special backgroudn glyph */
for( i=1; i<self->glyphs->size; ++i )
{
glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
glyph_index = FT_Get_Char_Index( face, glyph->charcode );
vector_clear( glyph->kerning );

for( j=1; j<self->glyphs->size; ++j )
{
prev_glyph = *(texture_glyph_t **) vector_get( self->glyphs, j );
prev_index = FT_Get_Char_Index( face, prev_glyph->charcode );
FT_Get_Kerning( face, prev_index, glyph_index, FT_KERNING_UNFITTED, &kerning );
// printf("%c(%d)-%c(%d): %ld\n",
// prev_glyph->charcode, prev_glyph->charcode,
// glyph_index, glyph_index, kerning.x);
if( kerning.x )
{
kerning_t k = {prev_glyph->charcode, kerning.x / (float)(HRESf*HRESf)};
vector_push_back( glyph->kerning, &k );
}
}
}

FT_Done_Face( face );
FT_Done_FreeType( library );
}

// ------------------------------------------------------ texture_font_init ---
static int
texture_font_init(texture_font_t *self)
{
FT_Library library;
FT_Face face;
FT_Size_Metrics metrics;

assert(self->atlas);
assert(self->size > 0);
assert((self->location == TEXTURE_FONT_FILE && self->filename)
|| (self->location == TEXTURE_FONT_MEMORY
&& self->memory.base && self->memory.size));

self->glyphs = vector_new(sizeof(texture_glyph_t *));
self->height = 0;
self->ascender = 0;
self->descender = 0;
self->outline_type = 0;
self->outline_thickness = 0.0;
self->hinting = 1;
self->kerning = 1;
self->filtering = 1;

// FT_LCD_FILTER_LIGHT is (0x00, 0x55, 0x56, 0x55, 0x00)
// FT_LCD_FILTER_DEFAULT is (0x10, 0x40, 0x70, 0x40, 0x10)
self->lcd_weights[0] = 0x10;
self->lcd_weights[1] = 0x40;
self->lcd_weights[2] = 0x70;
self->lcd_weights[3] = 0x40;
self->lcd_weights[4] = 0x10;

/* Get font metrics at high resolution */
if (!texture_font_get_hires_face(self, &library, &face))
return -1;

self->underline_position = face->underline_position / (float)(HRESf*HRESf) * self->size;
self->underline_position = round( self->underline_position );
if( self->underline_position > -2 )
{
self->underline_position = -2.0;
}

self->underline_thickness = face->underline_thickness / (float)(HRESf*HRESf) * self->size;
self->underline_thickness = round( self->underline_thickness );
if( self->underline_thickness < 1 )
{
self->underline_thickness = 1.0;
}

metrics = face->size->metrics;
self->ascender = (metrics.ascender >> 6) / 100.0;
self->descender = (metrics.descender >> 6) / 100.0;
self->height = (metrics.height >> 6) / 100.0;
self->linegap = self->height - self->ascender + self->descender;
FT_Done_Face( face );
FT_Done_FreeType( library );

/* -1 is a special glyph */
texture_font_get_glyph( self, -1 );

return 0;
}

// --------------------------------------------- texture_font_new_from_file ---
texture_font_t *
texture_font_new_from_file(texture_atlas_t *atlas, const float pt_size,
const char *filename)
{
texture_font_t *self;

assert(filename);

self = calloc(1, sizeof(*self));
if (!self) {
fprintf(stderr,
"line %d: No more memory for allocating data\n", __LINE__);
return NULL;
}

self->atlas = atlas;
self->size = pt_size;

self->location = TEXTURE_FONT_FILE;
self->filename = strdup(filename);

if (texture_font_init(self)) {
texture_font_delete(self);
return NULL;
}

return self;
}

// ------------------------------------------- texture_font_new_from_memory ---
texture_font_t *
texture_font_new_from_memory(texture_atlas_t *atlas, float pt_size,
const void *memory_base, size_t memory_size)
{
texture_font_t *self;

assert(memory_base);
assert(memory_size);

self = calloc(1, sizeof(*self));
if (!self) {
fprintf(stderr,
"line %d: No more memory for allocating data\n", __LINE__);
return NULL;
}

self->atlas = atlas;
self->size = pt_size;

self->location = TEXTURE_FONT_MEMORY;
self->memory.base = memory_base;
self->memory.size = memory_size;

if (texture_font_init(self)) {
texture_font_delete(self);
return NULL;
}

return self;
}

// ---------------------------------------------------- texture_font_delete ---
void
texture_font_delete( texture_font_t *self )
{
size_t i;
texture_glyph_t *glyph;

assert( self );

if(self->location == TEXTURE_FONT_FILE && self->filename)
free( self->filename );

for( i=0; i<vector_size( self->glyphs ); ++i)
{
glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
texture_glyph_delete( glyph);
}

vector_delete( self->glyphs );
free( self );
}


// ----------------------------------------------- texture_font_load_glyphs ---
size_t
texture_font_load_glyphs( texture_font_t * self,
const wchar_t * charcodes )
{
size_t i, j, x, y, width, height, depth, w, h;
FT_Library library;
FT_Error error;
FT_Face face;
FT_Glyph ft_glyph;
FT_GlyphSlot slot;
FT_Bitmap ft_bitmap;

FT_UInt glyph_index;
texture_glyph_t *glyph;
FT_Int32 flags = 0;
int ft_glyph_top = 0;
int ft_glyph_left = 0;

ivec4 region;
size_t missed = 0;
char pass;

assert( self );
assert( charcodes );


width = self->atlas->width;
height = self->atlas->height;
depth = self->atlas->depth;

if (!texture_font_get_face(self, &library, &face))
return wcslen(charcodes);

/* Load each glyph */
for( i=0; i<wcslen(charcodes); ++i ) {
pass = 0;
/* Check if charcode has been already loaded */
for(j = 0; j < self->glyphs->size; ++j ) {
glyph = *(texture_glyph_t **) vector_get( self->glyphs, j );
// If charcode is -1, we don't care about outline type or thickness
// if( (glyph->charcode == charcodes[i])) {
if( (glyph->charcode == charcodes[i]) &&
((charcodes[i] == (wchar_t)(-1) ) ||
((glyph->outline_type == self->outline_type) &&
(glyph->outline_thickness == self->outline_thickness)) ))
{
pass = 1;
break;
}
}

if(pass)
continue; // don't add the item

flags = 0;
ft_glyph_top = 0;
ft_glyph_left = 0;
glyph_index = FT_Get_Char_Index( face, charcodes[i] );
// WARNING: We use texture-atlas depth to guess if user wants
// LCD subpixel rendering

if( self->outline_type > 0 )
{
flags |= FT_LOAD_NO_BITMAP;
}
else
{
flags |= FT_LOAD_RENDER;
}

if( !self->hinting )
{
flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT;
}
else
{
flags |= FT_LOAD_FORCE_AUTOHINT;
}

#if 0
if( depth == 3 )
{
FT_Library_SetLcdFilter( library, FT_LCD_FILTER_LIGHT );
flags |= FT_LOAD_TARGET_LCD;
if( self->filtering )
{
FT_Library_SetLcdFilterWeights( library, self->lcd_weights );
}
}
#endif
error = FT_Load_Glyph( face, glyph_index, flags );
if( error )
{
fprintf( stderr, "FT_Error (line %d, code 0x%02x) : %s\n",
__LINE__, FT_Errors[error].code, FT_Errors[error].message );
FT_Done_Face( face );
FT_Done_FreeType( library );
return wcslen(charcodes)-i;
}


if( self->outline_type == 0 )
{
slot = face->glyph;
ft_bitmap = slot->bitmap;
ft_glyph_top = slot->bitmap_top;
ft_glyph_left = slot->bitmap_left;
}
else
{
FT_Stroker stroker;
FT_BitmapGlyph ft_bitmap_glyph;
error = FT_Stroker_New( library, &stroker );
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
FT_Stroker_Set(stroker,
(int)(self->outline_thickness * HRES),
FT_STROKER_LINECAP_ROUND,
FT_STROKER_LINEJOIN_ROUND,
0);
error = FT_Get_Glyph( face->glyph, &ft_glyph);
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}

if( self->outline_type == 1 )
{
error = FT_Glyph_Stroke( &ft_glyph, stroker, 1 );
}
else if ( self->outline_type == 2 )
{
error = FT_Glyph_StrokeBorder( &ft_glyph, stroker, 0, 1 );
}
else if ( self->outline_type == 3 )
{
error = FT_Glyph_StrokeBorder( &ft_glyph, stroker, 1, 1 );
}
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}

if( depth == 1)
{
error = FT_Glyph_To_Bitmap( &ft_glyph, FT_RENDER_MODE_NORMAL, 0, 1);
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
}
else
{
error = FT_Glyph_To_Bitmap( &ft_glyph, FT_RENDER_MODE_LCD, 0, 1);
if( error )
{
fprintf(stderr, "FT_Error (0x%02x) : %s\n",
FT_Errors[error].code, FT_Errors[error].message);
FT_Done_Face( face );
FT_Stroker_Done( stroker );
FT_Done_FreeType( library );
return 0;
}
}
ft_bitmap_glyph = (FT_BitmapGlyph) ft_glyph;
ft_bitmap = ft_bitmap_glyph->bitmap;
ft_glyph_top = ft_bitmap_glyph->top;
ft_glyph_left = ft_bitmap_glyph->left;
FT_Stroker_Done(stroker);
}


// We want each glyph to be separated by at least one black pixel
// (for example for shader used in demo-subpixel.c)
w = ft_bitmap.width/depth + 1;
h = ft_bitmap.rows + 1;
region = texture_atlas_get_region( self->atlas, w, h );
if ( region.x < 0 )
{
missed++;
fprintf( stderr, "Texture atlas is full (line %d)\n", __LINE__ );
continue;
}
w = w - 1;
h = h - 1;
x = region.x;
y = region.y;
texture_atlas_set_region( self->atlas, x, y, w, h,
ft_bitmap.buffer, ft_bitmap.pitch );

glyph = texture_glyph_new( );
glyph->charcode = charcodes[i];
glyph->width = w;
glyph->height = h;
glyph->outline_type = self->outline_type;
glyph->outline_thickness = self->outline_thickness;
glyph->offset_x = ft_glyph_left;
glyph->offset_y = ft_glyph_top;
glyph->s0 = x/(float)width;
glyph->t0 = y/(float)height;
glyph->s1 = (x + glyph->width)/(float)width;
glyph->t1 = (y + glyph->height)/(float)height;

// Discard hinting to get advance
FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING);
slot = face->glyph;
glyph->advance_x = slot->advance.x / HRESf;
glyph->advance_y = slot->advance.y / HRESf;

vector_push_back( self->glyphs, &glyph );

if( self->outline_type > 0 )
{
FT_Done_Glyph( ft_glyph );
}
}
FT_Done_Face( face );
FT_Done_FreeType( library );
texture_atlas_upload( self->atlas );
texture_font_generate_kerning( self );
return missed;
}


// ------------------------------------------------- texture_font_get_glyph ---
texture_glyph_t *
texture_font_get_glyph( texture_font_t * self,
wchar_t charcode )
{
size_t i;
wchar_t buffer[2] = {0,0};
texture_glyph_t *glyph;

assert( self );

assert( self );
assert( self->filename );
assert( self->atlas );

/* Check if charcode has been already loaded */
for( i=0; i<self->glyphs->size; ++i )
{
glyph = *(texture_glyph_t **) vector_get( self->glyphs, i );
// If charcode is -1, we don't care about outline type or thickness
if( (glyph->charcode == charcode) &&
((charcode == (wchar_t)(-1) ) ||
((glyph->outline_type == self->outline_type) &&
(glyph->outline_thickness == self->outline_thickness)) ))
{
return glyph;
}
}

/* charcode -1 is special : it is used for line drawing (overline,
* underline, strikethrough) and background.
*/
if( charcode == (wchar_t)(-1) )
{
size_t width = self->atlas->width;
size_t height = self->atlas->height;
ivec4 region = texture_atlas_get_region( self->atlas, 5, 5 );
texture_glyph_t * glyph = texture_glyph_new( );
static unsigned char data[4*4*3] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
if ( region.x < 0 )
{
fprintf( stderr, "Texture atlas is full (line %d)\n", __LINE__ );
return NULL;
}
texture_atlas_set_region( self->atlas, region.x, region.y, 4, 4, data, 0 );
glyph->charcode = (wchar_t)(-1);
glyph->s0 = (region.x+2)/(float)width;
glyph->t0 = (region.y+2)/(float)height;
glyph->s1 = (region.x+3)/(float)width;
glyph->t1 = (region.y+3)/(float)height;
vector_push_back( self->glyphs, &glyph );
return glyph; //*(texture_glyph_t **) vector_back( self->glyphs );
}

/* Glyph has not been already loaded */
buffer[0] = charcode;
if( texture_font_load_glyphs( self, buffer ) == 0 )
{
return *(texture_glyph_t **) vector_back( self->glyphs );
}
return NULL;
}

+ 0
- 451
dgl/src/freetype-gl/texture-font.h View File

@@ -1,451 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __TEXTURE_FONT_H__
#define __TEXTURE_FONT_H__
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "vector.h"
#include "texture-atlas.h"
/**
* @file texture-font.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup texture-font Texture font
*
* Texture font.
*
* Example Usage:
* @code
* #include "texture-font.h"
*
* int main( int arrgc, char *argv[] )
* {
* return 0;
* }
* @endcode
*
* @{
*/
/**
* A structure that hold a kerning value relatively to a charcode.
*
* This structure cannot be used alone since the (necessary) right charcode is
* implicitely held by the owner of this structure.
*/
typedef struct kerning_t
{
/**
* Left character code in the kern pair.
*/
wchar_t charcode;
/**
* Kerning value (in fractional pixels).
*/
float kerning;
} kerning_t;
/*
* Glyph metrics:
* --------------
*
* xmin xmax
* | |
* |<-------- width -------->|
* | |
* | +-------------------------+----------------- ymax
* | | ggggggggg ggggg | ^ ^
* | | g:::::::::ggg::::g | | |
* | | g:::::::::::::::::g | | |
* | | g::::::ggggg::::::gg | | |
* | | g:::::g g:::::g | | |
* offset_x -|-------->| g:::::g g:::::g | offset_y |
* | | g:::::g g:::::g | | |
* | | g::::::g g:::::g | | |
* | | g:::::::ggggg:::::g | | |
* | | g::::::::::::::::g | | height
* | | gg::::::::::::::g | | |
* baseline ---*---------|---- gggggggg::::::g-----*-------- |
* / | | g:::::g | |
* origin | | gggggg g:::::g | |
* | | g:::::gg gg:::::g | |
* | | g::::::ggg:::::::g | |
* | | gg:::::::::::::g | |
* | | ggg::::::ggg | |
* | | gggggg | v
* | +-------------------------+----------------- ymin
* | |
* |------------- advance_x ---------->|
*/
/**
* A structure that describe a glyph.
*/
typedef struct texture_glyph_t
{
/**
* Wide character this glyph represents
*/
wchar_t charcode;
/**
* Glyph id (used for display lists)
*/
unsigned int id;
/**
* Glyph's width in pixels.
*/
size_t width;
/**
* Glyph's height in pixels.
*/
size_t height;
/**
* Glyph's left bearing expressed in integer pixels.
*/
int offset_x;
/**
* Glyphs's top bearing expressed in integer pixels.
*
* Remember that this is the distance from the baseline to the top-most
* glyph scanline, upwards y coordinates being positive.
*/
int offset_y;
/**
* For horizontal text layouts, this is the horizontal distance (in
* fractional pixels) used to increment the pen position when the glyph is
* drawn as part of a string of text.
*/
float advance_x;
/**
* For vertical text layouts, this is the vertical distance (in fractional
* pixels) used to increment the pen position when the glyph is drawn as
* part of a string of text.
*/
float advance_y;
/**
* First normalized texture coordinate (x) of top-left corner
*/
float s0;
/**
* Second normalized texture coordinate (y) of top-left corner
*/
float t0;
/**
* First normalized texture coordinate (x) of bottom-right corner
*/
float s1;
/**
* Second normalized texture coordinate (y) of bottom-right corner
*/
float t1;
/**
* A vector of kerning pairs relative to this glyph.
*/
vector_t * kerning;
/**
* Glyph outline type (0 = None, 1 = line, 2 = inner, 3 = outer)
*/
int outline_type;
/**
* Glyph outline thickness
*/
float outline_thickness;
} texture_glyph_t;
/**
* Texture font structure.
*/
typedef struct texture_font_t
{
/**
* Vector of glyphs contained in this font.
*/
vector_t * glyphs;
/**
* Atlas structure to store glyphs data.
*/
texture_atlas_t * atlas;
/**
* font location
*/
enum {
TEXTURE_FONT_FILE = 0,
TEXTURE_FONT_MEMORY,
} location;
union {
/**
* Font filename, for when location == TEXTURE_FONT_FILE
*/
char *filename;
/**
* Font memory address, for when location == TEXTURE_FONT_MEMORY
*/
struct {
const void *base;
size_t size;
} memory;
};
/**
* Font size
*/
float size;
/**
* Whether to use autohint when rendering font
*/
int hinting;
/**
* Outline type (0 = None, 1 = line, 2 = inner, 3 = outer)
*/
int outline_type;
/**
* Outline thickness
*/
float outline_thickness;
/**
* Whether to use our own lcd filter.
*/
int filtering;
/**
* Whether to use kerning if available
*/
int kerning;
/**
* LCD filter weights
*/
unsigned char lcd_weights[5];
/**
* This field is simply used to compute a default line spacing (i.e., the
* baseline-to-baseline distance) when writing text with this font. Note
* that it usually is larger than the sum of the ascender and descender
* taken as absolute values. There is also no guarantee that no glyphs
* extend above or below subsequent baselines when using this distance.
*/
float height;
/**
* This field is the distance that must be placed between two lines of
* text. The baseline-to-baseline distance should be computed as:
* ascender - descender + linegap
*/
float linegap;
/**
* The ascender is the vertical distance from the horizontal baseline to
* the highest 'character' coordinate in a font face. Unfortunately, font
* formats define the ascender differently. For some, it represents the
* ascent of all capital latin characters (without accents), for others it
* is the ascent of the highest accented character, and finally, other
* formats define it as being equal to bbox.yMax.
*/
float ascender;
/**
* The descender is the vertical distance from the horizontal baseline to
* the lowest 'character' coordinate in a font face. Unfortunately, font
* formats define the descender differently. For some, it represents the
* descent of all capital latin characters (without accents), for others it
* is the ascent of the lowest accented character, and finally, other
* formats define it as being equal to bbox.yMin. This field is negative
* for values below the baseline.
*/
float descender;
/**
* The position of the underline line for this face. It is the center of
* the underlining stem. Only relevant for scalable formats.
*/
float underline_position;
/**
* The thickness of the underline for this face. Only relevant for scalable
* formats.
*/
float underline_thickness;
} texture_font_t;
/**
* This function creates a new texture font from given filename and size. The
* texture atlas is used to store glyph on demand. Note the depth of the atlas
* will determine if the font is rendered as alpha channel only (depth = 1) or
* RGB (depth = 3) that correspond to subpixel rendering (if available on your
* freetype implementation).
*
* @param atlas A texture atlas
* @param pt_size Size of font to be created (in points)
* @param filename A font filename
*
* @return A new empty font (no glyph inside yet)
*
*/
texture_font_t *
texture_font_new_from_file( texture_atlas_t * atlas,
const float pt_size,
const char * filename );
/**
* This function creates a new texture font from a memory location and size.
* The texture atlas is used to store glyph on demand. Note the depth of the
* atlas will determine if the font is rendered as alpha channel only
* (depth = 1) or RGB (depth = 3) that correspond to subpixel rendering (if
* available on your freetype implementation).
*
* @param atlas A texture atlas
* @param pt_size Size of font to be created (in points)
* @param memory_base Start of the font file in memory
* @param memory_size Size of the font file memory region, in bytes
*
* @return A new empty font (no glyph inside yet)
*
*/
texture_font_t *
texture_font_new_from_memory( texture_atlas_t *atlas,
float pt_size,
const void *memory_base,
size_t memory_size );
/**
* Delete a texture font. Note that this does not delete the glyph from the
* texture atlas.
*
* @param self a valid texture font
*/
void
texture_font_delete( texture_font_t * self );
/**
* Request a new glyph from the font. If it has not been created yet, it will
* be.
*
* @param self A valid texture font
* @param charcode Character codepoint to be loaded.
*
* @return A pointer on the new glyph or 0 if the texture atlas is not big
* enough
*
*/
texture_glyph_t *
texture_font_get_glyph( texture_font_t * self,
wchar_t charcode );
/**
* Request the loading of several glyphs at once.
*
* @param self a valid texture font
* @param charcodes character codepoints to be loaded.
*
* @return Number of missed glyph if the texture is not big enough to hold
* every glyphs.
*/
size_t
texture_font_load_glyphs( texture_font_t * self,
const wchar_t * charcodes );
/**
* Get the kerning between two horizontal glyphs.
*
* @param self a valid texture glyph
* @param charcode codepoint of the peceding glyph
*
* @return x kerning value
*/
float
texture_glyph_get_kerning( const texture_glyph_t * self,
const wchar_t charcode );
/**
* Creates a new empty glyph
*
* @return a new empty glyph (not valid)
*/
texture_glyph_t *
texture_glyph_new( void );
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* __TEXTURE_FONT_H__ */

+ 0
- 237
dgl/src/freetype-gl/vec234.h View File

@@ -1,237 +0,0 @@
/* ============================================================================
* 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.
* ============================================================================
*/
#ifndef __VEC234_H__
#define __VEC234_H__

#ifdef __cplusplus
extern "C" {
#endif


/**
* Tuple of 4 ints.
*
* Each field can be addressed using several aliases:
* - First component: <b>x</b>, <b>r</b>, <b>red</b> or <b>vstart</b>
* - Second component: <b>y</b>, <b>g</b>, <b>green</b> or <b>vcount</b>
* - Third component: <b>z</b>, <b>b</b>, <b>blue</b>, <b>width</b> or <b>istart</b>
* - Fourth component: <b>w</b>, <b>a</b>, <b>alpha</b>, <b>height</b> or <b>icount</b>
*
*/
typedef union
{
int data[4]; /**< All compoments at once */
struct {
int x; /**< Alias for first component */
int y; /**< Alias for second component */
int z; /**< Alias for third component */
int w; /**< Alias for fourht component */
};
struct {
int x_; /**< Alias for first component */
int y_; /**< Alias for second component */
int width; /**< Alias for third component */
int height; /**< Alias for fourth component */
};
struct {
int r; /**< Alias for first component */
int g; /**< Alias for second component */
int b; /**< Alias for third component */
int a; /**< Alias for fourth component */
};
struct {
int red; /**< Alias for first component */
int green; /**< Alias for second component */
int blue; /**< Alias for third component */
int alpha; /**< Alias for fourth component */
};
struct {
int vstart; /**< Alias for first component */
int vcount; /**< Alias for second component */
int istart; /**< Alias for third component */
int icount; /**< Alias for fourth component */
};
} ivec4;


/**
* Tuple of 3 ints.
*
* Each field can be addressed using several aliases:
* - First component: <b>x</b>, <b>r</b> or <b>red</b>
* - Second component: <b>y</b>, <b>g</b> or <b>green</b>
* - Third component: <b>z</b>, <b>b</b> or <b>blue</b>
*
*/
typedef union
{
int data[3]; /**< All compoments at once */
struct {
int x; /**< Alias for first component */
int y; /**< Alias for second component */
int z; /**< Alias for third component */
};
struct {
int r; /**< Alias for first component */
int g; /**< Alias for second component */
int b; /**< Alias for third component */
};
struct {
int red; /**< Alias for first component */
int green; /**< Alias for second component */
int blue; /**< Alias for third component */
};
} ivec3;


/**
* Tuple of 2 ints.
*
* Each field can be addressed using several aliases:
* - First component: <b>x</b>, <b>s</b> or <b>start</b>
* - Second component: <b>y</b>, <b>t</b> or <b>end</b>
*
*/
typedef union
{
int data[2]; /**< All compoments at once */
struct {
int x; /**< Alias for first component */
int y; /**< Alias for second component */
};
struct {
int s; /**< Alias for first component */
int t; /**< Alias for second component */
};
struct {
int start; /**< Alias for first component */
int end; /**< Alias for second component */
};
} ivec2;


/**
* Tuple of 4 floats.
*
* Each field can be addressed using several aliases:
* - First component: <b>x</b>, <b>r</b> or <b>red</b>
* - Second component: <b>y</b>, <b>g</b> or <b>green</b>
* - Third component: <b>z</b>, <b>b</b>, <b>blue</b> or <b>width</b>
* - Fourth component: <b>w</b>, <b>a</b>, <b>alpha</b> or <b>height</b>
*/
typedef union
{
float data[4]; /**< All compoments at once */
struct {
float x; /**< Alias for first component */
float y; /**< Alias fo second component */
float z; /**< Alias fo third component */
float w; /**< Alias fo fourth component */
};
struct {
float x_; /**< Alias for first component */
float y_; /**< Alias fo second component */
float width; /**< Alias fo third component */
float height; /**< Alias fo fourth component */
};
struct {
float r; /**< Alias for first component */
float g; /**< Alias fo second component */
float b; /**< Alias fo third component */
float a; /**< Alias fo fourth component */
};
struct {
float red; /**< Alias for first component */
float green; /**< Alias fo second component */
float blue; /**< Alias fo third component */
float alpha; /**< Alias fo fourth component */
};
} vec4;


/**
* Tuple of 3 floats
*
* Each field can be addressed using several aliases:
* - First component: <b>x</b>, <b>r</b> or <b>red</b>
* - Second component: <b>y</b>, <b>g</b> or <b>green</b>
* - Third component: <b>z</b>, <b>b</b> or <b>blue</b>
*/
typedef union
{
float data[3]; /**< All compoments at once */
struct {
float x; /**< Alias for first component */
float y; /**< Alias fo second component */
float z; /**< Alias fo third component */
};
struct {
float r; /**< Alias for first component */
float g; /**< Alias fo second component */
float b; /**< Alias fo third component */
};
struct {
float red; /**< Alias for first component */
float green; /**< Alias fo second component */
float blue; /**< Alias fo third component */
};
} vec3;


/**
* Tuple of 2 floats
*
* Each field can be addressed using several aliases:
* - First component: <b>x</b> or <b>s</b>
* - Second component: <b>y</b> or <b>t</b>
*/
typedef union
{
float data[2]; /**< All components at once */
struct {
float x; /**< Alias for first component */
float y; /**< Alias for second component */
};
struct {
float s; /**< Alias for first component */
float t; /**< Alias for second component */
};
} vec2;


#ifdef __cplusplus
}
#endif

#endif /* __VEC234_H__ */

+ 0
- 362
dgl/src/freetype-gl/vector.c View File

@@ -1,362 +0,0 @@
/* =========================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* -------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ========================================================================= */
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "vector.h"



// ------------------------------------------------------------- vector_new ---
vector_t *
vector_new( size_t item_size )
{
vector_t *self = (vector_t *) malloc( sizeof(vector_t) );
assert( item_size );

if( !self )
{
fprintf( stderr,
"line %d: No more memory for allocating data\n", __LINE__ );
exit( EXIT_FAILURE );
}
self->item_size = item_size;
self->size = 0;
self->capacity = 1;
self->items = malloc( self->item_size * self->capacity );
return self;
}



// ---------------------------------------------------------- vector_delete ---
void
vector_delete( vector_t *self )
{
assert( self );

free( self->items );
free( self );
}



// ------------------------------------------------------------- vector_get ---
const void *
vector_get( const vector_t *self,
size_t index )
{
assert( self );
assert( self->size );
assert( index < self->size );

return (char*)(self->items) + index * self->item_size;
}



// ----------------------------------------------------------- vector_front ---
const void *
vector_front( const vector_t *self )
{
assert( self );
assert( self->size );

return vector_get( self, 0 );
}


// ------------------------------------------------------------ vector_back ---
const void *
vector_back( const vector_t *self )
{
assert( self );
assert( self->size );

return vector_get( self, self->size-1 );
}


// -------------------------------------------------------- vector_contains ---
int
vector_contains( const vector_t *self,
const void *item,
int (*cmp)(const void *, const void *) )
{
size_t i;
assert( self );

for( i=0; i<self->size; ++i )
{
if( (*cmp)(item, vector_get(self,i) ) == 0 )
{
return 1;
}
}
return 0;
}


// ----------------------------------------------------------- vector_empty ---
int
vector_empty( const vector_t *self )
{
assert( self );

return self->size == 0;
}


// ------------------------------------------------------------ vector_size ---
size_t
vector_size( const vector_t *self )
{
assert( self );

return self->size;
}


// --------------------------------------------------------- vector_reserve ---
void
vector_reserve( vector_t *self,
const size_t size )
{
assert( self );

if( self->capacity < size)
{
self->items = realloc( self->items, size * self->item_size );
self->capacity = size;
}
}


// -------------------------------------------------------- vector_capacity ---
size_t
vector_capacity( const vector_t *self )
{
assert( self );

return self->capacity;
}


// ---------------------------------------------------------- vector_shrink ---
void
vector_shrink( vector_t *self )
{
assert( self );

if( self->capacity > self->size )
{
self->items = realloc( self->items, self->size * self->item_size );
}
self->capacity = self->size;
}


// ----------------------------------------------------------- vector_clear ---
void
vector_clear( vector_t *self )
{
assert( self );

self->size = 0;
}


// ------------------------------------------------------------- vector_set ---
void
vector_set( vector_t *self,
const size_t index,
const void *item )
{
assert( self );
assert( self->size );
assert( index < self->size );

memcpy( (char *)(self->items) + index * self->item_size,
item, self->item_size );
}


// ---------------------------------------------------------- vector_insert ---
void
vector_insert( vector_t *self,
const size_t index,
const void *item )
{
assert( self );
assert( index <= self->size);

if( self->capacity <= self->size )
{
vector_reserve(self, 2 * self->capacity );
}
if( index < self->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++;
vector_set( self, index, item );
}


// ----------------------------------------------------- vector_erase_range ---
void
vector_erase_range( vector_t *self,
const size_t first,
const size_t last )
{
assert( self );
assert( first < self->size );
assert( last < self->size+1 );
assert( first < last );

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);
}


// ----------------------------------------------------------- vector_erase ---
void
vector_erase( vector_t *self,
const size_t index )
{
assert( self );
assert( index < self->size );

vector_erase_range( self, index, index+1 );
}


// ------------------------------------------------------- vector_push_back ---
void
vector_push_back( vector_t *self,
const void *item )
{
vector_insert( self, self->size, item );
}


// -------------------------------------------------------- vector_pop_back ---
void
vector_pop_back( vector_t *self )
{
assert( self );
assert( self->size );

self->size--;
}


// ---------------------------------------------------------- vector_resize ---
void
vector_resize( vector_t *self,
const size_t size )
{
assert( self );

if( size > self->capacity)
{
vector_reserve( self, size );
self->size = self->capacity;
}
else
{
self->size = size;
}
}


// -------------------------------------------------- vector_push_back_data ---
void
vector_push_back_data( vector_t *self,
const void * data,
const size_t count )
{
assert( self );
assert( data );
assert( count );

if( self->capacity < (self->size+count) )
{
vector_reserve(self, self->size+count);
}
memmove( (char *)(self->items) + self->size * self->item_size, data,
count*self->item_size );
self->size += count;
}


// ----------------------------------------------------- vector_insert_data ---
void
vector_insert_data( vector_t *self,
const size_t index,
const void * data,
const size_t count )
{
assert( self );
assert( index < self->size );
assert( data );
assert( count );

if( self->capacity < (self->size+count) )
{
vector_reserve(self, self->size+count);
}
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 );
self->size += count;
}


// ------------------------------------------------------------ vector_sort ---
void
vector_sort( vector_t *self,
int (*cmp)(const void *, const void *) )
{
assert( self );
assert( self->size );

qsort(self->items, self->size, self->item_size, cmp);
}

+ 0
- 353
dgl/src/freetype-gl/vector.h View File

@@ -1,353 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __VECTOR_H__
#define __VECTOR_H__

#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

/**
* @file vector.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup vector Vector
*
* The vector structure and accompanying functions loosely mimic the STL C++
* vector class. It is used by @ref texture-atlas (for storing nodes), @ref
* texture-font (for storing glyphs) and @ref font-manager (for storing fonts).
* More information at http://www.cppreference.com/wiki/container/vector/start
*
* <b>Example Usage</b>:
* @code
* #include "vector.h"
*
* int main( int arrgc, char *argv[] )
* {
* int i,j = 1;
* vector_t * vector = vector_new( sizeof(int) );
* vector_push_back( &i );
*
* j = * (int *) vector_get( vector, 0 );
* vector_delete( vector);
*
* return 0;
* }
* @endcode
*
* @{
*/

/**
* Generic vector structure.
*
* @memberof vector
*/
typedef struct vector_t
{
/** Pointer to dynamically allocated items. */
void * items;

/** Number of items that can be held in currently allocated storage. */
size_t capacity;

/** Number of items. */
size_t size;

/** Size (in bytes) of a single item. */
size_t item_size;
} vector_t;


/**
* Creates a new empty vector.
*
* @param item_size item size in bytes
* @return a new empty vector
*
*/
vector_t *
vector_new( size_t item_size );


/**
* Deletes a vector.
*
* @param self a vector structure
*
*/
void
vector_delete( vector_t *self );


/**
* Returns a pointer to the item located at specified index.
*
* @param self a vector structure
* @param index the index of the item to be returned
* @return pointer on the specified item
*/
const void *
vector_get( const vector_t *self,
size_t index );


/**
* Returns a pointer to the first item.
*
* @param self a vector structure
* @return pointer on the first item
*/
const void *
vector_front( const vector_t *self );


/**
* Returns a pointer to the last item
*
* @param self a vector structure
* @return pointer on the last item
*/
const void *
vector_back( const vector_t *self );


/**
* Check if an item is contained within the vector.
*
* @param self a vector structure
* @param item item to be searched in the vector
* @param cmp a pointer a comparison function
* @return 1 if item is contained within the vector, 0 otherwise
*/
int
vector_contains( const vector_t *self,
const void *item,
int (*cmp)(const void *, const void *) );


/**
* Checks whether the vector is empty.
*
* @param self a vector structure
* @return 1 if the vector is empty, 0 otherwise
*/
int
vector_empty( const vector_t *self );


/**
* Returns the number of items
*
* @param self a vector structure
* @return number of items
*/
size_t
vector_size( const vector_t *self );


/**
* Reserve storage such that it can hold at last size items.
*
* @param self a vector structure
* @param size the new storage capacity
*/
void
vector_reserve( vector_t *self,
const size_t size );


/**
* Returns current storage capacity
*
* @param self a vector structure
* @return storage capacity
*/
size_t
vector_capacity( const vector_t *self );


/**
* Decrease capacity to fit actual size.
*
* @param self a vector structure
*/
void
vector_shrink( vector_t *self );


/**
* Removes all items.
*
* @param self a vector structure
*/
void
vector_clear( vector_t *self );


/**
* Replace an item.
*
* @param self a vector structure
* @param index the index of the item to be replaced
* @param item the new item
*/
void
vector_set( vector_t *self,
const size_t index,
const void *item );


/**
* Erase an item.
*
* @param self a vector structure
* @param index the index of the item to be erased
*/
void
vector_erase( vector_t *self,
const size_t index );


/**
* Erase a range of items.
*
* @param self a vector structure
* @param first the index of the first item to be erased
* @param last the index of the last item to be erased
*/
void
vector_erase_range( vector_t *self,
const size_t first,
const size_t last );


/**
* Appends given item to the end of the vector.
*
* @param self a vector structure
* @param item the item to be inserted
*/
void
vector_push_back( vector_t *self,
const void *item );


/**
* Removes the last item of the vector.
*
* @param self a vector structure
*/
void
vector_pop_back( vector_t *self );


/**
* Resizes the vector to contain size items
*
* If the current size is less than size, additional items are appended and
* initialized with value. If the current size is greater than size, the
* vector is reduced to its first size elements.
*
* @param self a vector structure
* @param size the new size
*/
void
vector_resize( vector_t *self,
const size_t size );


/**
* Insert a single item at specified index.
*
* @param self a vector structure
* @param index location before which to insert item
* @param item the item to be inserted
*/
void
vector_insert( vector_t *self,
const size_t index,
const void *item );


/**
* Insert raw data at specified index.
*
* @param self a vector structure
* @param index location before which to insert item
* @param data a pointer to the items to be inserted
* @param count the number of items to be inserted
*/
void
vector_insert_data( vector_t *self,
const size_t index,
const void * data,
const size_t count );


/**
* Append raw data to the end of the vector.
*
* @param self a vector structure
* @param data a pointer to the items to be inserted
* @param count the number of items to be inserted
*/
void
vector_push_back_data( vector_t *self,
const void * data,
const size_t count );


/**
* Sort vector items according to cmp function.
*
* @param self a vector structure
* @param cmp a pointer a comparison function
*/
void
vector_sort( vector_t *self,
int (*cmp)(const void *, const void *) );


/** @} */

#ifdef __cplusplus
}
#endif

#endif /* __VECTOR_H__ */

+ 0
- 168
dgl/src/freetype-gl/vertex-attribute.c View File

@@ -1,168 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "vec234.h"
#include "platform.h"
#include "vertex-attribute.h"



// ----------------------------------------------------------------------------
vertex_attribute_t *
vertex_attribute_new( GLchar * name,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
GLvoid *pointer )
{
vertex_attribute_t *attribute =
(vertex_attribute_t *) malloc (sizeof(vertex_attribute_t));

assert( size > 0 );

attribute->name = (GLchar *) strdup( name );
attribute->index = -1;
attribute->size = size;
attribute->type = type;
attribute->normalized = normalized;
attribute->stride = stride;
attribute->pointer = pointer;
return attribute;
}



// ----------------------------------------------------------------------------
void
vertex_attribute_delete( vertex_attribute_t * self )
{
assert( self );

free( self->name );
free( self );
}



// ----------------------------------------------------------------------------
vertex_attribute_t *
vertex_attribute_parse( char *format )
{
GLenum type = 0;
int size;
int normalized = 0;
char ctype;
char *name;
vertex_attribute_t *attr;
char *p = strchr(format, ':');
if( p != NULL)
{
name = strndup(format, p-format);
if( *(++p) == '\0' )
{
fprintf( stderr, "No size specified for '%s' attribute\n", name );
free( name );
return 0;
}
size = *p - '0';

if( *(++p) == '\0' )
{
fprintf( stderr, "No format specified for '%s' attribute\n", name );
free( name );
return 0;
}
ctype = *p;

if( *(++p) != '\0' )
{
if( *p == 'n' )
{
normalized = 1;
}
}

}
else
{
fprintf(stderr, "Vertex attribute format not understood ('%s')\n", format );
return 0;
}

switch( ctype )
{
case 'b': type = GL_BYTE; break;
case 'B': type = GL_UNSIGNED_BYTE; break;
case 's': type = GL_SHORT; break;
case 'S': type = GL_UNSIGNED_SHORT; break;
case 'i': type = GL_INT; break;
case 'I': type = GL_UNSIGNED_INT; break;
case 'f': type = GL_FLOAT; break;
default: type = 0; break;
}


attr = vertex_attribute_new( name, size, type, normalized, 0, 0 );
free( name );
return attr;
}



// ----------------------------------------------------------------------------
void
vertex_attribute_enable( vertex_attribute_t *attr )
{
if( attr->index == -1 )
{
GLint program;
glGetIntegerv( GL_CURRENT_PROGRAM, &program );
if( program == 0)
{
return;
}
attr->index = glGetAttribLocation( program, attr->name );
if( attr->index == -1 )
{
return;
}
}
glEnableVertexAttribArray( attr->index );
glVertexAttribPointer( attr->index, attr->size, attr->type,
attr->normalized, attr->stride, attr->pointer );
}

+ 0
- 320
dgl/src/freetype-gl/vertex-attribute.h View File

@@ -1,320 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __VERTEX_ATTRIBUTE_H__
#define __VERTEX_ATTRIBUTE_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "opengl.h"
#include "vector.h"


/**
* @file vertex-attribute.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
*
* @defgroup vertex-attribut Vertex attribute
*
* Besides the required vertex position, vertices can have several other
* numeric attributes. Each is specified in the format string with a letter,
* the number of components and the data type.
*
* Each of the attributes is described in the table below with the set of valid
* format strings written as a regular expression (for example, "v[234][if]"
* means "v2f", "v3i", "v4f", etc. are all valid formats).
*
* Some attributes have a "recommended" format string, which is the most
* efficient form for the video driver as it requires less conversion.
*
* <table>
* <tr>
* <th>Attribute</th>
* <th>Formats</th>
* <th>Recommended</th>
* </tr>
* <tr>
* <td>Vertex position</td>
* <td>"v[234][sifd]"</td>
* <td>"v[234]f"</td>
* </tr>
* <tr>
* <td> Color </td>
* <td> "c[34][bBsSiIfd]" </td>
* <td> "c[34]B" </td>
* </tr>
* <tr>
* <td> Edge flag </td>
* <td> "e1[bB]" </td>
* <td> </td>
* </tr>
* <tr>
* <td> Fog coordinate </td>
* <td> "f[1234][bBsSiIfd]"</td>
* <td> </td>
* </tr>
* <tr>
* <td> Normal </td>
* <td> "n3[bsifd]" </td>
* <td> "n3f" </td>
* </tr>
* <tr>
* <td> Secondary color </td>
* <td> "s[34][bBsSiIfd]" </td>
* <td> "s[34]B" </td>
* </tr>
* <tr>
* <td> Texture coordinate </td>
* <td> "t[234][sifd]" </td>
* <td> "t[234]f" </td>
* </tr>
* <tr>
* <td> Generic attribute </td>
* <td> "[0-15]g(n)?[1234][bBsSiIfd]" </td>
* <td> </td>
* </tr>
* </table>
*
* The possible data types that can be specified in the format string are described below.
*
* <table>
* <tr>
* <th> Format </th>
* <th> Type </th>
* <th> GL Type </th>
* </tr>
* <tr>
* <td> "b" </td>
* <td> Signed byte </td>
* <td> GL_BYTE </td>
* </tr>
* <tr>
* <td> "B" </td>
* <td> Unsigned byte </td>
* <td> GL_UNSIGNED_BYTE </td>
* </tr>
* <tr>
* <td> "s" </td>
* <td> Signed short </td>
* <td> GL_SHORT </td>
* </tr>
* <tr>
* <td> "S" </td>
* <td> Unsigned short </td>
* <td> GL_UNSIGNED_SHORT </td>
* </tr>
* <tr>
* <td> "i" </td>
* <td> Signed int </td>
* <td> GL_INT </td>
* </tr>
* <tr>
* <td> "I" </td>
* <td> Unsigned int </td>
* <td> GL_UNSIGNED_INT </td>
* </tr>
* <tr>
* <td> "f" </td>
* <td> Float </td>
* <td> GL_FLOAT </td>
* </tr>
* <tr>
* <td> "d" </td>
* <td> Double </td>
* <td> GL_DOUBLE T </td>
* </tr>
* </table>
*
* The following attributes are normalised to the range [0, 1]. The value is
* used as-is if the data type is floating-point. If the data type is byte,
* short or int, the value is divided by the maximum value representable by
* that type. For example, unsigned bytes are divided by 255 to get the
* normalised value.
*
* - Color
* - Secondary color
* - Generic attributes with the "n" format given.
*
* Up to 16 generic attributes can be specified per vertex, and can be used by
* shader programs for any purpose (they are ignored in the fixed-function
* pipeline). For the other attributes, consult the OpenGL programming guide
* for details on their effects.
*
* When using the draw and related functions, attribute data is specified
* alongside the vertex position data. The following example reproduces the two
* points from the previous page, except that the first point is blue and the
* second green:
*
* It is an error to provide more than one set of data for any attribute, or to
* mismatch the size of the initial data with the number of vertices specified
* in the first argument.
*
* @{
*/


/**
* Maximum number of attributes per vertex
*
* @private
*/
#define MAX_VERTEX_ATTRIBUTE 16


/**
* Generic vertex attribute.
*/
typedef struct vertex_attribute_t
{
/**
* atribute name
*/
GLchar * name;

/**
* index of the generic vertex attribute to be modified.
*/
GLuint index;

/**
* Number of components per generic vertex attribute.
*
* Must be 1, 2, 3, or 4. The initial value is 4.
*/
GLint size;

/**
* data type of each component in the array.
*
* Symbolic constants GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT,
* GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, or GL_DOUBLE are
* accepted. The initial value is GL_FLOAT.
*/
GLenum type;

/**
* whether fixed-point data values should be normalized (GL_TRUE) or
* converted directly as fixed-point values (GL_FALSE) when they are
* accessed.
*/
GLboolean normalized;

/**
* byte offset between consecutive generic vertex attributes.
*
* If stride is 0, the generic vertex attributes are understood to be
* tightly packed in the array. The initial value is 0.
*/
GLsizei stride;

/**
* pointer to the first component of the first attribute element in the
* array.
*/
GLvoid * pointer;

/**
* pointer to the function that enable this attribute.
*/
void ( * enable )(void *);

} vertex_attribute_t;



/**
* Create an attribute from the given parameters.
*
* @param size number of component
* @param type data type
* @param normalized Whether fixed-point data values should be normalized
(GL_TRUE) or converted directly as fixed-point values
(GL_FALSE) when they are accessed.
* @param stride byte offset between consecutive attributes.
* @param pointer pointer to the first component of the first attribute
* element in the array.
* @return a new initialized vertex attribute.
*
* @private
*/
vertex_attribute_t *
vertex_attribute_new( GLchar * name,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
GLvoid *pointer );



/**
* Delete a vertex attribute.
*
* @param self a vertex attribute
*
*/
void
vertex_attribute_delete( vertex_attribute_t * self );


/**
* Create an attribute from the given description.
*
* @param format Format string specifies the format of a vertex attribute.
* @return an initialized vertex attribute
*
* @private
*/
vertex_attribute_t *
vertex_attribute_parse( char *format );

/**
* Enable a vertex attribute.
*
* @param attr a vertex attribute
*
* @private
*/
void
vertex_attribute_enable( vertex_attribute_t *attr );


/** @} */

#ifdef __cplusplus
}
#endif

#endif /* __VERTEX_ATTRIBUTE_H__ */

+ 0
- 662
dgl/src/freetype-gl/vertex-buffer.c View File

@@ -1,662 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "vec234.h"
#include "platform.h"
#include "vertex-buffer.h"

/**
* Buffer status
*/
#define CLEAN (0)
#define DIRTY (1)
#define FROZEN (2)


// ----------------------------------------------------------------------------
vertex_buffer_t *
vertex_buffer_new( const char *format )
{
size_t i, index = 0, stride = 0;
const char *start = 0, *end = 0;
GLchar *pointer = 0;

vertex_buffer_t *self = (vertex_buffer_t *) malloc (sizeof(vertex_buffer_t));
if( !self )
{
return NULL;
}

self->format = strdup( format );

for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i )
{
self->attributes[i] = 0;
}

start = format;
do
{
char *desc = 0;
vertex_attribute_t *attribute;
GLuint attribute_size = 0;
end = (char *) (strchr(start+1, ','));

if (end == NULL)
{
desc = strdup( start );
}
else
{
desc = strndup( start, end-start );
}
attribute = vertex_attribute_parse( desc );
start = end+1;
free(desc);
attribute->pointer = pointer;

switch( attribute->type )
{
case GL_BOOL: attribute_size = sizeof(GLboolean); break;
case GL_BYTE: attribute_size = sizeof(GLbyte); break;
case GL_UNSIGNED_BYTE: attribute_size = sizeof(GLubyte); break;
case GL_SHORT: attribute_size = sizeof(GLshort); break;
case GL_UNSIGNED_SHORT: attribute_size = sizeof(GLushort); break;
case GL_INT: attribute_size = sizeof(GLint); break;
case GL_UNSIGNED_INT: attribute_size = sizeof(GLuint); break;
case GL_FLOAT: attribute_size = sizeof(GLfloat); break;
default: attribute_size = 0;
}
stride += attribute->size*attribute_size;
pointer += attribute->size*attribute_size;
self->attributes[index] = attribute;
index++;
} while ( end && (index < MAX_VERTEX_ATTRIBUTE) );

for( i=0; i<index; ++i )
{
self->attributes[i]->stride = stride;
}

#ifdef FREETYPE_GL_USE_VAO
self->VAO_id = 0;
#endif

self->vertices = vector_new( stride );
self->vertices_id = 0;
self->GPU_vsize = 0;

self->indices = vector_new( sizeof(GLuint) );
self->indices_id = 0;
self->GPU_isize = 0;

self->items = vector_new( sizeof(ivec4) );
self->state = DIRTY;
self->mode = GL_TRIANGLES;
return self;
}



// ----------------------------------------------------------------------------
void
vertex_buffer_delete( vertex_buffer_t *self )
{
size_t i;

assert( self );

for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i )
{
if( self->attributes[i] )
{
vertex_attribute_delete( self->attributes[i] );
}
}

#ifdef FREETYPE_GL_USE_VAO
if( self->VAO_id )
{
glDeleteVertexArrays( 1, &self->VAO_id );
}
self->VAO_id = 0;
#endif

vector_delete( self->vertices );
self->vertices = 0;
if( self->vertices_id )
{
glDeleteBuffers( 1, &self->vertices_id );
}
self->vertices_id = 0;

vector_delete( self->indices );
self->indices = 0;
if( self->indices_id )
{
glDeleteBuffers( 1, &self->indices_id );
}
self->indices_id = 0;

vector_delete( self->items );

if( self->format )
{
free( self->format );
}
self->format = 0;
self->state = 0;
free( self );
}


// ----------------------------------------------------------------------------
const char *
vertex_buffer_format( const vertex_buffer_t *self )
{
assert( self );

return self->format;
}


// ----------------------------------------------------------------------------
size_t
vertex_buffer_size( const vertex_buffer_t *self )
{
assert( self );

return vector_size( self->items );
}


// ----------------------------------------------------------------------------
void
vertex_buffer_print( vertex_buffer_t * self )
{
int i = 0;
static char *gltypes[9] = {
"GL_BOOL",
"GL_BYTE",
"GL_UNSIGNED_BYTE",
"GL_SHORT",
"GL_UNSIGNED_SHORT",
"GL_INT",
"GL_UNSIGNED_INT",
"GL_FLOAT",
"GL_VOID"
};

assert(self);

fprintf( stderr, "%ld vertices, %ld indices\n",
vector_size( self->vertices ), vector_size( self->indices ) );
while( self->attributes[i] )
{
int j = 8;
switch( self->attributes[i]->type )
{
case GL_BOOL: j=0; break;
case GL_BYTE: j=1; break;
case GL_UNSIGNED_BYTE: j=2; break;
case GL_SHORT: j=3; break;
case GL_UNSIGNED_SHORT: j=4; break;
case GL_INT: j=5; break;
case GL_UNSIGNED_INT: j=6; break;
case GL_FLOAT: j=7; break;
default: j=8; break;
}
fprintf(stderr, "%s : %dx%s (+%p)\n",
self->attributes[i]->name,
self->attributes[i]->size,
gltypes[j],
self->attributes[i]->pointer);

i += 1;
}
}


// ----------------------------------------------------------------------------
void
vertex_buffer_upload ( vertex_buffer_t *self )
{
size_t vsize, isize;

if( self->state == FROZEN )
{
return;
}

if( !self->vertices_id )
{
glGenBuffers( 1, &self->vertices_id );
}
if( !self->indices_id )
{
glGenBuffers( 1, &self->indices_id );
}

vsize = self->vertices->size*self->vertices->item_size;
isize = self->indices->size*self->indices->item_size;


// Always upload vertices first such that indices do not point to non
// existing data (if we get interrupted in between for example).

// Upload vertices
glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );
if( vsize != self->GPU_vsize )
{
glBufferData( GL_ARRAY_BUFFER,
vsize, self->vertices->items, GL_DYNAMIC_DRAW );
self->GPU_vsize = vsize;
}
else
{
glBufferSubData( GL_ARRAY_BUFFER,
0, vsize, self->vertices->items );
}
glBindBuffer( GL_ARRAY_BUFFER, 0 );

// Upload indices
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
if( isize != self->GPU_isize )
{
glBufferData( GL_ELEMENT_ARRAY_BUFFER,
isize, self->indices->items, GL_DYNAMIC_DRAW );
self->GPU_isize = isize;
}
else
{
glBufferSubData( GL_ELEMENT_ARRAY_BUFFER,
0, isize, self->indices->items );
}
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
}



// ----------------------------------------------------------------------------
void
vertex_buffer_clear( vertex_buffer_t *self )
{
assert( self );

self->state = FROZEN;
vector_clear( self->indices );
vector_clear( self->vertices );
vector_clear( self->items );
self->state = DIRTY;
}



// ----------------------------------------------------------------------------
void
vertex_buffer_render_setup ( vertex_buffer_t *self, GLenum mode )
{
size_t i;

#ifdef FREETYPE_GL_USE_VAO
// Unbind so no existing VAO-state is overwritten,
// (e.g. the GL_ELEMENT_ARRAY_BUFFER-binding).
glBindVertexArray( 0 );
#endif

if( self->state != CLEAN )
{
vertex_buffer_upload( self );
self->state = CLEAN;
}

#ifdef FREETYPE_GL_USE_VAO
if( self->VAO_id == 0 )
{
// Generate and set up VAO

glGenVertexArrays( 1, &self->VAO_id );
glBindVertexArray( self->VAO_id );

glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );

for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i )
{
vertex_attribute_t *attribute = self->attributes[i];
if( attribute == 0 )
{
continue;
}
else
{
vertex_attribute_enable( attribute );
}
}

glBindBuffer( GL_ARRAY_BUFFER, 0 );

if( self->indices->size )
{
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
}
}

// Bind VAO for drawing
glBindVertexArray( self->VAO_id );
#else

glBindBuffer( GL_ARRAY_BUFFER, self->vertices_id );

for( i=0; i<MAX_VERTEX_ATTRIBUTE; ++i )
{
vertex_attribute_t *attribute = self->attributes[i];
if ( attribute == 0 )
{
continue;
}
else
{
vertex_attribute_enable( attribute );
}
}

if( self->indices->size )
{
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self->indices_id );
}
#endif

self->mode = mode;
}

// ----------------------------------------------------------------------------
void
vertex_buffer_render_finish ( vertex_buffer_t *self )
{
#ifdef FREETYPE_GL_USE_VAO
glBindVertexArray( 0 );
#else
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
#endif
}


// ----------------------------------------------------------------------------
void
vertex_buffer_render_item ( vertex_buffer_t *self,
size_t index )
{
ivec4 * item = (ivec4 *) vector_get( self->items, index );
assert( self );
assert( index < vector_size( self->items ) );

if( self->indices->size )
{
size_t start = item->istart;
size_t count = item->icount;
glDrawElements( self->mode, count, GL_UNSIGNED_INT, (void *)(start*sizeof(GLuint)) );
}
else if( self->vertices->size )
{
size_t start = item->vstart;
size_t count = item->vcount;
glDrawArrays( self->mode, start*self->vertices->item_size, count);
}
}


// ----------------------------------------------------------------------------
void
vertex_buffer_render ( vertex_buffer_t *self, GLenum mode )
{
size_t vcount = self->vertices->size;
size_t icount = self->indices->size;

vertex_buffer_render_setup( self, mode );
if( icount )
{
glDrawElements( mode, icount, GL_UNSIGNED_INT, 0 );
}
else
{
glDrawArrays( mode, 0, vcount );
}
vertex_buffer_render_finish( self );
}


// ----------------------------------------------------------------------------
void
vertex_buffer_push_back_indices ( vertex_buffer_t * self,
const GLuint * indices,
const size_t icount )
{
assert( self );

self->state |= DIRTY;
vector_push_back_data( self->indices, indices, icount );
}



// ----------------------------------------------------------------------------
void
vertex_buffer_push_back_vertices ( vertex_buffer_t * self,
const void * vertices,
const size_t vcount )
{
assert( self );

self->state |= DIRTY;
vector_push_back_data( self->vertices, vertices, vcount );
}



// ----------------------------------------------------------------------------
void
vertex_buffer_insert_indices ( vertex_buffer_t *self,
const size_t index,
const GLuint *indices,
const size_t count )
{
assert( self );
assert( self->indices );
assert( index < self->indices->size+1 );

self->state |= DIRTY;
vector_insert_data( self->indices, index, indices, count );
}



// ----------------------------------------------------------------------------
void
vertex_buffer_insert_vertices( vertex_buffer_t *self,
const size_t index,
const void *vertices,
const size_t vcount )
{
size_t i;
assert( self );
assert( self->vertices );
assert( index < self->vertices->size+1 );

self->state |= DIRTY;

for( i=0; i<self->indices->size; ++i )
{
if( *(GLuint *)(vector_get( self->indices, i )) > index )
{
*(GLuint *)(vector_get( self->indices, i )) += index;
}
}

vector_insert_data( self->vertices, index, vertices, vcount );
}



// ----------------------------------------------------------------------------
void
vertex_buffer_erase_indices( vertex_buffer_t *self,
const size_t first,
const size_t last )
{
assert( self );
assert( self->indices );
assert( first < self->indices->size );
assert( (last) <= self->indices->size );

self->state |= DIRTY;
vector_erase_range( self->indices, first, last );
}



// ----------------------------------------------------------------------------
void
vertex_buffer_erase_vertices( vertex_buffer_t *self,
const size_t first,
const size_t last )
{
size_t i;
assert( self );
assert( self->vertices );
assert( first < self->vertices->size );
assert( (first+last) <= self->vertices->size );
assert( last > first );

self->state |= DIRTY;
for( i=0; i<self->indices->size; ++i )
{
if( *(GLuint *)(vector_get( self->indices, i )) > first )
{
*(GLuint *)(vector_get( self->indices, i )) -= (last-first);
}
}
vector_erase_range( self->vertices, first, last );
}



// ----------------------------------------------------------------------------
size_t
vertex_buffer_push_back( vertex_buffer_t * self,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount )
{
return vertex_buffer_insert( self, vector_size( self->items ),
vertices, vcount, indices, icount );
}

// ----------------------------------------------------------------------------
size_t
vertex_buffer_insert( vertex_buffer_t * self, const size_t index,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount )
{
size_t vstart, istart, i;
ivec4 item;
assert( self );
assert( vertices );
assert( indices );

self->state = FROZEN;

// Push back vertices
vstart = vector_size( self->vertices );
vertex_buffer_push_back_vertices( self, vertices, vcount );

// Push back indices
istart = vector_size( self->indices );
vertex_buffer_push_back_indices( self, indices, icount );

// Update indices within the vertex buffer
for( i=0; i<icount; ++i )
{
*(GLuint *)(vector_get( self->indices, istart+i )) += vstart;
}
// Insert item
item.x = vstart;
item.y = vcount;
item.z = istart;
item.w = icount;
vector_insert( self->items, index, &item );

self->state = DIRTY;
return index;
}

// ----------------------------------------------------------------------------
void
vertex_buffer_erase( vertex_buffer_t * self,
const size_t index )
{
ivec4 * item;
size_t vstart, vcount, istart, icount, i;
assert( self );
assert( index < vector_size( self->items ) );

item = (ivec4 *) vector_get( self->items, index );
vstart = item->vstart;
vcount = item->vcount;
istart = item->istart;
icount = item->icount;

// Update items
for( i=0; i<vector_size(self->items); ++i )
{
ivec4 * item = (ivec4 *) vector_get( self->items, i );
if( item->vstart > vstart)
{
item->vstart -= vcount;
item->istart -= icount;
}
}

self->state = FROZEN;
vertex_buffer_erase_indices( self, istart, istart+icount );
vertex_buffer_erase_vertices( self, vstart, vstart+vcount );
vector_erase( self->items, index );
self->state = DIRTY;
}

+ 0
- 350
dgl/src/freetype-gl/vertex-buffer.h View File

@@ -1,350 +0,0 @@
/* ============================================================================
* Freetype GL - A C OpenGL Freetype engine
* Platform: Any
* WWW: http://code.google.com/p/freetype-gl/
* ----------------------------------------------------------------------------
* Copyright 2011,2012 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.
* ============================================================================
*/
#ifndef __VERTEX_BUFFER_H__
#define __VERTEX_BUFFER_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "opengl.h"
#include "vector.h"
#include "vertex-attribute.h"

/**
* @file vertex-buffer.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
* @date April, 2012
*
* @defgroup vertex-buffer Vertex buffer
*
* @{
*/


/**
* Generic vertex buffer.
*/
typedef struct vertex_buffer_t
{
/** Format of the vertex buffer. */
char * format;

/** Vector of vertices. */
vector_t * vertices;

#ifdef FREETYPE_GL_USE_VAO
/** GL identity of the Vertex Array Object */
GLuint VAO_id;
#endif

/** GL identity of the vertices buffer. */
GLuint vertices_id;

/** Vector of indices. */
vector_t * indices;

/** GL identity of the indices buffer. */
GLuint indices_id;

/** Current size of the vertices buffer in GPU */
size_t GPU_vsize;

/** Current size of the indices buffer in GPU*/
size_t GPU_isize;

/** GL primitives to render. */
GLenum mode;

/** Whether the vertex buffer needs to be uploaded to GPU memory. */
char state;

/** Individual items */
vector_t * items;

/** Array of attributes. */
vertex_attribute_t *attributes[MAX_VERTEX_ATTRIBUTE];
} vertex_buffer_t;


/**
* Creates an empty vertex buffer.
*
* @param format a string describing vertex format.
* @return an empty vertex buffer.
*/
vertex_buffer_t *
vertex_buffer_new( const char *format );


/**
* Deletes vertex buffer and releases GPU memory.
*
* @param self a vertex buffer
*/
void
vertex_buffer_delete( vertex_buffer_t * self );


/**
* Returns the number of items in the vertex buffer
*
* @param self a vertex buffer
* @return number of items
*/
size_t
vertex_buffer_size( const vertex_buffer_t *self );


/**
* Returns vertex format
*
* @param self a vertex buffer
* @return vertex format
*/
const char *
vertex_buffer_format( const vertex_buffer_t *self );


/**
* Print information about a vertex buffer
*
* @param self a vertex buffer
*/
void
vertex_buffer_print( vertex_buffer_t * self );


/**
* Prepare vertex buffer for render.
*
* @param self a vertex buffer
* @param mode render mode
*/
void
vertex_buffer_render_setup ( vertex_buffer_t *self,
GLenum mode );


/**
* Finish rendering by setting back modified states
*
* @param self a vertex buffer
*/
void
vertex_buffer_render_finish ( vertex_buffer_t *self );


/**
* Render vertex buffer.
*
* @param self a vertex buffer
* @param mode render mode
*/
void
vertex_buffer_render ( vertex_buffer_t *self,
GLenum mode );


/**
* Render a specified item from the vertex buffer.
*
* @param self a vertex buffer
* @param index index of the item to be rendered
*/
void
vertex_buffer_render_item ( vertex_buffer_t *self,
size_t index );


/**
* Upload buffer to GPU memory.
*
* @param self a vertex buffer
*/
void
vertex_buffer_upload( vertex_buffer_t *self );


/**
* Clear all items.
*
* @param self a vertex buffer
*/
void
vertex_buffer_clear( vertex_buffer_t *self );


/**
* Appends indices at the end of the buffer.
*
* @param self a vertex buffer
* @param indices indices to be appended
* @param icount number of indices to be appended
*
* @private
*/
void
vertex_buffer_push_back_indices ( vertex_buffer_t *self,
const GLuint * indices,
const size_t icount );


/**
* Appends vertices at the end of the buffer.
*
* @note Internal use
*
* @param self a vertex buffer
* @param vertices vertices to be appended
* @param vcount number of vertices to be appended
*
* @private
*/
void
vertex_buffer_push_back_vertices ( vertex_buffer_t *self,
const void * vertices,
const size_t vcount );


/**
* Insert indices in the buffer.
*
* @param self a vertex buffer
* @param index location before which to insert indices
* @param indices indices to be appended
* @param icount number of indices to be appended
*
* @private
*/
void
vertex_buffer_insert_indices ( vertex_buffer_t *self,
const size_t index,
const GLuint *indices,
const size_t icount );


/**
* Insert vertices in the buffer.
*
* @param self a vertex buffer
* @param index location before which to insert vertices
* @param vertices vertices to be appended
* @param vcount number of vertices to be appended
*
* @private
*/
void
vertex_buffer_insert_vertices ( vertex_buffer_t *self,
const size_t index,
const void *vertices,
const size_t vcount );

/**
* Erase indices in the buffer.
*
* @param self a vertex buffer
* @param first the index of the first index to be erased
* @param last the index of the last index to be erased
*
* @private
*/
void
vertex_buffer_erase_indices ( vertex_buffer_t *self,
const size_t first,
const size_t last );

/**
* Erase vertices in the buffer.
*
* @param self a vertex buffer
* @param first the index of the first vertex to be erased
* @param last the index of the last vertex to be erased
*
* @private
*/
void
vertex_buffer_erase_vertices ( vertex_buffer_t *self,
const size_t first,
const size_t last );


/**
* Append a new item to the collection.
*
* @param self a vertex buffer
* @param vcount number of vertices
* @param vertices raw vertices data
* @param icount number of indices
* @param indices raw indices data
*/
size_t
vertex_buffer_push_back( vertex_buffer_t * self,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount );


/**
* Insert a new item into the vertex buffer.
*
* @param self a vertex buffer
* @param index location before which to insert item
* @param vertices raw vertices data
* @param vcount number of vertices
* @param indices raw indices data
* @param icount number of indices
*/
size_t
vertex_buffer_insert( vertex_buffer_t * self,
const size_t index,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount );

/**
* Erase an item from the vertex buffer.
*
* @param self a vertex buffer
* @param index index of the item to be deleted
*/
void
vertex_buffer_erase( vertex_buffer_t * self,
const size_t index );

/** @} */

#ifdef __cplusplus
}
#endif

#endif /* __VERTEX_BUFFER_H__ */

+ 0
- 169
dgl/src/freetype/FTL.TXT View File

@@ -1,169 +0,0 @@
The FreeType Project LICENSE
----------------------------

2006-Jan-27

Copyright 1996-2002, 2006 by
David Turner, Robert Wilhelm, and Werner Lemberg



Introduction
============

The FreeType Project is distributed in several archive packages;
some of them may contain, in addition to the FreeType font engine,
various tools and contributions which rely on, or relate to, the
FreeType Project.

This license applies to all files found in such packages, and
which do not fall under their own explicit license. The license
affects thus the FreeType font engine, the test programs,
documentation and makefiles, at the very least.

This license was inspired by the BSD, Artistic, and IJG
(Independent JPEG Group) licenses, which all encourage inclusion
and use of free software in commercial and freeware products
alike. As a consequence, its main points are that:

o We don't promise that this software works. However, we will be
interested in any kind of bug reports. (`as is' distribution)

o You can use this software for whatever you want, in parts or
full form, without having to pay us. (`royalty-free' usage)

o You may not pretend that you wrote this software. If you use
it, or only parts of it, in a program, you must acknowledge
somewhere in your documentation that you have used the
FreeType code. (`credits')

We specifically permit and encourage the inclusion of this
software, with or without modifications, in commercial products.
We disclaim all warranties covering The FreeType Project and
assume no liability related to The FreeType Project.


Finally, many people asked us for a preferred form for a
credit/disclaimer to use in compliance with this license. We thus
encourage you to use the following text:

"""
Portions of this software are copyright © <year> The FreeType
Project (www.freetype.org). All rights reserved.
"""

Please replace <year> with the value from the FreeType version you
actually use.


Legal Terms
===========

0. Definitions
--------------

Throughout this license, the terms `package', `FreeType Project',
and `FreeType archive' refer to the set of files originally
distributed by the authors (David Turner, Robert Wilhelm, and
Werner Lemberg) as the `FreeType Project', be they named as alpha,
beta or final release.

`You' refers to the licensee, or person using the project, where
`using' is a generic term including compiling the project's source
code as well as linking it to form a `program' or `executable'.
This program is referred to as `a program using the FreeType
engine'.

This license applies to all files distributed in the original
FreeType Project, including all source code, binaries and
documentation, unless otherwise stated in the file in its
original, unmodified form as distributed in the original archive.
If you are unsure whether or not a particular file is covered by
this license, you must contact us to verify this.

The FreeType Project is copyright (C) 1996-2000 by David Turner,
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
specified below.

1. No Warranty
--------------

THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
USE, OF THE FREETYPE PROJECT.

2. Redistribution
-----------------

This license grants a worldwide, royalty-free, perpetual and
irrevocable right and license to use, execute, perform, compile,
display, copy, create derivative works of, distribute and
sublicense the FreeType Project (in both source and object code
forms) and derivative works thereof for any purpose; and to
authorize others to exercise some or all of the rights granted
herein, subject to the following conditions:

o Redistribution of source code must retain this license file
(`FTL.TXT') unaltered; any additions, deletions or changes to
the original files must be clearly indicated in accompanying
documentation. The copyright notices of the unaltered,
original files must be preserved in all copies of source
files.

o Redistribution in binary form must provide a disclaimer that
states that the software is based in part of the work of the
FreeType Team, in the distribution documentation. We also
encourage you to put an URL to the FreeType web page in your
documentation, though this isn't mandatory.

These conditions apply to any software derived from or based on
the FreeType Project, not just the unmodified files. If you use
our work, you must acknowledge us. However, no fee need be paid
to us.

3. Advertising
--------------

Neither the FreeType authors and contributors nor you shall use
the name of the other for commercial, advertising, or promotional
purposes without specific prior written permission.

We suggest, but do not require, that you use one or more of the
following phrases to refer to this software in your documentation
or advertising materials: `FreeType Project', `FreeType Engine',
`FreeType library', or `FreeType Distribution'.

As you have not signed this license, you are not required to
accept it. However, as the FreeType Project is copyrighted
material, only this license, or another one contracted with the
authors, grants you the right to use, distribute, and modify it.
Therefore, by using, distributing, or modifying the FreeType
Project, you indicate that you understand and accept all the terms
of this license.

4. Contacts
-----------

There are two mailing lists related to FreeType:

o freetype@nongnu.org

Discusses general use and applications of FreeType, as well as
future and wanted additions to the library and distribution.
If you are looking for support, start in this list if you
haven't found anything to help you in the documentation.

o freetype-devel@nongnu.org

Discusses bugs, as well as engine internals, design issues,
specific licenses, porting, etc.

Our home page can be found at

http://www.freetype.org


--- end of FTL.TXT ---

+ 0
- 166730
dgl/src/freetype/FreeTypeAmalgam.c
File diff suppressed because it is too large
View File


+ 0
- 10275
dgl/src/freetype/FreeTypeAmalgam.h
File diff suppressed because it is too large
View File


+ 0
- 340
dgl/src/freetype/GPLv2.TXT View File

@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

+ 0
- 34
dgl/src/freetype/LICENSE.TXT View File

@@ -1,34 +0,0 @@

The FreeType 2 font engine is copyrighted work and cannot be used
legally without a software license. In order to make this project
usable to a vast majority of developers, we distribute it under two
mutually exclusive open-source licenses.

This means that *you* must choose *one* of the two licenses described
below, then obey all its terms and conditions when using FreeType 2 in
any of your projects or products.

- The FreeType License, found in the file `FTL.TXT', which is similar
to the original BSD license *with* an advertising clause that forces
you to explicitly cite the FreeType project in your product's
documentation. All details are in the license file. This license
is suited to products which don't use the GNU General Public
License.

Note that this license is compatible to the GNU General Public
License version 3, but not version 2.

- The GNU General Public License version 2, found in `GPLv2.TXT' (any
later version can be used also), for programs which already use the
GPL. Note that the FTL is incompatible with GPLv2 due to its
advertisement clause.

The contributed BDF and PCF drivers come with a license similar to that
of the X Window System. It is compatible to the above two licenses (see
file src/bdf/README and src/pcf/README).

The gzip module uses the zlib license (see src/gzip/zlib.h) which too is
compatible to the above two licenses.


--- end of LICENSE.TXT ---

+ 0
- 36
dgl/src/freetype/README.md View File

@@ -1,36 +0,0 @@
# FreeType 2.4.12 Amalgamation
A distribution of the [FreeType][1] library in amalgamated source code form.
## What's an amalgamation?
An amalgamation is simply a collection of header and source files that have been
concatenated together to form one or more very large files. In this form, they
are easy to add to your existing project as source files (rather than linking
as a library). They are also easier to redistribute if you are making an open
source application and don't want to have any external dependencies.
## What is FreeType?
FreeType 2 is a software font engine that is designed to be small,
efficient, highly customizable, and portable while capable of producing
high-quality output (glyph images). It can be used in graphics libraries,
display servers, font conversion tools, text image generation tools, and
many other products as well.
## How do I use this?
Add FreeTypeAmalgam.c to your existing project, include FreeTypeAmalgam.h
in the source files where you want to use FreeType, and that's it!
The [FreeType Amalgmation][4] was built using the [Amalgamate Templates][3].
## License
Copyright 2003-2007, 2011 by David Turner, Robert Wilhelm, and Werner Lemberg.<br>
FreeType is distributed under a dual license, see the file LICENSE.txt for details.
[1]: http://www.freetype.org "The FreeType Library"
[2]: http://rawmaterialsoftware.com/jucelicense.php "JUCE Commercial Licensing"
[3]: https://github.com/vinniefalco/Amalgams/ "Amalgamate Templates"
[4]: https://github.com/vinniefalco/FreeTypeAmalgam/ "FreeType Amalgamation"

Loading…
Cancel
Save