Sign in to follow this  

itoa (_itoa_s) analog for float ?

Recommended Posts

I'm getting current color in my app by code: GLfloat arr[3] = {0,0,0}; glGetFloatv(GL_CURRENT_COLOR,arr); now I need to display it throught such routine: drawString(-1.9f, 1.9f, GLUT_BITMAP_HELVETICA_18, somestring); where drawSrting is void drawString(float x, float y,void *font, char *string) { char *c; glRasterPos2f(x, y); for (c=string; *c != '\0'; c++) glutBitmapCharacter(font, *c); } So how to convert my GLfloat array to char* string - to pass it to my func?

Share this post

Link to post
Share on other sites
Erm, if I understand correctly, which I might not:

GLfloat arr[3] = {0,0,0};

char nString[128];
sprintf(nString, "%f,%f,%f", arr[0],arr[1],arr[2]);


CString nString;
nString.Format("%f,%f,%f", arr[0],arr[1],arr[2]);

//Then pass nString.GetString() into your text drawing function...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this