Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Borghetti <bdiego@gmail.com>2012-01-06 20:40:57 +0400
committerDiego Borghetti <bdiego@gmail.com>2012-01-06 20:40:57 +0400
commit5ba14fd210355e0bbff7746cdc58ec96b7a489de (patch)
tree8767fab3342ea8a6150231cfb2500a1a64dbf579 /source/blender/blenfont/intern
parent7ff5a17ff2959fcd1a13b245596c52e057e57e39 (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')
-rw-r--r--source/blender/blenfont/intern/blf.c25
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c10
2 files changed, 17 insertions, 18 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, &param);
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, &param);
blf_font_draw_ascii(font, str, len);
- blf_draw__end(mode);
+ blf_draw__end(mode, param);
}
}
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index f8c589a7051..f0cfcdc97b9 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -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, &param);
- 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;
}