Jump to content
  • Advertisement
Sign in to follow this  
nickme

Opengl:how To Calculate The Width And Height Of A String Of Char?

This topic is 882 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

I just want to know whether it is possible to calculate the width and height of a string of char.

 

suppose i have a string of char and wanted to calculate the width of the whole string "Hello, world!," what functions should i call?

 

char *C = "Hello, world!";

 

for (int i = 0; C != 0; i ++)

            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, C);
 
if i can calculate the width and height of a single char i can figure out the rest. what is the convention in telling the width of GLUT_BITMAP_HELVETICA_24?
 
THANKS

Share this post


Link to post
Share on other sites
Advertisement

hi

 

I found the solution:

 

glutBitmapWidth(GLUT_BITMAP_HELVETICA_18, c);
 
thanks for reading.

Share this post


Link to post
Share on other sites

 

I found the solution:

glutBitmapWidth(GLUT_BITMAP_HELVETICA_18, c);

 

 

Outside of the GLUT world you need to handle this by your own. Bitmap fonts are assembled from a texture and certain metrics structs determining each character on that texture. Here it is simply iterating each character and get the mectrics to calculate width and height of a string

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!