[SDL] Question about blitting...

L-28C leo28c at gmail.com
Sat Aug 12 14:55:03 PDT 2006


Dang...  How can I make it transparent then?  Thanks!

David Olofson wrote:
> On Saturday 12 August 2006 03:55, L-28C wrote:
>> Hello everyone!
>> OK...  I have a car, and I want to put windows on it.  How do I make 
> the 
>> windows so that they are transparent, like, so I can see the driver?  
> I 
>> have the window on a PNG file, and I set up the transparency in 
>> Photoshop, but it just shows up solid on SDL...  How do I blit it 
>> correctly?  I have the following code:
>>
>> =<code>==
>> // Create window surface
>> SDL_Surface *glass = SDL_CreateRGBSurface(SDL_HWSURFACE, 96, 96, 32, 
> 0, 
>> 0, 0, 0);
>>
>> // Blit the window from the PNG to the 'glass' surface
>> SDL_BlitSurface(this->vehicles[0].layers, &src, glass, &dest);
>>
>> // Set 100 transparency
>> SDL_SetAlpha(glass, SDL_SRCALPHA, 100);
>>
>> // Blit it to the car
>> SDL_BlitSurface(glass, &src, this->vehicles[0].bmp, &dest);
> 
> This will only *blend* the window onto the car. It will not affect the 
> alpha channel of the car, and thus, it cannot make the window on the 
> car transparent.
> 
> 
> //David Olofson - Programmer, Composer, Open Source Advocate
> 
> .-------  http://olofson.net - Games, SDL examples  -------.
> |        http://zeespace.net - 2.5D rendering engine       |
> |       http://audiality.org - Music/audio engine          |
> |     http://eel.olofson.net - Real time scripting         |
> '--  http://www.reologica.se - Rheology instrumentation  --'


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





More information about the SDL mailing list