Jump to content
  • Advertisement
Sign in to follow this  
juanmanuelsanchez

glCallLists questions

This topic is 4161 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 ! Im trying to render the FPS in my viewport, I can do strings but since FPS are floats Im kinda stuck. Here is the function that renders the font
void BitMapFont::RenderFontF(int xPos, int yPos, unsigned int base, const GLfloat str)
{
	if ((base == 0) || (!str))
		return;

	glRasterPos2i(xPos, yPos);
	glPushAttrib(GL_LIST_BIT);
	glListBase(base - 32);
	glCallLists((int)strlen(str), GL_UNSIGNED_BYTE, str);
	glPopAttrib();
}


The thing is that I know I cant use strlen for the float, wich alternative can I use? and the other thing is that I get this error "lCallLists' : cannot convert parameter 3 from 'const float' to 'const void *'" and Im not sure how to solve it

Share this post


Link to post
Share on other sites
Advertisement
glCallLists expects a pointer to a continous block of memory containing chars, you are trying to give it a float. You need to first parse the float as a string.


std::stringstream ss();

ss << myFloat;

std::string myString = ss.str();

//myString.c_str(); returns const char array to use with glCallLists

glCallLists(myString.size(), GL_UNSIGNED_BYTE, myString.c_str());




I recommend that you go back and review your C++ book to get a better understanding of types.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!