Skip to content

Commit

Permalink
Fix various issue (see issue 45)
Browse files Browse the repository at this point in the history
  • Loading branch information
rougier committed Feb 4, 2013
1 parent d1e1efd commit 8d87f1a
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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)
26 changes: 13 additions & 13 deletions demo-ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -74,15 +74,15 @@ void display( void )
}


// --------------------------------------------------------------- reshape ---
/* -------------------------------------------------------------- reshape - */
void reshape(int width, int height)
{
glViewport(0, 0, width, height);
mat4_set_orthographic( &projection, 0, width, 0, height, -1, 1);
}


// --------------------------------------------------------------- keyboard ---
/* -------------------------------------------------------------- keyboard - */
void keyboard( unsigned char key, int x, int y )
{
if ( key == 27 )
Expand All @@ -92,7 +92,7 @@ void keyboard( unsigned char key, int x, int y )
}


// ------------------------------------------------------------ init_colors ---
/* ----------------------------------------------------------- init_colors - */
void
init_colors( vec4 *colors )
{
Expand All @@ -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}};
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -295,7 +295,7 @@ print( text_buffer_t * buffer, vec2 * pen,
}


// ------------------------------------------------------------------- main ---
/* ------------------------------------------------------------------ main - */
int main( int argc, char **argv )
{
glutInit( &argc, argv );
Expand Down
2 changes: 1 addition & 1 deletion edtaa3func.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*
*/
#include <math.h>

#include "edtaa3func.h"

/*
* Compute the local gradient at edge pixels using convolution filters.
Expand Down
3 changes: 3 additions & 0 deletions mat4.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <math.h>
#include "mat4.h"

#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif

mat4 *
mat4_new( void )
Expand Down
22 changes: 21 additions & 1 deletion platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* policies, either expressed or implied, of Nicolas P. Rougier.
* ============================================================================
*/
#include <string.h>
#include "platform.h"

#if defined(_WIN32) || defined(_WIN64)
Expand All @@ -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
22 changes: 11 additions & 11 deletions platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#ifndef __PLATFORM_H__
#define __PLATFORM_H__

#include <stdlib.h>

//-------------------------------------------------
// stdint.h is not available on VS2008 or lower
//-------------------------------------------------
Expand All @@ -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__ */
67 changes: 34 additions & 33 deletions shader.h
Original file line number Diff line number Diff line change
@@ -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__

Expand Down Expand Up @@ -113,4 +114,4 @@ extern "C" {
}
#endif

#endif // __SHADER_H__
#endif /* __SHADER_H__ */
1 change: 1 addition & 0 deletions texture-font.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <assert.h>
#include <math.h>
#include <wchar.h>
#include "platform.h"
#include "texture-font.h"

#undef __FTERRORS_H__
Expand Down
2 changes: 1 addition & 1 deletion vec234.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions vertex-attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "vec234.h"
#include "platform.h"
#include "vertex-attribute.h"


Expand Down
23 changes: 1 addition & 22 deletions vertex-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 8d87f1a

Please sign in to comment.