diff options
author | Diego Borghetti <bdiego@gmail.com> | 2012-01-06 20:40:57 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2012-01-06 20:40:57 +0400 |
commit | 5ba14fd210355e0bbff7746cdc58ec96b7a489de (patch) | |
tree | 8767fab3342ea8a6150231cfb2500a1a64dbf579 /source/blender/blenfont/intern/blf.c | |
parent | 7ff5a17ff2959fcd1a13b245596c52e057e57e39 (diff) |
Move glTexEnvi to draw__start/draw__end.
As Campbell point, this is to avoid call glGet/glTexEnvi
on each character.
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index f8018e05431..a387b416c38 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -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); } } |