diff options
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index b7d72bb28bb..6c3fd090d4a 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -55,6 +55,8 @@ #include "IMB_colormanagement.h" +#include "GPU_basic_shader.h" + #include "blf_internal_types.h" #include "blf_internal.h" @@ -486,7 +488,7 @@ void BLF_rotation_default(float angle) } } -static void blf_draw_gl__start(FontBLF *font, GLint *mode, GLint *param) +static void blf_draw_gl__start(FontBLF *font, GLint *mode) { /* * The pixmap alignment hack is handle @@ -494,9 +496,10 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode, GLint *param) */ glEnable(GL_BLEND); - glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + GPU_basic_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR); + /* Save the current matrix mode. */ glGetIntegerv(GL_MATRIX_MODE, mode); @@ -523,19 +526,10 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode, GLint *param) /* always bind the texture for the first glyph */ font->tex_bind_state = -1; - - /* Save the current parameter to restore it later. */ - glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param); - if (*param != GL_MODULATE) - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } -static void blf_draw_gl__end(GLint mode, GLint param) +static void blf_draw_gl__end(GLint mode) { - /* and restore the original value. */ - if (param != GL_MODULATE) - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param); - glMatrixMode(GL_TEXTURE); glPopMatrix(); @@ -545,8 +539,8 @@ static void blf_draw_gl__end(GLint mode, GLint param) if (mode != GL_MODELVIEW) glMatrixMode(mode); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); } void BLF_draw_ex( @@ -554,19 +548,19 @@ void BLF_draw_ex( struct ResultBLF *r_info) { FontBLF *font = blf_get(fontid); - GLint mode, param; + GLint mode; BLF_RESULT_CHECK_INIT(r_info); if (font && font->glyph_cache) { - blf_draw_gl__start(font, &mode, ¶m); + blf_draw_gl__start(font, &mode); if (font->flags & BLF_WORD_WRAP) { blf_font_draw__wrap(font, str, len, r_info); } else { blf_font_draw(font, str, len, r_info); } - blf_draw_gl__end(mode, param); + blf_draw_gl__end(mode); } } void BLF_draw(int fontid, const char *str, size_t len) @@ -579,12 +573,12 @@ void BLF_draw_ascii_ex( struct ResultBLF *r_info) { FontBLF *font = blf_get(fontid); - GLint mode, param; + GLint mode; BLF_RESULT_CHECK_INIT(r_info); if (font && font->glyph_cache) { - blf_draw_gl__start(font, &mode, ¶m); + blf_draw_gl__start(font, &mode); if (font->flags & BLF_WORD_WRAP) { /* use non-ascii draw function for word-wrap */ blf_font_draw__wrap(font, str, len, r_info); @@ -592,7 +586,7 @@ void BLF_draw_ascii_ex( else { blf_font_draw_ascii(font, str, len, r_info); } - blf_draw_gl__end(mode, param); + blf_draw_gl__end(mode); } } void BLF_draw_ascii(int fontid, const char *str, size_t len) @@ -603,13 +597,13 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len) int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth) { FontBLF *font = blf_get(fontid); - GLint mode, param; + GLint mode; int columns = 0; if (font && font->glyph_cache) { - blf_draw_gl__start(font, &mode, ¶m); + blf_draw_gl__start(font, &mode); columns = blf_font_draw_mono(font, str, len, cwidth); - blf_draw_gl__end(mode, param); + blf_draw_gl__end(mode); } return columns; |