diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-09 13:50:17 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-09 13:50:17 +0400 |
commit | eacf5b5d6d406492ba79b44f9319867230585e9b (patch) | |
tree | 15e5b8ce210f7e8d889edf3ca40b3ee2c3a05904 /source/blender/gpu | |
parent | ba4ad93eada475e607831ce17883d04d1575bc32 (diff) |
BGE Text
- multi-line strings for bitmap text
- keyboard sensor now logs return and pad enter as "\n"
BGE std::vector use in Value.cpp and RAS_MaterialBucket.cpp
The size of a new list is known before making them, reduce re-allocs, though probably not a noticeable speedup.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 3c1c280a727..c0033c89d5c 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -84,6 +84,15 @@ void GPU_render_text(MTFace *tface, int mode, int characters, index, character; float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; + /* 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 +106,19 @@ void GPU_render_text(MTFace *tface, int mode, glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); + 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; + } + // space starts at offset 1 // character = character - ' ' + 1; matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, ¢ery, @@ -143,6 +159,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(); } |