Browse Source

* Updated documentation, removed warning in cucul_render_glyph(), minor optimisation in driver_gl

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18 years ago
parent
commit
a87130bade
2 changed files with 15 additions and 9 deletions
  1. +13
    -7
      caca/driver_gl.c
  2. +2
    -2
      cucul/font.c

+ 13
- 7
caca/driver_gl.c View File

@@ -175,6 +175,10 @@ static int gl_init_graphics(caca_display_t *dp)
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);


glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);



empty_texture = malloc(16 * 16 * 4); empty_texture = malloc(16 * 16 * 4);
if(empty_texture == NULL) if(empty_texture == NULL)
@@ -248,9 +252,11 @@ static unsigned int gl_get_display_height(caca_display_t *dp)
static void gl_display(caca_display_t *dp) static void gl_display(caca_display_t *dp)
{ {
unsigned int x, y, line; unsigned int x, y, line;
static int old_texture = 0;


glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);

glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
line = 0; line = 0;
for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height) for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height)
{ {
@@ -259,7 +265,7 @@ static void gl_display(caca_display_t *dp)
for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width) for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width)
{ {
uint16_t bg = _cucul_argb32_to_rgb12bg(*attr++); uint16_t bg = _cucul_argb32_to_rgb12bg(*attr++);
glDisable(GL_TEXTURE_2D);
glColor4b(((bg & 0xf00) >> 8) * 8, glColor4b(((bg & 0xf00) >> 8) * 8,
((bg & 0x0f0) >> 4) * 8, ((bg & 0x0f0) >> 4) * 8,
(bg & 0x00f) * 8, (bg & 0x00f) * 8,
@@ -279,7 +285,6 @@ static void gl_display(caca_display_t *dp)
/* 2nd pass, avoids changing render state too much */ /* 2nd pass, avoids changing render state too much */
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);


line = 0; line = 0;
for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height, line++) for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height, line++)
@@ -297,7 +302,11 @@ static void gl_display(caca_display_t *dp)


if(cv > 0x00000020 && cv < 0x00000080) if(cv > 0x00000020 && cv < 0x00000080)
{ {
glBindTexture(GL_TEXTURE_2D, dp->drv.p->id[cv - 32]);
if(old_texture != dp->drv.p->id[cv - 32])
{
glBindTexture(GL_TEXTURE_2D, dp->drv.p->id[cv - 32]);
old_texture = dp->drv.p->id[cv - 32];
}
} }
else switch(cv) else switch(cv)
{ {
@@ -329,9 +338,6 @@ static void gl_display(caca_display_t *dp)
glEnd(); glEnd();
} }
} }
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);


#ifdef HAVE_GLUTCHECKLOOP #ifdef HAVE_GLUTCHECKLOOP
glutCheckLoop(); glutCheckLoop();


+ 2
- 2
cucul/font.c View File

@@ -458,7 +458,7 @@ int cucul_render_canvas(cucul_canvas_t *cv, cucul_font_t *f,
* \param f The font, as returned by cucul_load_font() * \param f The font, as returned by cucul_load_font()
* \param ch The character to render * \param ch The character to render
* \param buf The image buffer * \param buf The image buffer
* \param pitch The pitch of the image buffer
* \param stride width of the destination buffer
* \return This function always returns 0. * \return This function always returns 0.
*/ */
int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf, int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf,
@@ -466,7 +466,7 @@ int cucul_render_glyph(cucul_font_t *f, unsigned int ch, void *buf,
{ {
unsigned int b, y; unsigned int b, y;
struct glyph_info *g; struct glyph_info *g;
uint8_t *glyph;
uint8_t *glyph = NULL;


/* Find the Unicode block where our glyph lies */ /* Find the Unicode block where our glyph lies */
for(b = 0; b < f->header.blocks; b++) for(b = 0; b < f->header.blocks; b++)


Loading…
Cancel
Save