SDL_BlitSurface Woes

Started by
1 comment, last by RyanA 16 years, 11 months ago
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
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).
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.

This topic is closed to new replies.

Advertisement