Commit 8d87f1a5 authored by Nicolas.Rougier's avatar Nicolas.Rougier

Fix various issue (see issue 45)

parent d1e1efdb
......@@ -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:
......
......@@ -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)
......@@ -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 );
......
......@@ -56,7 +56,7 @@
*
*/
#include <math.h>
#include "edtaa3func.h"
/*
* Compute the local gradient at edge pixels using convolution filters.
......
......@@ -37,6 +37,9 @@
#include <math.h>
#include "mat4.h"
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
mat4 *
mat4_new( void )
......
......@@ -31,6 +31,7 @@
* policies, either expressed or implied, of Nicolas P. Rougier.
* ============================================================================
*/
#include <string.h>
#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
......@@ -34,6 +34,8 @@
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#include <stdlib.h>
//-------------------------------------------------
// stdint.h is not available on VS2008 or lower
//-------------------------------------------------
......@@ -46,24 +48,22 @@ typedef unsigned __int64 uint64_t;
#include <stdint.h>
#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__ */
// ----------------------------------------------------------------------------
// 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__ */
......@@ -42,6 +42,7 @@
#include <assert.h>
#include <math.h>
#include <wchar.h>
#include "platform.h"
#include "texture-font.h"
#undef __FTERRORS_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:
......
......@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "vec234.h"
#include "platform.h"
#include "vertex-attribute.h"
......
......@@ -36,31 +36,10 @@
#include <stdlib.h>
#include <stdio.h>
#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
*/
......
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