diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
commit | 874c29cea8e6f9bc411fccf2d6f4cb07e94328d0 (patch) | |
tree | 5971e577cf7c02e05a1e37b5ad058c71a6744877 /source/blender/gpu | |
parent | 7555bfa793a2b0fc187c6211c56986f35b2d7b09 (diff) | |
parent | c5bc4e4fb1a33eda8c31f2ea02e91f32f74c8fa5 (diff) |
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes:
* blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7f5f85e23a6..0e123d872fe 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -83,7 +83,18 @@ void GPU_render_text(MTFace *tface, int mode, Image* ima; int characters, index, character; float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; - + float advance_tab; + + + /* multiline */ + float line_start= 0.0f, line_height; + if (v4) + line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]); + else + line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]); + line_height *= 1.2; /* could be an option? */ + /* end multiline */ + characters = textlen; ima = (Image*)tface->tpage; @@ -97,12 +108,32 @@ void GPU_render_text(MTFace *tface, int mode, glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); + + /* get the tab width */ + matrixGlyph((ImBuf *)ima->ibufs.first, ' ', & centerx, ¢ery, + &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); + + advance_tab= advance * 4; /* tab width could also be an option */ + + for (index = 0; index < characters; index++) { float uv[4][2]; // lets calculate offset stuff character = textstr[index]; + if (character=='\n') { + glTranslatef(line_start, -line_height, 0.0); + line_start = 0.0f; + continue; + } + else if (character=='\t') { + glTranslatef(advance_tab, 0.0, 0.0); + line_start -= advance_tab; /* so we can go back to the start of the line */ + continue; + + } + // space starts at offset 1 // character = character - ' ' + 1; matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, ¢ery, @@ -143,6 +174,7 @@ void GPU_render_text(MTFace *tface, int mode, glEnd(); glTranslatef(advance, 0.0, 0.0); + line_start -= advance; /* so we can go back to the start of the line */ } glPopMatrix(); } |