Advertisement Jump to content
Sign in to follow this  
deathwearer

Color transparency with SDL?

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

1. iS there anyway to set a color transparency with SDL? OR is there anyway to make the image im moving always under the last one I used? (For a tetris game ) 2. Since i'm going to make a Tetris game, that mean i will load more than 5 images, and moslty an uncertain amount of images. Is there a way beside : SDL_Surface *Piece1; SDL_Surface *Piece2; SDL_Surface *Piece3; SDL_Surface *Piece4; etc. Like only use one for all the piece. [Edited by - deathwearer on August 4, 2005 11:31:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by deathwearer
1. iS there anyway to set a color transparency with SDL?

You mean a color key?

Quote:
OR is there anyway to make the image im moving always under the last one I used? (For a tetris game )

Not sure what you're asking, but sounds like it's a simple issue of drawing stuff in the right order.

Quote:
2. Since i'm going to make a Tetris game, that mean i will load more than 5 images, and moslty an uncertain amount of images. Is there a way beside :

SDL_Surface *Piece1;
SDL_Surface *Piece2;
SDL_Surface *Piece3;
SDL_Surface *Piece4;

etc. Like only use one for all the piece.

Well, you could do something like this:
SDL_Surface *Pieces[5];

Or you could just have all the pieces on one big surface, and then blit that portion of the surface whenever you need to draw a piece.

Share this post


Link to post
Share on other sites
1. Yes maybe a color key, i have pieace for tetris game but they of course all have some black around em and i would like to make it transparent.

2. The 2 solution sound good, but i wonder, when you blit the piece on the surface, that mean that it is now part of the background? so i can delete the pointer and use it again?

3. Also when you load an image, and then blit it with the backgound if it's possible, do i have to load the image once again?

[Edited by - deathwearer on August 5, 2005 9:22:01 AM]

Share this post


Link to post
Share on other sites
You can either use alpha blending, or SDL_SRCCOLORKEY.

You can only use color keying on 24 or less-bit surfaces(that is, no alpha channel). Use SDL_SetColorKey(your_surface,SDL_SRCCOLORKEY,SDL_MapRGB(your_surface->format,red_value,green_value,blue_value));
once before the first blit.
Otherwise, fire up some image editor, and make the black areas literally transparent.

Share this post


Link to post
Share on other sites
Ok Thank, i think it will be alright for the color transparency.

Now, concerning your post BradDaBug, are you saying i could "blit" one of the piece on the background?

If so when i'v done this, what shall i do before i re-use the image pointer?

Share this post


Link to post
Share on other sites
When you blit a surface on to another (such as the screen) it basically does a straight copy of the image data. This means that you can reuse the image without reloading it just fine.

Share this post


Link to post
Share on other sites
In your main loop, the first thing you should do is either clear the whole screen or reblit the whole background onto the screen. After that, you should blit all of the peices onto the screen, not the background.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!