diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-06-08 08:16:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-06-08 08:20:57 +0300 |
commit | eaa19177e7c3b874bc363b7dd3cf45aca808e814 (patch) | |
tree | f519595d6b6c03854c64287b87d2e89b49d10636 /source | |
parent | 654019fa01c858ce49595bb95d189e5e60b7e6cc (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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 14 |
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); } |