View Full Version : vsprintf

01-09-2002, 10:03 AM
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[])

01-10-2002, 12:22 AM
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.


01-10-2002, 01:40 PM
thanks for replying, but how do i:
use (v)sprintf put the float in a buffer as a text string

01-10-2002, 02:23 PM
I think you misunderstodd something ... this is an OpenGL forum:

01-10-2002, 09:12 PM
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?