Commit 242c2acb authored by Nicolas P. Rougier's avatar Nicolas P. Rougier

Merge pull request #19 from cforfang/tweaks+fixes

Various fixes and tweaks
parents da1dc67a 65e8b7ae
......@@ -71,7 +71,7 @@ extern "C" {
/**
* Structure in charge of caching fonts.
*/
typedef struct {
typedef struct font_manager_t {
/**
* Texture atlas to hold font glyphs.
*/
......
......@@ -84,7 +84,7 @@ extern "C" {
/**
* Simple structure that describes text properties.
*/
typedef struct
typedef struct markup_t
{
/**
* A font family name such as "normal", "sans", "serif" or "monospace".
......
......@@ -98,6 +98,7 @@ shader_load( const char * vert_filename,
char *vert_source = shader_read( vert_filename );
GLuint vert_shader = shader_compile( vert_source, GL_VERTEX_SHADER);
glAttachShader( handle, vert_shader);
glDeleteShader( vert_shader );
free( vert_source );
}
if( frag_filename && strlen( frag_filename ) )
......@@ -105,6 +106,7 @@ shader_load( const char * vert_filename,
char *frag_source = shader_read( frag_filename );
GLuint frag_shader = shader_compile( frag_source, GL_FRAGMENT_SHADER);
glAttachShader( handle, frag_shader);
glDeleteShader( frag_shader );
free( frag_source );
}
......
......@@ -71,6 +71,15 @@ text_buffer_new( size_t depth )
return self;
}
// ----------------------------------------------------------------------------
void
text_buffer_delete( text_buffer_t * self )
{
vertex_buffer_delete( self->buffer );
glDeleteProgram( self->shader );
free( self );
}
// ----------------------------------------------------------------------------
void
text_buffer_clear( text_buffer_t * self )
......@@ -89,8 +98,10 @@ void
text_buffer_render( text_buffer_t * self )
{
glEnable( GL_BLEND );
glEnable( GL_TEXTURE_2D );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, self->manager->atlas->id );
if( self->manager->atlas->depth == 1 )
{
//glDisable( GL_COLOR_MATERIAL );
......
......@@ -78,7 +78,7 @@ extern "C" {
/**
* Text buffer structure
*/
typedef struct {
typedef struct text_buffer_t {
/**
* Vertex buffer
*/
......@@ -137,7 +137,7 @@ typedef struct {
/**
* Glyph vertex structure
*/
typedef struct {
typedef struct glyph_vertex_t {
/**
* Vertex x coordinates
*/
......@@ -208,6 +208,14 @@ typedef struct {
text_buffer_t *
text_buffer_new( size_t depth );
/**
* Deletes texture buffer and its associated shader and vertex buffer.
*
* @param self texture buffer to delete
*
*/
void
text_buffer_delete( text_buffer_t * self );
/**
* Render a text buffer.
......
......@@ -95,7 +95,7 @@ extern "C" {
/**
* A texture atlas is used to pack several small regions into a single texture.
*/
typedef struct
typedef struct texture_atlas_t
{
/**
* Allocated nodes
......
......@@ -72,7 +72,7 @@ extern "C" {
* This structure cannot be used alone since the (necessary) right charcode is
* implicitely held by the owner of this structure.
*/
typedef struct
typedef struct kerning_t
{
/**
* Left character code in the kern pair.
......@@ -125,7 +125,7 @@ typedef struct
/**
* A structure that describe a glyph.
*/
typedef struct
typedef struct texture_glyph_t
{
/**
* Wide character this glyph represents
......@@ -216,7 +216,7 @@ typedef struct
/**
* Texture font structure.
*/
typedef struct
typedef struct texture_font_t
{
/**
* Vector of glyphs contained in this font.
......
......@@ -78,7 +78,7 @@ extern "C" {
*
* @memberof vector
*/
typedef struct
typedef struct vector_t
{
/** Pointer to dynamically allocated items. */
void * items;
......
......@@ -196,7 +196,7 @@ extern "C" {
/**
* Generic vertex attribute.
*/
typedef struct
typedef struct vertex_attribute_t
{
/**
* atribute name
......
......@@ -57,7 +57,7 @@ extern "C" {
/**
* Generic vertex buffer.
*/
typedef struct
typedef struct vertex_buffer_t
{
/** Format of the vertex buffer. */
char * format;
......
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