[SDL] [Update] Can anyone please tell me what's wrong with this code?

L-28C leo28c at gmail.com
Tue Aug 8 21:59:15 PDT 2006


OK, after some fiddling around, I changed the initialization of 'bmp' to 
this:

=<Code>=================
this->vehicles[0].bmp = SDL_CreateRGBSurface(SDL_HWSURFACE, 96, 96, 32, 
0, 0, 0, 0);
=</Code>================

It works!  But then I get a black background (initial reason to use the 
transparent image file)...  How can I fix this?  Thanks!


L-28C wrote:
> Hello everyone!
> OK, here's the code:
> 
> =<Code>=================
> bool Game::t_DrawVehicle()
> {
> 	SDL_Rect src, dest;
> 	src.w = 96;
> 	src.h = 96;
> 
> 	dest.w = 96;
> 	dest.h = 96;
> 	dest.x = 0;
> 	dest.y = 0;
> 
> 	// Layer 1
> 	src.x = 0;
> 	src.y = 0;
> 	SDL_BlitSurface(this->vehicles[0].layers, &src, this->vehicles[0].bmp, 
> &dest);
> 
> 	SDL_UpdateRect(this->vehicles[0].bmp, 0, 0, 96, 96);
> 
> 	return true;
> }
> =</Code>================
> 
> The blit isn't working...  Here's the declaration of both surfaces 
> (they're not on the same func):
> 
> =<Code>=================
> this->vehicles[0].layers = IMG_Load("./Graphics/Vehicles/AZX-2400.PNG"); 
> //192x192
> 
> this->vehicles[0].bmp = IMG_Load("./Graphics/Transparent 96x96 
> Image.png"); //96x96
> =</Code>================
> 
> The 'layers' one works, because I can display it to the screen, but 
> 'bmp' just displays the original image it had... ("Transparent 96x96 
> Image.png", just a transparent box with a black pixel in the middle...)
> 
> Does anyone know why it's happening?  Thanks very much!
> 


-- 
~ Leo, M@$73r L3170, Sulfurik, Kixdemp, L-28C... Whatever you wanna call me.





More information about the SDL mailing list