diff options
author | Diego Borghetti <bdiego@gmail.com> | 2010-12-09 07:36:58 +0300 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2010-12-09 07:36:58 +0300 |
commit | b25c32393d42c314c073ef2244cde1fabb7b64af (patch) | |
tree | a295abf9b556d1fdc8ed2d8d555f602bc1f874ce /source/blender/blenfont/intern/blf.c | |
parent | 36175f37c9d3ea128cfdcebd1c1b438494b34433 (diff) |
Add the possibility to set a 4x4 matrix to be used on blf.
This option allow the user to set a 4x4 matrix to be
multiplied before draw the text, for example:
double *m;
/* Get the matrix or build it! */
BLF_matrix(m);
BLF_enable(BLF_MATRIX);
/* set color, size, etc and draw! */
BLF_disable(BLF_MATRIX);
You don't need the last line (disable), but remember
that if you use the font to draw in any other place,
the matrix will be used!.
The GL code is:
glPushMatrix();
glMultMatrixd(m);
glTranslatef();
glScalef();
glRotatef();
glPopMatrix();
Let's Dalai test this!!! :D
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index febd3d9d6f7..d9a02b09336 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -330,6 +330,18 @@ void BLF_aspect(int fontid, float aspect) font->aspect= aspect; } +void BLF_matrix(int fontid, double *m) +{ + FontBLF *font; + int i; + + font= BLF_get(fontid); + if (font) { + for (i= 0; i < 16; i++) + font->m[i]= m[i]; + } +} + void BLF_position(int fontid, float x, float y, float z) { FontBLF *font; @@ -435,6 +447,10 @@ static void blf_draw__start(FontBLF *font) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPushMatrix(); + + if (font->flags & BLF_MATRIX) + glMultMatrixd((GLdouble *)&font->m); + glTranslatef(font->pos[0], font->pos[1], font->pos[2]); glScalef(font->aspect, font->aspect, 1.0); |