Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

penetrator

C++: displaying floats

This topic is 5428 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, when i use a gcvt function to convert, for example, 0.02 to a char, when i display it i get "3.e-002". How can i print the 0.02 value instead ?

Share this post


Link to post
Share on other sites
Advertisement
thx for your help, i have a printing routine as follows:

GLvoid glPrint_IMG(GLint x, GLint y, char *string, int set) // Where The Printing Happens
{

glBindTexture(GL_TEXTURE_2D, texture_IMG[0]); // Select Our Font Texture
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(base_IMG-32+(128*set)); // Sets The Base Character to 0
glCallLists(strlen(string), GL_BYTE, string); // Draws The Display List Text
glPopAttrib();

}

so i try to use it like this: glPrint_IMG(0,0,&float_str,0);

But i get the following error:
error C2664: ''glPrint_IMG'' : cannot convert parameter 3 from ''class std::basic_string,class std::allocat
or > *'' to ''char *''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

Share this post


Link to post
Share on other sites
yep, it worked using it like this:

const char * szWork = float_str.c_str();
glPrint_IMG(0,0,szWork,0);

thanks everybody for helping me !

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!