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:
authorMike Erwin <significant.bit@gmail.com>2016-10-12 04:21:02 +0300
committerMike Erwin <significant.bit@gmail.com>2016-10-12 04:21:02 +0300
commit683656681c994e6d1f91e63760a7b8d5ece15af5 (patch)
tree1c3c94887c6a0ff6cbed1119fc8f12dec6aa338b /source/blender/blenfont
parent06d4aca87956a8d276f97dedce7a021d86fc03f6 (diff)
BLF/OpenGL: use new matrix API when drawing text
First test of matrix API. This will eventually use the 2D part of this API, but the 3D part is ready now. Part of T49450
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 9bd43f7a69e..e43d2bba23c 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -57,6 +57,7 @@
#ifndef BLF_STANDALONE
#include "GPU_shader.h"
+#include "GPU_matrix.h"
#include "GPU_immediate.h"
#endif
@@ -491,7 +492,7 @@ void BLF_rotation_default(float angle)
}
}
-static void blf_draw_gl__start(FontBLF *font, GLint *mode)
+static void blf_draw_gl__start(FontBLF *font)
{
/*
* The pixmap alignment hack is handle
@@ -501,23 +502,18 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode)
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- /* Save the current matrix mode. */
- glGetIntegerv(GL_MATRIX_MODE, mode);
-
- if (*mode != GL_MODELVIEW)
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
+ gpuMatrixBegin3D_legacy();
if (font->flags & BLF_MATRIX)
- glMultMatrixf(font->m);
+ gpuMultMatrix3D(font->m);
- glTranslate3fv(font->pos);
+ gpuTranslate3fv(font->pos);
if (font->flags & BLF_ASPECT)
- glScalef(font->aspect[0], font->aspect[1], font->aspect[2]);
+ gpuScale3fv(font->aspect);
if (font->flags & BLF_ROTATION) /* radians -> degrees */
- glRotatef(font->angle * (float)(180.0 / M_PI), 0.0f, 0.0f, 1.0f);
+ gpuRotateAxis(font->angle * (float)(180.0 / M_PI), 'Z');
glGetFloatv(GL_CURRENT_COLOR, font->orig_col); /* TODO(merwin): new BLF_color function? */
@@ -538,12 +534,9 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode)
font->tex_bind_state = -1;
}
-static void blf_draw_gl__end(GLint mode)
+static void blf_draw_gl__end(void)
{
- glPopMatrix();
-
- if (mode != GL_MODELVIEW)
- glMatrixMode(mode);
+ gpuMatrixEnd();
#ifndef BLF_STANDALONE
immUnbindProgram();
@@ -557,19 +550,18 @@ void BLF_draw_ex(
struct ResultBLF *r_info)
{
FontBLF *font = blf_get(fontid);
- GLint mode;
BLF_RESULT_CHECK_INIT(r_info);
if (font && font->glyph_cache) {
- blf_draw_gl__start(font, &mode);
+ blf_draw_gl__start(font);
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);
+ blf_draw_gl__end();
}
}
void BLF_draw(int fontid, const char *str, size_t len)
@@ -582,12 +574,11 @@ void BLF_draw_ascii_ex(
struct ResultBLF *r_info)
{
FontBLF *font = blf_get(fontid);
- GLint mode;
BLF_RESULT_CHECK_INIT(r_info);
if (font && font->glyph_cache) {
- blf_draw_gl__start(font, &mode);
+ blf_draw_gl__start(font);
if (font->flags & BLF_WORD_WRAP) {
/* use non-ascii draw function for word-wrap */
blf_font_draw__wrap(font, str, len, r_info);
@@ -595,7 +586,7 @@ void BLF_draw_ascii_ex(
else {
blf_font_draw_ascii(font, str, len, r_info);
}
- blf_draw_gl__end(mode);
+ blf_draw_gl__end();
}
}
void BLF_draw_ascii(int fontid, const char *str, size_t len)
@@ -606,13 +597,12 @@ 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;
int columns = 0;
if (font && font->glyph_cache) {
- blf_draw_gl__start(font, &mode);
+ blf_draw_gl__start(font);
columns = blf_font_draw_mono(font, str, len, cwidth);
- blf_draw_gl__end(mode);
+ blf_draw_gl__end();
}
return columns;