2

DrawText's first argument needs to be a const(char)* but i tried using to! for that and have failed :(

yVel = to!(string)(player.vel.y);
DrawText(yVel, player.pos.x, player.pos.y - 40, 20, RAYWHITE);

How to properly convert from float to const(char)* ?

Soft Waffle
  • 356
  • 1
  • 12

1 Answers1

3

to!string converts from float to string. Then toStringz converts from string over to a const char*. So just combine them.

Or for more control and efficiency, you could define a little stack buffer and sprintf or something as well.

Generally some_string.ptr will give something you can use as const char*, just make sure you put the 0 terminator at the end before passing it to most C or Windows functions.

Adam D. Ruppe
  • 25,382
  • 4
  • 41
  • 60