Jump to content
  • Advertisement
Sign in to follow this  
RyanA

SDL_BlitSurface Woes

This topic is 4147 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'm currently working on a TTF Font class utilizing SDL/OpenGL/SDL_ttf. Everything *seems* to work, except one bug. I think I narrowed it down to a problem with SDL_BlitSurface. Here is what I did:
SDL_Surface *Initial;
SDL_Surface *Intermediary;

Initial = TTF_RenderText_Blended(TTF, Text, Color);
SDL_SaveBMP(Initial, "Initial.bmp");

W = NextPowerOfTwo(Initial->w);
H = NextPowerOfTwo(Initial->h);

Intermediary = SDL_CreateRGBSurface(0, W, H, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);

SDL_BlitSurface(Initial, 0, Intermediary, 0);
SDL_SaveBMP(Intermediary, "Intermediary.bmp");

And then this is the output: Initial.bmp (38x21) : Intermediary.bmp (64x32) : Anyone have any idea why the pixels aren't being blitted to the Intermediary surface? Thanks :) -Ryan

Share this post


Link to post
Share on other sites
Advertisement
Those surface masks look a bit odd. Its generally 0xrrggbbaa or 0xaabbggrr I think. But that may not be it.

I think you should do a *lot* more error checking. Check the return values of all SDL functions (even blitsurface has one) and if they are NULL (for pointers) or below zero( for most other functions ), then printf/cout the value of SDL_GetError() ( or TTF_GetError() for TTF functions).

Share this post


Link to post
Share on other sites
Ack! I was just deleting this post when you replied, rip-off. My apologies.

I dug more into the forums, and found out if you place:

SDL_SetAlpha(SDL_Surface_Here, 0, 0);

It'll blit fine.

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!