Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-30-2004, 04:12 AM
|
#1
|
Member
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344
Rep:
|
SDL transparency problem
I have 2 sprites in an sdl program. Sprite A has a large transparent center, sprite B is solid.
The transparency works fine for A as long as it is moving...however, if A stops on top of B (B is now visible through the transparency in A) - and B moves away, the image of B is still displayed as A's transparency, even though it is gone.
Sprite A has to be moved a distance for the correct transparency to be restored. Is this a common problem?
I can post code, but it's 300 lines long and I dont really know which sections are relevant.
Thanks in advance,
unholy
|
|
|
07-30-2004, 04:45 AM
|
#2
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
did you try a SDL_UpdateRect() right after your sprite stops ?
|
|
|
07-31-2004, 07:52 AM
|
#3
|
Member
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344
Original Poster
Rep:
|
Thanks Cedrik,
The sprite is a SDL_Surface, but I will try your suggestion this evening.
Regards,
unholy
|
|
|
08-03-2004, 09:59 AM
|
#4
|
Member
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344
Original Poster
Rep:
|
Cedrik,
I changed my sprite for a single image with a transparency, and there was no problem. I did also did not need to use updateRectangle(...).
But when I use a sprite, the problem does occur, and updateRectangle doesnt seem to help, the transparency doesnt get refresed unless the sprite is moved.
My sprite code came from this tutorial
http://cone3d.gamedev.net/cgi-bin/in...ls/gfxsdl/tut3
|
|
|
08-03-2004, 11:34 AM
|
#5
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
Code:
In the void CSprite::updateBG() function, I would try to add :
...
SDL_BlitSurface(mScreen, &srcrect, mBackreplacement, NULL);
SDL_UpdateRects(mScreen, 1, &srcrect);
and in the void DrawIMG(SDL_Surface *img, int x, int y) function :
...
SDL_BlitSurface(img, NULL, screen, &dest);
SDL_UpdateRects(screen, 1, &dest);
|
|
|
08-08-2004, 07:10 AM
|
#6
|
Member
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344
Original Poster
Rep:
|
Thanks Cedrik, I'll try that again.
Are there any other good resources for learning SDL? I have the documentation project stuff, and the tutorials from the website. I dont mind buying a book, but I'd prefer something on soft copy.
|
|
|
08-08-2004, 09:13 AM
|
#7
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
There is a nice book in PDF format here And you may want to browse the source directory to download source examples from the book.
Last edited by Cedrik; 08-08-2004 at 09:16 AM.
|
|
|
08-13-2004, 01:41 PM
|
#8
|
Member
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344
Original Poster
Rep:
|
Thanks a lot Cedrik, You've made my week!
|
|
|
All times are GMT -5. The time now is 11:00 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|