[Bf-blender-cvs] [2c29b94384d] blender2.8: Fix text drawing with core profile
Sergey Sharybin
noreply at git.blender.org
Tue Apr 18 16:45:07 CEST 2017
Commit: 2c29b94384d2c556563a3126563704a7e1173c65
Author: Sergey Sharybin
Date: Tue Apr 18 16:41:07 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB2c29b94384d2c556563a3126563704a7e1173c65
Fix text drawing with core profile
The issue was going to the fact that GL_ALPHA was deprecated in core profile
and common solution online is to use GL_RED instead. That is what is done in
this commit.
===================================================================
M source/blender/blenfont/intern/blf_glyph.c
M source/blender/gpu/shaders/gpu_shader_text_frag.glsl
===================================================================
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index f99f1bf0d6d..a7d52e96800 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -183,7 +183,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA8, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, gc->p2_width, gc->p2_height, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
}
GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
@@ -459,7 +459,7 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, g->tex);
- glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_RED, GL_UNSIGNED_BYTE, g->bitmap);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsb_first);
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
diff --git a/source/blender/gpu/shaders/gpu_shader_text_frag.glsl b/source/blender/gpu/shaders/gpu_shader_text_frag.glsl
index 9283d682767..e0a19912520 100644
--- a/source/blender/gpu/shaders/gpu_shader_text_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_text_frag.glsl
@@ -18,5 +18,5 @@ void main()
fragColor.rgb = color_flat.rgb;
// modulate input alpha & texture alpha
- fragColor.a = color_flat.a * texture2D(glyph, texCoord_interp).a;
+ fragColor.a = color_flat.a * texture2D(glyph, texCoord_interp).r;
}
More information about the Bf-blender-cvs
mailing list