diff --git a/Makefile b/Makefile index f92089a2..a0f9510e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Platform: Any # WWW: http://code.google.com/p/freetype-gl/ # ------------------------------------------------------------------------- -# Copyright 2011,2012 Nicolas P. Rougier. All rights reserved. +# 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: diff --git a/README b/README index 62d12137..314fc6eb 100644 --- a/README +++ b/README @@ -59,4 +59,5 @@ Contributors: * bsoddd (Bug report & fix) * Jim Teeuwen (Bug report & fix) * quarnster (Bug report & fix) -* Per Inge Mathisen (Bug report @ fix) +* Per Inge Mathisen (Bug report & fix) +* Wojciech Mamrak (Code review, bug report & fix) diff --git a/demo-ansi.c b/demo-ansi.c index aaca4d54..7f7e8dc7 100644 --- a/demo-ansi.c +++ b/demo-ansi.c @@ -48,12 +48,12 @@ #endif -// ------------------------------------------------------- global variables --- +/* ------------------------------------------------------ global variables - */ text_buffer_t * buffer; mat4 model, view, projection; -// ---------------------------------------------------------------- display --- +/* --------------------------------------------------------------- display - */ void display( void ) { glClearColor(1.00,1.00,1.00,1.00); @@ -74,7 +74,7 @@ void display( void ) } -// --------------------------------------------------------------- reshape --- +/* -------------------------------------------------------------- reshape - */ void reshape(int width, int height) { glViewport(0, 0, width, height); @@ -82,7 +82,7 @@ void reshape(int width, int height) } -// --------------------------------------------------------------- keyboard --- +/* -------------------------------------------------------------- keyboard - */ void keyboard( unsigned char key, int x, int y ) { if ( key == 27 ) @@ -92,7 +92,7 @@ void keyboard( unsigned char key, int x, int y ) } -// ------------------------------------------------------------ init_colors --- +/* ----------------------------------------------------------- init_colors - */ void init_colors( vec4 *colors ) { @@ -116,18 +116,18 @@ init_colors( vec4 *colors ) {{238/256.0f, 238/256.0f, 236/256.0f, 1.0f}} }; size_t i = 0; - // Default 16 colors + /* Default 16 colors */ for( i=0; i< 16; ++i ) { colors[i] = defaults[i]; } - // Color cube + /* Color cube */ for( i=0; i<6*6*6; i++ ) { vec4 color = {{ (i/6/6)/5.0f, ((i/6)%6)/5.0f, (i%6)/5.0f, 1.0f}}; colors[i+16] = color; } - // Grascale ramp (24 tones) + /* Grascale ramp (24 tones) */ for( i=0; i<24; i++ ) { vec4 color ={{i/24.0f, i/24.0f, i/24.0f, 1.0f}}; @@ -136,7 +136,7 @@ init_colors( vec4 *colors ) } -// --------------------------------------------------------- ansi_to_markup --- +/* -------------------------------------------------------- ansi_to_markup - */ void ansi_to_markup( wchar_t *sequence, size_t length, markup_t *markup ) { @@ -198,12 +198,12 @@ ansi_to_markup( wchar_t *sequence, size_t length, markup_t *markup ) set_bg = 1; code = 0; } - // Set fg color (30 + x, where x is the index of the color) + /* Set fg color (30 + x, where x is the index of the color) */ else if( (code >= 30) && (code < 38 ) ) { markup->foreground_color = colors[code-30]; } - // Set bg color (40 + x, where x is the index of the color) + /* Set bg color (40 + x, where x is the index of the color) */ else if( (code >= 40) && (code < 48 ) ) { markup->background_color = colors[code-40]; @@ -251,7 +251,7 @@ ansi_to_markup( wchar_t *sequence, size_t length, markup_t *markup ) markup->outline_color = markup->foreground_color; } -// ------------------------------------------------------------------ print --- +/* ----------------------------------------------------------------- print - */ void print( text_buffer_t * buffer, vec2 * pen, wchar_t *text, markup_t *markup ) @@ -295,7 +295,7 @@ print( text_buffer_t * buffer, vec2 * pen, } -// ------------------------------------------------------------------- main --- +/* ------------------------------------------------------------------ main - */ int main( int argc, char **argv ) { glutInit( &argc, argv ); diff --git a/edtaa3func.c b/edtaa3func.c index 3bec8688..c43a4e4d 100644 --- a/edtaa3func.c +++ b/edtaa3func.c @@ -56,7 +56,7 @@ * */ #include - +#include "edtaa3func.h" /* * Compute the local gradient at edge pixels using convolution filters. diff --git a/mat4.c b/mat4.c index 28d0299b..509de106 100644 --- a/mat4.c +++ b/mat4.c @@ -37,6 +37,9 @@ #include #include "mat4.h" +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif mat4 * mat4_new( void ) diff --git a/platform.c b/platform.c index 351b4b23..469d6b2f 100644 --- a/platform.c +++ b/platform.c @@ -31,6 +31,7 @@ * policies, either expressed or implied, of Nicolas P. Rougier. * ============================================================================ */ +#include #include "platform.h" #if defined(_WIN32) || defined(_WIN64) @@ -42,4 +43,23 @@ float round (float v) return floor(v+0.5f); } -#endif // _WIN32 || _WIN64 +// strndup() is not available on Windows +char *strndup( const char *s1, size_t n) +{ + char *copy= (char*)malloc( n+1 ); + memcpy( copy, s1, n ); + copy[n] = 0; + return copy; +}; +#endif + + +// strndup() was only added in OSX lion +#if defined(__APPLE__) +char *strndup( const char *s1, size_t n) +{ + char *copy = calloc( n+1, sizeof(char) ); + memcpy( copy, s1, n ); + return copy; +}; +#endif diff --git a/platform.h b/platform.h index 69dbda81..e2234d0b 100644 --- a/platform.h +++ b/platform.h @@ -34,6 +34,8 @@ #ifndef __PLATFORM_H__ #define __PLATFORM_H__ +#include + //------------------------------------------------- // stdint.h is not available on VS2008 or lower //------------------------------------------------- @@ -46,24 +48,22 @@ typedef unsigned __int64 uint64_t; #include #endif // _MSC_VER -#if defined(_WIN32) || defined(_WIN64) - -//------------------------------------------------- -// Functions not supported by VS -//------------------------------------------------- #ifdef __cplusplus extern "C" { #endif -float round (float v); +#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); + float round (float v); +# pragma warning (disable: 4244) // suspend warnings +#endif // _WIN32 || _WIN64 #ifdef __cplusplus } #endif // __cplusplus -// suspend warnings -#pragma warning (disable: 4244) - -#endif // _WIN32 || _WIN64 - #endif /* __PLATFORM_H__ */ diff --git a/shader.h b/shader.h index 378acdbc..ef0c6cbd 100644 --- a/shader.h +++ b/shader.h @@ -1,35 +1,36 @@ -// ---------------------------------------------------------------------------- -// 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. -// ---------------------------------------------------------------------------- +/* ============================================================================ + * 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__ @@ -113,4 +114,4 @@ extern "C" { } #endif -#endif // __SHADER_H__ +#endif /* __SHADER_H__ */ diff --git a/texture-font.c b/texture-font.c index aaf5708b..b83ffc1d 100644 --- a/texture-font.c +++ b/texture-font.c @@ -42,6 +42,7 @@ #include #include #include +#include "platform.h" #include "texture-font.h" #undef __FTERRORS_H__ diff --git a/vec234.h b/vec234.h index 2442dda5..a473859b 100644 --- a/vec234.h +++ b/vec234.h @@ -3,7 +3,7 @@ * Platform: Any * WWW: http://code.google.com/p/freetype-gl/ * ---------------------------------------------------------------------------- - * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved. + * 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: diff --git a/vertex-attribute.c b/vertex-attribute.c index 94d7fd1c..745ffbbc 100644 --- a/vertex-attribute.c +++ b/vertex-attribute.c @@ -36,6 +36,7 @@ #include #include #include "vec234.h" +#include "platform.h" #include "vertex-attribute.h" diff --git a/vertex-buffer.c b/vertex-buffer.c index 040b4bb9..36c5cb8a 100644 --- a/vertex-buffer.c +++ b/vertex-buffer.c @@ -36,31 +36,10 @@ #include #include #include "vec234.h" +#include "platform.h" #include "vertex-buffer.h" -// strndup() was only added in OSX lion -#ifdef __APPLE__ -char * -strndup( const char *s1, size_t n) -{ - char *copy = calloc( n+1, sizeof(char) ); - memcpy( copy, s1, n ); - return copy; -}; -#elif defined(_WIN32) || defined(_WIN64) - // strndup() is not available on Windows, too -char * -strndup( const char *s1, size_t n) -{ - char *copy= (char*)malloc( n+1 ); - memcpy( copy, s1, n ); - copy[n] = 0; - return copy; -}; -#endif - - /** * Buffer status */