Commit 6a9756ae authored by andystanton's avatar andystanton

Add ftgl namespace.

Implementation of the idea discussed by @Trouvist and @rougier in
rougier/freetype-gl#40.
 * Added ftgl namespace in all freetype-gl headers, guarded by ```ifdef __cplusplus```
 * Using this namespace by default in freetype-gl.h
 * Allow override of the default with NOT_USING_FT_GL_NAMESPACE
parent 14b0e660
......@@ -31,3 +31,6 @@ fonts/Verdana.ttf
CMakeFiles
CMakeCache.txt
*.o
libfreetype-gl.a
demo-make
cmake_install.cmake
......@@ -34,6 +34,7 @@
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
typedef struct
......@@ -69,7 +70,7 @@ typedef struct
} texture_font_t;
texture_font_t font = {
128, 128, 1,
128, 128, 1,
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
......@@ -581,8 +582,8 @@ texture_font_t font = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
16.000000f, 18.400000f, 0.530000f, 14.480000f, -3.390000f, 96,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
16.000000f, 18.400000f, 0.530000f, 14.480000f, -3.390000f, 96,
{
{L'\0', 0, 0, 0, 0, 0.000000f, 0.000000f, 0.023438f, 0.023438f, 0.031250f, 0.031250f, 0, { } },
{L' ', 0, 0, 0, 0, 4.453125f, 0.000000f, 0.046875f, 0.007812f, 0.046875f, 0.007812f, 5, { {L'A', -0.882812f}, {L'L', -0.593750f}, {L'P', -0.289062f}, {L'T', -0.289062f}, {L'Y', -0.289062f}} },
......@@ -684,4 +685,5 @@ texture_font_t font = {
};
#ifdef __cplusplus
}
}
#endif
......@@ -65,6 +65,9 @@ extern "C" {
#include <math.h>
#ifdef __cplusplus
namespace ftgl {
#endif
/*
* Compute the local gradient at edge pixels using convolution filters.
......@@ -95,6 +98,7 @@ void edtaa3(double *img, double *gx, double *gy, int w, int h, short *distx, sho
#ifdef __cplusplus
}
}
#endif
#endif // __EDTAA3FUNC_H__
......@@ -43,6 +43,10 @@ extern "C" {
#include "texture-font.h"
#include "texture-atlas.h"
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* @file font-manager.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
......@@ -199,7 +203,7 @@ typedef struct font_manager_t {
#ifdef __cplusplus
}
}
#endif // ifdef __cplusplus
#endif /* __FONT_MANAGER_H__ */
......@@ -41,4 +41,10 @@
#include "texture-atlas.h"
#include "texture-font.h"
#ifdef __cplusplus
#ifndef NOT_USING_FT_GL_NAMESPACE
using namespace ftgl;
#endif /* NOT_USING_FT_GL_NAMESPACE */
#endif /* __cplusplus */
#endif /* FREETYPE_GL_H */
......@@ -36,6 +36,7 @@
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
......@@ -112,6 +113,7 @@ mat4_scale( mat4 *self,
#ifdef __cplusplus
}
}
#endif
#endif /* __MAT4_H__ */
......@@ -50,12 +50,13 @@ typedef unsigned __int64 uint64_t;
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
#ifdef __APPLE__
/* strndup() was only added in OSX lion */
char * strndup( const char *s1, size_t n);
#elif defined(_WIN32) || defined(_WIN64)
#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
......@@ -66,6 +67,7 @@ extern "C" {
#ifdef __cplusplus
}
}
#endif // __cplusplus
#endif /* __PLATFORM_H__ */
......@@ -4,17 +4,17 @@
* 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
......@@ -25,7 +25,7 @@
* 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.
......@@ -38,6 +38,7 @@
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
/**
......@@ -114,6 +115,7 @@ extern "C" {
#ifdef __cplusplus
}
}
#endif
#endif /* __SHADER_H__ */
......@@ -43,6 +43,9 @@ extern "C" {
#include "markup.h"
#include "shader.h"
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* Use LCD filtering
......@@ -80,12 +83,12 @@ extern "C" {
*/
typedef struct text_buffer_t {
/**
* Vertex buffer
* Vertex buffer
*/
vertex_buffer_t *buffer;
/**
* Font manager
* Font manager
*/
font_manager_t *manager;
......@@ -280,6 +283,7 @@ text_buffer_delete( text_buffer_t * self );
#ifdef __cplusplus
}
}
#endif
#endif /* #define __TEXT_BUFFER_H__ */
......@@ -53,6 +53,10 @@ extern "C" {
#include "vector.h"
#include "vec234.h"
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* @file texture-atlas.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
......@@ -220,6 +224,7 @@ typedef struct texture_atlas_t
#ifdef __cplusplus
}
}
#endif
#endif /* __TEXTURE_ATLAS_H__ */
......@@ -43,6 +43,10 @@ extern "C" {
#include "vector.h"
#include "texture-atlas.h"
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* @file texture-font.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
......@@ -78,7 +82,7 @@ typedef struct kerning_t
* Left character code in the kern pair.
*/
wchar_t charcode;
/**
* Kerning value (in fractional pixels).
*/
......@@ -96,26 +100,26 @@ typedef struct kerning_t
* 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:::::::::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 | | |
* | | gg::::::::::::::g | | |
* baseline ---*---------|---- gggggggg::::::g-----*-------- |
* / | | g:::::g | |
* origin | | gggggg g:::::g | |
* | | g:::::gg gg:::::g | |
* | | g::::::ggg:::::::g | |
* | | gg:::::::::::::g | |
* | | ggg::::::ggg | |
* / | | g:::::g | |
* origin | | gggggg g:::::g | |
* | | g:::::gg gg:::::g | |
* | | g::::::ggg:::::::g | |
* | | gg:::::::::::::g | |
* | | ggg::::::ggg | |
* | | gggggg | v
* | +-------------------------+----------------- ymin
* | |
......@@ -227,7 +231,7 @@ typedef struct texture_font_t
* Atlas structure to store glyphs data.
*/
texture_atlas_t * atlas;
/**
* font location
*/
......@@ -255,7 +259,7 @@ typedef struct texture_font_t
* Font size
*/
float size;
/**
* Whether to use autohint when rendering font
*/
......@@ -271,7 +275,7 @@ typedef struct texture_font_t
*/
float outline_thickness;
/**
/**
* Whether to use our own lcd filter.
*/
int filtering;
......@@ -392,7 +396,7 @@ typedef struct texture_font_t
/**
* Request a new glyph from the font. If it has not been created yet, it will
* be.
* be.
*
* @param self A valid texture font
* @param charcode Character codepoint to be loaded.
......@@ -424,10 +428,10 @@ typedef struct texture_font_t
*
* @param self a valid texture glyph
* @param charcode codepoint of the peceding glyph
*
*
* @return x kerning value
*/
float
float
texture_glyph_get_kerning( const texture_glyph_t * self,
const wchar_t charcode );
......@@ -445,7 +449,7 @@ texture_glyph_new( void );
#ifdef __cplusplus
}
}
#endif
#endif /* __TEXTURE_FONT_H__ */
......@@ -36,6 +36,7 @@
#ifdef __cplusplus
extern "C" {
namespace ftgl {
#endif
......@@ -232,6 +233,7 @@ typedef union
#ifdef __cplusplus
}
}
#endif
#endif /* __VEC234_H__ */
......@@ -42,6 +42,10 @@ extern "C" {
#include <stddef.h>
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* @file vector.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
......@@ -62,7 +66,7 @@ extern "C" {
* int i,j = 1;
* vector_t * vector = vector_new( sizeof(int) );
* vector_push_back( &i );
*
*
* j = * (int *) vector_get( vector, 0 );
* vector_delete( vector);
*
......@@ -329,7 +333,7 @@ typedef struct vector_t
*/
void
vector_push_back_data( vector_t *self,
const void * data,
const void * data,
const size_t count );
......@@ -348,6 +352,7 @@ typedef struct vector_t
#ifdef __cplusplus
}
}
#endif
#endif /* __VECTOR_H__ */
......@@ -41,6 +41,9 @@ extern "C" {
#include "opengl.h"
#include "vector.h"
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* @file vertex-attribute.h
......@@ -102,7 +105,7 @@ extern "C" {
* </tr>
* <tr>
* <td> Generic attribute </td>
* <td> "[0-15]g(n)?[1234][bBsSiIfd]" </td>
* <td> "[0-15]g(n)?[1234][bBsSiIfd]" </td>
* <td> </td>
* </tr>
* </table>
......@@ -112,47 +115,47 @@ extern "C" {
* <table>
* <tr>
* <th> Format </th>
* <th> Type </th>
* <th> Type </th>
* <th> GL Type </th>
* </tr>
* <tr>
* <td> "b" </td>
* <td> Signed byte </td>
* <td> Signed byte </td>
* <td> GL_BYTE </td>
* </tr>
* <tr>
* <td> "B" </td>
* <td> Unsigned byte </td>
* <td> Unsigned byte </td>
* <td> GL_UNSIGNED_BYTE </td>
* </tr>
* <tr>
* <td> "s" </td>
* <td> Signed short </td>
* <td> Signed short </td>
* <td> GL_SHORT </td>
* </tr>
* <tr>
* <td> "S" </td>
* <td> Unsigned short </td>
* <td> Unsigned short </td>
* <td> GL_UNSIGNED_SHORT </td>
* </tr>
* <tr>
* <td> "i" </td>
* <td> Signed int </td>
* <td> Signed int </td>
* <td> GL_INT </td>
* </tr>
* <tr>
* <td> "I" </td>
* <td> Unsigned int </td>
* <td> Unsigned int </td>
* <td> GL_UNSIGNED_INT </td>
* </tr>
* <tr>
* <td> "f" </td>
* <td> Float </td>
* <td> Float </td>
* <td> GL_FLOAT </td>
* </tr>
* <tr>
* <td> "d" </td>
* <td> Double </td>
* <td> Double </td>
* <td> GL_DOUBLE T </td>
* </tr>
* </table>
......@@ -215,7 +218,7 @@ typedef struct vertex_attribute_t
*/
GLint size;
/**
/**
* data type of each component in the array.
*
* Symbolic constants GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT,
......@@ -315,6 +318,7 @@ vertex_attribute_delete( vertex_attribute_t * self );
#ifdef __cplusplus
}
}
#endif
#endif /* __VERTEX_ATTRIBUTE_H__ */
......@@ -42,6 +42,10 @@ extern "C" {
#include "vector.h"
#include "vertex-attribute.h"
#ifdef __cplusplus
namespace ftgl {
#endif
/**
* @file vertex-buffer.h
* @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
......@@ -181,7 +185,7 @@ typedef struct vertex_buffer_t
* Render a specified item from the vertex buffer.
*
* @param self a vertex buffer
* @param index index of the item to be rendered
* @param index index of the item to be rendered
*/
void
vertex_buffer_render_item ( vertex_buffer_t *self,
......@@ -311,7 +315,7 @@ typedef struct vertex_buffer_t
*/
size_t
vertex_buffer_push_back( vertex_buffer_t * self,
const void * vertices, const size_t vcount,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount );
......@@ -328,7 +332,7 @@ typedef struct vertex_buffer_t
size_t
vertex_buffer_insert( vertex_buffer_t * self,
const size_t index,
const void * vertices, const size_t vcount,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount );
/**
......@@ -345,6 +349,7 @@ typedef struct vertex_buffer_t
#ifdef __cplusplus
}
}
#endif
#endif /* __VERTEX_BUFFER_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment