Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FontRender( RMesh *mesh, RFontMap const *font, float scale, char const *text )
- {
- int_t len = strlen(text);
- int_t vcount = len * 6;
- void *buf = gRender.temp_allocator->alloc( sizeof(font_vert_t) * vcount );
- ASSERT_RETURN( NULL != buf );
- CArray verts;
- verts.init( buf, sizeof(font_vert_t), vcount );
- vector2_fl pos = vector2_fl(0.0f);
- vector2_fl kerning;
- glyph_t *last_glyph = NULL;
- char const *c = text;
- while (*c != NULL) {
- char v = *c;
- glyph_t *glyph = FindGetGlyph( font, v );
- FontGetKerning( &kerning, font, last_glyph, glyph );
- pos.add( kerning * scale );
- CreateRectForGlyph( &verts, pos, scale, glyph );
- pos.add( glyph->advance * scale );
- last_glyph = glyph;
- ++c;
- }
- MeshMapVertices( mesh, buf, vcount );
- gRender.temp_allocator->free(buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement