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:
authorCampbell Barton <ideasman42@gmail.com>2016-06-08 08:16:50 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2016-06-08 22:45:40 +0300
commit3262fc31d4a2452dc13f7bdeaeb2cc18d07f432b (patch)
treeab078026a4ef0c9232752332872d5bd70566175a
parent74c65981ceb55ed8007be2ee8fd1dd7624c29b0c (diff)
GPU: fix/workaround basic shader font-color
All text was displaying black. BLF uses alpha-only textures which aren't supported by the basic-shader, Workaround this by using texture swizzle so the RGB components of the texture are set to 1.
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 41726e41176..aa7d539538b 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -55,6 +55,10 @@
#include "BIF_gl.h"
#include "BLF_api.h"
+#ifndef BLF_STANDALONE
+#include "GPU_basic_shader.h"
+#endif
+
#include "blf_internal_types.h"
#include "blf_internal.h"
@@ -179,6 +183,16 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+#ifndef BLF_STANDALONE
+ /* needed since basic shader doesn't support alpha-only textures,
+ * while we could add support this is only used in a few places
+ * (an alternative could be to have a simple shader for BLF). */
+ if (GLEW_ARB_texture_swizzle && GPU_basic_shader_use_glsl_get()) {
+ GLint swizzle_mask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle_mask);
+ }
+#endif
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA8, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
}