directx - (Closed) C++ & Direct3D 9 - How to draw formatted text? (Like printf etc) -


i've started programming in c++ using directx. i'm not new c++ i've used allegro & sdl before. far, can draw text screen. however, have slight problem, cannot draw variable screen. ideally, want draw string + int value. have no idea how that. snippet of code far:

font->drawtexta(sprite, "score: ", -1, scorer, dt_calcrect, 0xffffffff); font->drawtexta(sprite, "score: ", -1, scorer, 0, 0xffffffff); 

as might expect, write "score: " screen. need write 'score' variable after that.

any appreciated.

you may use sprintf format string memory string, , print using drawtext

example: (not tested)

char formatted_string[100]; sprintf(formatted_string, "score: %d", score); font->drawtexta(sprite, formatted_string, -1, scorer, dt_calcrect, 0xffffffff); 

obviously illustrative, more polished.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -