[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43105] trunk/blender/source/blender/ blenfont/intern: Fix:
Diego Borghetti
bdiego at gmail.com
Tue Jan 3 20:41:45 CET 2012
Revision: 43105
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43105
Author: bdiego
Date: 2012-01-03 19:41:36 +0000 (Tue, 03 Jan 2012)
Log Message:
-----------
Fix:
[#25834] no color of textobjects in game engine when combined with
textured objects
[#26893] Curruption of displayed text (debug properties/fps info or bgui)
when using animated/tile uv mode
The first bug was beacuse a bad mode on the texture environment, now
we save the current glTexEnvi, set the one that we need, draw and
restore the original at the end.
The second was because a missing call to glLoadIdentity for the
texture matrix and as we do before, now we do a gl-Push/Identity/Pop
for this matrix to.
The first problem was solved by Kanttori and the second by Dalai.
Modified Paths:
--------------
trunk/blender/source/blender/blenfont/intern/blf.c
trunk/blender/source/blender/blenfont/intern/blf_glyph.c
Modified: trunk/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf.c 2012-01-03 17:33:38 UTC (rev 43104)
+++ trunk/blender/source/blender/blenfont/intern/blf.c 2012-01-03 19:41:36 UTC (rev 43105)
@@ -479,7 +479,7 @@
}
}
-static void blf_draw__start(FontBLF *font)
+static void blf_draw__start(FontBLF *font, GLint *mode)
{
/*
* The pixmap alignment hack is handle
@@ -490,8 +490,16 @@
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)
glMultMatrixd((GLdouble *)&font->m);
@@ -508,12 +516,19 @@
/* 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 @@
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);
}
}
Modified: trunk/blender/source/blender/blenfont/intern/blf_glyph.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_glyph.c 2012-01-03 17:33:38 UTC (rev 43104)
+++ trunk/blender/source/blender/blenfont/intern/blf_glyph.c 2012-01-03 19:41:36 UTC (rev 43105)
@@ -368,6 +368,7 @@
float dx, dx1;
float y1, y2;
float xo, yo;
+ GLint param;
if ((!g->width) || (!g->height))
return 1;
@@ -449,6 +450,11 @@
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) {
@@ -487,5 +493,9 @@
break;
}
+ /* and restore the original value. */
+ if (param != GL_MODULATE)
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
+
return 1;
}
More information about the Bf-blender-cvs
mailing list