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:
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r--source/blender/blenfont/intern/blf.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 9b26e7a54be..f8018e05431 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)
+static void blf_draw__start(FontBLF *font, GLint *mode)
{
/*
* The pixmap alignment hack is handle
@@ -490,6 +490,14 @@ static void blf_draw__start(FontBLF *font)
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ /* Save the current matrix mode. */
+ glGetIntegerv(GL_MATRIX_MODE, mode);
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (font->flags & BLF_MATRIX)
@@ -508,12 +516,19 @@ static void blf_draw__start(FontBLF *font)
/* always bind the texture for the first glyph */
font->tex_bind_state= -1;
-
}
-static void blf_draw__end(void)
+static void blf_draw__end(GLint mode)
{
+ glMatrixMode(GL_TEXTURE);
glPopMatrix();
+
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
+ if (mode != GL_MODELVIEW)
+ glMatrixMode(mode);
+
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}
@@ -521,22 +536,24 @@ static void blf_draw__end(void)
void BLF_draw(int fontid, const char *str, size_t len)
{
FontBLF *font= BLF_get(fontid);
+ GLint mode;
if (font && font->glyph_cache) {
- blf_draw__start(font);
+ blf_draw__start(font, &mode);
blf_font_draw(font, str, len);
- blf_draw__end();
+ blf_draw__end(mode);
}
}
void BLF_draw_ascii(int fontid, const char *str, size_t len)
{
FontBLF *font= BLF_get(fontid);
+ GLint mode;
if (font && font->glyph_cache) {
- blf_draw__start(font);
+ blf_draw__start(font, &mode);
blf_font_draw_ascii(font, str, len);
- blf_draw__end();
+ blf_draw__end(mode);
}
}