PDA

View Full Version : vsprintf



01-09-2002, 11: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:


headers
float x

void myGlutReshape(GLsizei width, GLsizei height)
{
}

void myGlutDisplay( void )
{

want to output the text here
}

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

mikael_aronsson
01-10-2002, 01: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.

Mikael

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

Shag
01-10-2002, 03:23 PM
I think you misunderstodd something ... this is an OpenGL forum:
http://www.cprogramming.com/cboard/

Bob
01-10-2002, 10: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?