Jump to content
  • Advertisement
Sign in to follow this  
Edmond Tahiri


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

Use key.unicode instead of key.sym? Not sure if it already handles things such as shift and etc, but it's a start...

Misread the post.

Generally, you'd have a table of SDL_Rects you index into to select where in the bitmap that character resides:

Slightly pseudo-code:

SDL_Rect glyphBounds[256];

// load into file
std::ifstream fs( "bitmap_font.txt" );
for ( int idx = 0; idx < 256 && fs >> glyphBounds[idx]; ++idx )

// draw:
std::string str = "Hello";
int x = 0, y = 0;
for ( int idx = 0; idx < str.length(); ++idx ) {
const SDL_Rect& r = glyphBounds[str[idx]];
draw( x, y, bmpFont, r );
x += r.width;
Edited by fastcall22

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!