* Add proper glPushAttrib() and glPushClientAttrib() calls to the rendering methods that need them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/src/FTFont/FTBitmapFont.cpp b/src/FTFont/FTBitmapFont.cpp
index 08df30c..1e77379 100644
--- a/src/FTFont/FTBitmapFont.cpp
+++ b/src/FTFont/FTBitmapFont.cpp
@@ -67,8 +67,11 @@ inline FTPoint FTBitmapFontImpl::RenderI(const T* string, const int len,
FTPoint position, FTPoint spacing,
int renderMode)
{
+ // Protect GL_BLEND
+ glPushAttrib(GL_COLOR_BUFFER_BIT);
+
+ // Protect glPixelStorei() calls (also in FTBitmapGlyphImpl::RenderImpl)
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- glPushAttrib(GL_ENABLE_BIT);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -78,8 +81,8 @@ inline FTPoint FTBitmapFontImpl::RenderI(const T* string, const int len,
FTPoint tmp = FTFontImpl::Render(string, len,
position, spacing, renderMode);
- glPopAttrib();
glPopClientAttrib();
+ glPopAttrib();
return tmp;
}
diff --git a/src/FTFont/FTBufferFont.cpp b/src/FTFont/FTBufferFont.cpp
index a78abc2..0b25126 100644
--- a/src/FTFont/FTBufferFont.cpp
+++ b/src/FTFont/FTBufferFont.cpp
@@ -160,10 +160,12 @@ inline FTPoint FTBufferFontImpl::RenderI(const T* string, const int len,
FTPoint tmp = FTFontImpl::Render(string, len, position,
spacing, renderMode);
+ // Protect blending functions, GL_BLEND and GL_TEXTURE_2D
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT);
+
+ // Protect glPixelStorei() calls
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
- /* FIXME: can we push/pop these instead? */
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
diff --git a/src/FTFont/FTOutlineFont.cpp b/src/FTFont/FTOutlineFont.cpp
index 8a7f270..1fbc928 100644
--- a/src/FTFont/FTOutlineFont.cpp
+++ b/src/FTFont/FTOutlineFont.cpp
@@ -74,11 +74,11 @@ inline FTPoint FTOutlineFontImpl::RenderI(const T* string, const int len,
FTPoint position, FTPoint spacing,
int renderMode)
{
+ // Protect GL_TEXTURE_2D, glHint(), GL_LINE_SMOOTH and blending functions
glPushAttrib(GL_ENABLE_BIT | GL_HINT_BIT | GL_LINE_BIT
| GL_COLOR_BUFFER_BIT);
glDisable(GL_TEXTURE_2D);
-
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glEnable(GL_BLEND);
diff --git a/src/FTFont/FTPixmapFont.cpp b/src/FTFont/FTPixmapFont.cpp
index f298fe5..2113e61 100644
--- a/src/FTFont/FTPixmapFont.cpp
+++ b/src/FTFont/FTPixmapFont.cpp
@@ -67,7 +67,11 @@ inline FTPoint FTPixmapFontImpl::RenderI(const T* string, const int len,
FTPoint position, FTPoint spacing,
int renderMode)
{
+ // Protect GL_TEXTURE_2D and GL_BLEND, glPixelTransferf(), and blending
+ // functions.
glPushAttrib(GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT);
+
+ // Protect glPixelStorei() calls (made by FTPixmapGlyphImpl::RenderImpl).
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
glEnable(GL_BLEND);
diff --git a/src/FTFont/FTTextureFont.cpp b/src/FTFont/FTTextureFont.cpp
index 9773ddd..d782397 100644
--- a/src/FTFont/FTTextureFont.cpp
+++ b/src/FTFont/FTTextureFont.cpp
@@ -228,14 +228,22 @@ inline FTPoint FTTextureFontImpl::RenderI(const T* string, const int len,
FTPoint position, FTPoint spacing,
int renderMode)
{
- /* FIXME: can we push/pop these instead? */
+ // Protect GL_TEXTURE_2D, GL_BLEND and blending functions
+ glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
+
glEnable(GL_BLEND);
- glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_ONE
+ glEnable(GL_TEXTURE_2D);
+
FTTextureGlyphImpl::ResetActiveTexture();
- return FTFontImpl::Render(string, len, position, spacing, renderMode);
+ FTPoint tmp = FTFontImpl::Render(string, len,
+ position, spacing, renderMode);
+
+ glPopAttrib();
+
+ return tmp;
}