[Bf-blender-cvs] [eaa1917] master: GPU: fix/workaround basic shader font-color

Campbell Barton noreply at git.blender.org
Wed Jun 8 07:20:25 CEST 2016


Commit: eaa19177e7c3b874bc363b7dd3cf45aca808e814
Author: Campbell Barton
Date:   Wed Jun 8 15:16:50 2016 +1000
Branches: master
https://developer.blender.org/rBeaa19177e7c3b874bc363b7dd3cf45aca808e814

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.

===================================================================

M	source/blender/blenfont/intern/blf_glyph.c

===================================================================

diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 41726e4..aa7d539 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);
 }




More information about the Bf-blender-cvs mailing list