a while back i asked how i could output floats into an opengl window as text, i was told to use vsprintf

i already went through the NeHe tutorial, but my program structure is a bit different, and it’s not explained very well, could someone give me like a 10 line example of how to output a float using this general structure:

float x

void myGlutReshape(GLsizei width, GLsizei height)

void myGlutDisplay( void )

want to output the text here

void main(int argc, char* argv[])

Hi !

I think you missunderstood something, (v)sprintf puts the float in a buffer as a text string, but to display that in the OpenGL window you need to create a font for this (wglUseOutLineFonts for example), you can also use bitmap fonts or create the font as a texture.


thanks for replying, but how do i:
use (v)sprintf put the float in a buffer as a text string

I think you misunderstodd something … this is an OpenGL forum:

float myFloat = 1.23;
char buffer[512];
sprintf(buffer, “my own float = %f”, myFloat);

You didn’t bother looking in some manual/reference, did you?