Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions demos/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ GLuint text_shader;

// ------------------------------------------------------------ init_colors ---
void
init_colors( vec4 *colors )
init_colors( ftgl_vec4 *colors )
{
vec4 defaults[16] =
ftgl_vec4 defaults[16] =
{
{{ 46/256.0f, 52/256.0f, 54/256.0f, 1.0f}},
{{204/256.0f, 0/256.0f, 0/256.0f, 1.0f}},
Expand Down Expand Up @@ -58,13 +58,13 @@ init_colors( vec4 *colors )
/* 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}};
ftgl_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) */
for( i=0; i<24; i++ )
{
vec4 color ={{i/24.0f, i/24.0f, i/24.0f, 1.0f}};
ftgl_vec4 color ={{i/24.0f, i/24.0f, i/24.0f, 1.0f}};
colors[232+i] = color;
}
}
Expand All @@ -78,12 +78,12 @@ ansi_to_markup( char *sequence, size_t length, markup_t *markup )
int code = 0;
int set_bg = -1;
int set_fg = -1;
vec4 none = {{0,0,0,0}};
static vec4 * colors = 0;
ftgl_vec4 none = {{0,0,0,0}};
static ftgl_vec4 * colors = 0;

if( colors == 0 )
{
colors = (vec4 *) malloc( sizeof(vec4) * 256 );
colors = (ftgl_vec4 *) malloc( sizeof(ftgl_vec4) * 256 );
init_colors( colors );
}

Expand Down Expand Up @@ -205,7 +205,7 @@ ansi_to_markup( char *sequence, size_t length, markup_t *markup )

// ------------------------------------------------------------------ print ---
void
print( text_buffer_t * buffer, vec2 * pen,
print( text_buffer_t * buffer, ftgl_vec2 * pen,
char *text, markup_t *markup )
{
char *seq_start = text, *seq_end = text;
Expand Down Expand Up @@ -257,8 +257,8 @@ void init( void )
font_manager = font_manager_new( 512, 512, LCD_FILTERING_OFF );
buffer = text_buffer_new( );

vec4 black = {{0.0, 0.0, 0.0, 1.0}};
vec4 none = {{1.0, 1.0, 1.0, 0.0}};
ftgl_vec4 black = {{0.0, 0.0, 0.0, 1.0}};
ftgl_vec4 none = {{1.0, 1.0, 1.0, 0.0}};

markup_t markup;
markup.family = "fonts/VeraMono.ttf";
Expand All @@ -277,7 +277,7 @@ void init( void )
markup.strikethrough_color = black;
markup.font = 0;

vec2 pen = {{10.0, 480.0}};
ftgl_vec2 pen = {{10.0, 480.0}};
FILE *file = fopen ( "data/256colors.txt", "r" );
if ( file != NULL )
{
Expand Down
12 changes: 6 additions & 6 deletions demos/atb-agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ static char text[] =
void
build_buffer( void )
{
vec2 pen;
ftgl_vec2 pen;
texture_font_t *font;
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}};
vec4 color = white;
ftgl_vec4 black = {{0.0, 0.0, 0.0, 1.0}};
ftgl_vec4 white = {{1.0, 1.0, 1.0, 1.0}};
ftgl_vec4 none = {{1.0, 1.0, 1.0, 0.0}};
ftgl_vec4 color = white;
if( p_invert )
{
color = black;
Expand Down Expand Up @@ -174,7 +174,7 @@ build_buffer( void )
size_t i;
for( i=0; i < vector_size( vbuffer->items ); ++i )
{
ivec4 *item = (ivec4 *) vector_get( vbuffer->items, i);
ftgl_ivec4 *item = (ftgl_ivec4 *) vector_get( vbuffer->items, i);
glyph_vertex_t * v0 = /* x0,y0 */
(glyph_vertex_t *) vector_get( vbuffer->vertices, item->vstart+0 );
//glyph_vertex_t * v1 = /* x0,y1 */
Expand Down
10 changes: 5 additions & 5 deletions demos/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mat4 model, view, projection;

// --------------------------------------------------------------- add_text ---
void add_text( vertex_buffer_t * buffer, texture_font_t * font,
char *text, vec4 * color, vec2 * pen )
char *text, ftgl_vec4 * color, ftgl_vec2 * pen )
{
size_t i;
float r = color->red, g = color->green, b = color->blue, a = color->alpha;
Expand Down Expand Up @@ -78,8 +78,8 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
void init( void )
{
size_t i;
vec2 pen = {{0,0}};
vec4 color = {{0,0,0,1}};
ftgl_vec2 pen = {{0,0}};
ftgl_vec4 color = {{0,0,0,1}};

atlas = texture_atlas_new( 512, 512, 1 );
font = texture_font_new_from_file( atlas, 12, "fonts/VeraMono.ttf" );
Expand Down Expand Up @@ -155,8 +155,8 @@ void display( GLFWwindow* window )
if( count < 5 )
{
size_t i;
vec4 color = {{0,0,0,1}};
vec2 pen = {{0,0}};
ftgl_vec4 color = {{0,0,0,1}};
ftgl_vec2 pen = {{0,0}};
vertex_buffer_clear( buffer );

pen.y = -font->descender;
Expand Down
14 changes: 7 additions & 7 deletions demos/cartoon.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
typedef struct {
float x, y, z;
float u, v;
vec4 color;
ftgl_vec4 color;
} vertex_t;


Expand All @@ -33,7 +33,7 @@ mat4 model, view, projection;

// --------------------------------------------------------------- add_text ---
void add_text( vertex_buffer_t * buffer, texture_font_t * font,
char *text, vec2 pen, vec4 fg_color_1, vec4 fg_color_2 )
char *text, ftgl_vec2 pen, ftgl_vec4 fg_color_1, ftgl_vec4 fg_color_2 )
{
size_t i;
for( i = 0; i < strlen(text); ++i )
Expand Down Expand Up @@ -78,11 +78,11 @@ void init( void )
texture_font_t *font =
texture_font_new_from_file( atlas, 128, "fonts/LuckiestGuy.ttf" );

vec2 pen = {{50, 50}};
vec4 black = {{0.0, 0.0, 0.0, 1.0}};
vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
vec4 orange1 = {{1.0, 0.9, 0.0, 1.0}};
vec4 orange2 = {{1.0, 0.6, 0.0, 1.0}};
ftgl_vec2 pen = {{50, 50}};
ftgl_vec4 black = {{0.0, 0.0, 0.0, 1.0}};
ftgl_vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
ftgl_vec4 orange1 = {{1.0, 0.9, 0.0, 1.0}};
ftgl_vec4 orange2 = {{1.0, 0.6, 0.0, 1.0}};

font->rendermode = RENDER_OUTLINE_POSITIVE;
font->outline_thickness = 7;
Expand Down
8 changes: 4 additions & 4 deletions demos/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct _console_t {
markup_t markup[MARKUP_COUNT];
vertex_buffer_t * buffer;
texture_atlas_t *atlas;
vec2 pen;
ftgl_vec2 pen;
void (*handlers[4])( struct _console_t *, char * );
};
typedef struct _console_t console_t;
Expand Down Expand Up @@ -89,9 +89,9 @@ console_new( float font_size )
self->atlas = texture_atlas_new( 512, 512, 1 );
glGenTextures( 1, &self->atlas->id );

vec4 white = {{1,1,1,1}};
vec4 black = {{0,0,0,1}};
vec4 none = {{0,0,1,0}};
ftgl_vec4 white = {{1,1,1,1}};
ftgl_vec4 black = {{0,0,0,1}};
ftgl_vec4 none = {{0,0,1,0}};

markup_t normal;
normal.family = "fonts/VeraMono.ttf";
Expand Down
14 changes: 7 additions & 7 deletions demos/distance-field-2.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ mat4 model, view, projection;


// --------------------------------------------------------------- add_text ---
vec4
ftgl_vec4
add_text( vertex_buffer_t * buffer, texture_font_t * font,
char *text, vec4 * color, vec2 * pen )
char *text, ftgl_vec4 * color, ftgl_vec2 * pen )
{
vec4 bbox = {{0,0,0,0}};
ftgl_vec4 bbox = {{0,0,0,0}};
size_t i;
float r = color->red, g = color->green, b = color->blue, a = color->alpha;
for( i = 0; i < strlen(text); ++i )
Expand Down Expand Up @@ -99,11 +99,11 @@ void init( void )
const char * filename = "fonts/Vera.ttf";
char *text = "A Quick Brown Fox Jumps Over The Lazy Dog 0123456789";
buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
vec2 pen = {{0,0}};
vec4 black = {{1,1,1,1}};
ftgl_vec2 pen = {{0,0}};
ftgl_vec4 black = {{1,1,1,1}};
font = texture_font_new_from_file( atlas, 48, filename );
font->rendermode = RENDER_SIGNED_DISTANCE_FIELD;
vec4 bbox = add_text( buffer, font, text, &black, &pen );
ftgl_vec4 bbox = add_text( buffer, font, text, &black, &pen );
size_t i;
vector_t * vertices = buffer->vertices;
for( i=0; i< vector_size(vertices); ++i )
Expand Down Expand Up @@ -145,7 +145,7 @@ void display( GLFWwindow* window )
GLint height = viewport[3];

srand(4);
vec4 color = {{0.067,0.333, 0.486, 1.0}};
ftgl_vec4 color = {{0.067,0.333, 0.486, 1.0}};
size_t i;
for( i=0; i<40; ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions demos/distance-field-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ load_glyph( const char * filename, const char* codepoint,
printf( "Glyph offset x: %d\n", glyph->offset_x );
printf( "Glyph offset y: %d\n", glyph->offset_y );
*/
ivec4 region = texture_atlas_get_region( atlas, glyph->width, glyph->height );
ftgl_ivec4 region = texture_atlas_get_region( atlas, glyph->width, glyph->height );
/*
printf( "Region x : %d\n", region.x );
printf( "Region y : %d\n", region.y );
Expand Down Expand Up @@ -317,7 +317,7 @@ void display( GLFWwindow* window )

float s = .025+.975*(1+cos(angle/100.0))/2.;

vec4 color = {{1.0, 1.0, 1.0, 1.0 }};
ftgl_vec4 color = {{1.0, 1.0, 1.0, 1.0 }};

mat4_set_identity( &model );
mat4_scale( &model, width * s, width * s, 1 );
Expand Down
2 changes: 1 addition & 1 deletion demos/distance-field.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void display( GLFWwindow* window )
GLint width = v[2];
GLint height = v[3];

vec4 color = {{1.0, 1.0, 1.0, 1.0 }};
ftgl_vec4 color = {{1.0, 1.0, 1.0, 1.0 }};

mat4_set_identity( &model );
mat4_scale( &model, width * viewport.zoom, height * viewport.zoom, 0 );
Expand Down
6 changes: 3 additions & 3 deletions demos/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mat4 model, view, projection;

// --------------------------------------------------------------- add_text ---
void add_text( vertex_buffer_t * buffer, texture_font_t * font,
char * text, vec4 * color, vec2 * pen )
char * text, ftgl_vec4 * color, ftgl_vec2 * pen )
{
size_t i;
float r = color->red, g = color->green, b = color->blue, a = color->alpha;
Expand Down Expand Up @@ -76,8 +76,8 @@ void init( void )
const char * filename = "fonts/Vera.ttf";
char * text = "A Quick Brown Fox Jumps Over The Lazy Dog 0123456789";
buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" );
vec2 pen = {{5,400}};
vec4 black = {{0,0,0,1}};
ftgl_vec2 pen = {{5,400}};
ftgl_vec4 black = {{0,0,0,1}};
for( i=7; i < 27; ++i)
{
font = texture_font_new_from_file( atlas, i, filename );
Expand Down
8 changes: 4 additions & 4 deletions demos/gamma.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ void init( void )
font_manager = font_manager_new( 512, 512, LCD_FILTERING_OFF );

buffer = text_buffer_new( );
vec4 white = {{1.0, 1.0, 1.0, 1.0}};
vec4 black = {{0.0, 0.0, 0.0, 1.0}};
vec4 none = {{1.0, 1.0, 1.0, 0.0}};
ftgl_vec4 white = {{1.0, 1.0, 1.0, 1.0}};
ftgl_vec4 black = {{0.0, 0.0, 0.0, 1.0}};
ftgl_vec4 none = {{1.0, 1.0, 1.0, 0.0}};

markup_t markup;
markup.family = "fonts/Vera.ttf";
Expand All @@ -71,7 +71,7 @@ void init( void )
markup.font = font_manager_get_from_markup( font_manager, &markup );

size_t i;
vec2 pen;
ftgl_vec2 pen;
pen.x = 32;
pen.y = 508;

Expand Down
10 changes: 5 additions & 5 deletions demos/glyph.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct {

typedef struct {
float x, y, z;
vec4 color;
ftgl_vec4 color;
} point_t;


Expand All @@ -43,7 +43,7 @@ const int height = 600;

// --------------------------------------------------------------- add_text ---
void add_text( vertex_buffer_t * buffer, texture_font_t * font,
char *text, vec4 * color, vec2 * pen )
char *text, ftgl_vec4 * color, ftgl_vec2 * pen )
{
size_t i;
float r = color->red, g = color->green, b = color->blue, a = color->alpha;
Expand Down Expand Up @@ -81,8 +81,8 @@ void add_text( vertex_buffer_t * buffer, texture_font_t * font,
// ------------------------------------------------------------------- init ---
void init( void )
{
vec4 blue = {{0,0,1,1}};
vec4 black = {{0,0,0,1}};
ftgl_vec4 blue = {{0,0,1,1}};
ftgl_vec4 black = {{0,0,0,1}};

atlas = texture_atlas_new( 512, 512, 1 );
texture_font_t * big = texture_font_new_from_file( atlas, 400, "fonts/Vera.ttf");
Expand All @@ -93,7 +93,7 @@ void init( void )
line_buffer = vertex_buffer_new( "vertex:3f,color:4f" );
point_buffer = vertex_buffer_new( "vertex:3f,color:4f" );

vec2 pen, origin;
ftgl_vec2 pen, origin;

texture_glyph_t *glyph = texture_font_get_glyph( big, "g" );
origin.x = width/2 - glyph->offset_x - glyph->width/2;
Expand Down
2 changes: 1 addition & 1 deletion demos/harfbuzz-texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void init( void )
int w = ft_bitmap_width/3; // 3 because of LCD/RGB encoding
int h = ft_bitmap_rows;

ivec4 region = texture_atlas_get_region( atlas, w+1, h+1 );
ftgl_ivec4 region = texture_atlas_get_region( atlas, w+1, h+1 );
if ( region.x < 0 )
{
fprintf( stderr, "Texture atlas is full (%s:%d)\n", __FILE__, __LINE__ );
Expand Down
6 changes: 3 additions & 3 deletions demos/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mat4 model, view, projection;

// --------------------------------------------------------------- add_text ---
void add_text( vertex_buffer_t * buffer, texture_font_t * font,
char * text, vec4 * color, vec2 * pen )
char * text, ftgl_vec4 * color, ftgl_vec2 * pen )
{
size_t i;
float r = color->red, g = color->green, b = color->blue, a = color->alpha;
Expand Down Expand Up @@ -80,8 +80,8 @@ void init( void )
const char * filename = "fonts/Vera.ttf";
char * text = "A Quick Brown Fox Jumps Over The Lazy Dog 0123456789";
buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f,ashift:1f,agamma:1f" );
vec2 pen = {{0,0}};
vec4 color = {{0,0,0,1}};
ftgl_vec2 pen = {{0,0}};
ftgl_vec4 color = {{0,0,0,1}};

for( i=7; i < 27; ++i)
{
Expand Down
14 changes: 7 additions & 7 deletions demos/markup.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ void init()
font_manager = font_manager_new( 512, 512, LCD_FILTERING_ON );
buffer = text_buffer_new( );

vec4 black = {{0.0, 0.0, 0.0, 1.0}};
vec4 white = {{1.0, 1.0, 1.0, 1.0}};
vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
vec4 grey = {{0.5, 0.5, 0.5, 1.0}};
vec4 none = {{1.0, 1.0, 1.0, 0.0}};
ftgl_vec4 black = {{0.0, 0.0, 0.0, 1.0}};
ftgl_vec4 white = {{1.0, 1.0, 1.0, 1.0}};
ftgl_vec4 yellow = {{1.0, 1.0, 0.0, 1.0}};
ftgl_vec4 grey = {{0.5, 0.5, 0.5, 1.0}};
ftgl_vec4 none = {{1.0, 1.0, 1.0, 0.0}};

char *f_normal = match_description("Droid Serif:size=24");
char *f_bold = match_description("Droid Serif:size=24:weight=bold");
Expand Down Expand Up @@ -142,7 +142,7 @@ void init()
japanese.font = font_manager_get_from_markup( font_manager, &japanese );
math.font = font_manager_get_from_markup( font_manager, &math );

vec2 pen = {{20, 200}};
ftgl_vec2 pen = {{20, 200}};
text_buffer_printf( buffer, &pen,
&underline, "The",
&normal, " Quick",
Expand Down Expand Up @@ -170,7 +170,7 @@ void init()

text_buffer_align( buffer, &pen, ALIGN_CENTER );

vec4 bounds = text_buffer_get_bounds( buffer, &pen );
ftgl_vec4 bounds = text_buffer_get_bounds( buffer, &pen );
float left = bounds.left;
float right = bounds.left + bounds.width;
float top = bounds.top;
Expand Down
Loading