Move glTexEnvi to draw__start/draw__end.
As Campbell point, this is to avoid call glGet/glTexEnvi on each character.
This commit is contained in:
@@ -479,7 +479,7 @@ void BLF_rotation_default(float angle)
|
||||
}
|
||||
}
|
||||
|
||||
static void blf_draw__start(FontBLF *font, GLint *mode)
|
||||
static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
|
||||
{
|
||||
/*
|
||||
* The pixmap alignment hack is handle
|
||||
@@ -516,10 +516,19 @@ static void blf_draw__start(FontBLF *font, GLint *mode)
|
||||
|
||||
/* always bind the texture for the first glyph */
|
||||
font->tex_bind_state= -1;
|
||||
|
||||
/* Save the current parameter to restore it later. */
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
||||
if (*param != GL_MODULATE)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
|
||||
static void blf_draw__end(GLint mode)
|
||||
static void blf_draw__end(GLint mode, GLint param)
|
||||
{
|
||||
/* and restore the original value. */
|
||||
if (param != GL_MODULATE)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPopMatrix();
|
||||
|
||||
@@ -536,24 +545,24 @@ static void blf_draw__end(GLint mode)
|
||||
void BLF_draw(int fontid, const char *str, size_t len)
|
||||
{
|
||||
FontBLF *font= BLF_get(fontid);
|
||||
GLint mode;
|
||||
GLint mode, param;
|
||||
|
||||
if (font && font->glyph_cache) {
|
||||
blf_draw__start(font, &mode);
|
||||
blf_draw__start(font, &mode, ¶m);
|
||||
blf_font_draw(font, str, len);
|
||||
blf_draw__end(mode);
|
||||
blf_draw__end(mode, param);
|
||||
}
|
||||
}
|
||||
|
||||
void BLF_draw_ascii(int fontid, const char *str, size_t len)
|
||||
{
|
||||
FontBLF *font= BLF_get(fontid);
|
||||
GLint mode;
|
||||
GLint mode, param;
|
||||
|
||||
if (font && font->glyph_cache) {
|
||||
blf_draw__start(font, &mode);
|
||||
blf_draw__start(font, &mode, ¶m);
|
||||
blf_font_draw_ascii(font, str, len);
|
||||
blf_draw__end(mode);
|
||||
blf_draw__end(mode, param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,6 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
||||
float dx, dx1;
|
||||
float y1, y2;
|
||||
float xo, yo;
|
||||
GLint param;
|
||||
|
||||
if ((!g->width) || (!g->height))
|
||||
return 1;
|
||||
@@ -450,11 +449,6 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
||||
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state= g->tex));
|
||||
}
|
||||
|
||||
/* Save the current parameter to restore it later. */
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, ¶m);
|
||||
if (param != GL_MODULATE)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
if (font->flags & BLF_SHADOW) {
|
||||
|
||||
switch(font->shadow) {
|
||||
@@ -493,9 +487,5 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
||||
break;
|
||||
}
|
||||
|
||||
/* and restore the original value. */
|
||||
if (param != GL_MODULATE)
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user