Displaying variables as text on screen

how can i display my variables on the screen for real-time testing purposes? i can display strings on screen, but it only accepts “strings” and i always get these errors:

cannot convert parameter from ‘float’ to ‘char *’

where i replace the strings with a different data type…

anyone have any ideas?

thank you =]

Sounds like you’re trying to cast a float into a string, you can’t do that, you need (in most programming languages), to convert it yourself…

CJ

how do i convert it?

 void PrintFloat(float value, int x, int y) {
 char c[32];

 sprintf(c, "%16.8f", value);
 glRasterPos2i(x, y);
 glCallLists(strlen(c), GL_UNSIGNED_BYTE, c); }
 

…assuming that you had a call to glXUseXFont() or something similar before.

is that the best way to go about dispalying variables? is that how you woud do it? if not, how would you?

Well, for C code sprintf is as good as they get. If you want to use pure C++ maybe you’d like to take a look at stringstreams (one word!)

that is the best way for me to show variables on the screen. otherwise i would not have posted it :slight_smile:

but to be honest, the best way to watch over variables while running a prog is:

  1. throw away your windows
  2. install linux
  3. now you can run a window-based prog, which may even use opengl, and you still can use >printf< to display whatever you want in a terminal.