LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 07-30-2004, 04:12 AM   #1
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Rep: Reputation: 30
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
 
Old 07-30-2004, 04:45 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
did you try a SDL_UpdateRect() right after your sprite stops ?
 
Old 07-31-2004, 07:52 AM   #3
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
Thanks Cedrik,

The sprite is a SDL_Surface, but I will try your suggestion this evening.

Regards,

unholy
 
Old 08-03-2004, 09:59 AM   #4
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
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
 
Old 08-03-2004, 11:34 AM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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);
 
Old 08-08-2004, 07:10 AM   #6
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
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.
 
Old 08-08-2004, 09:13 AM   #7
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
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.
 
Old 08-13-2004, 01:41 PM   #8
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Original Poster
Rep: Reputation: 30
Thanks a lot Cedrik, You've made my week!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installation problem re: SDL rwillard Linux - Newbie 3 05-17-2005 04:48 AM
Trying to program an SDL application but cannot find the SDL.h file:SuSE 9.2&KDevelop pujolasdf Linux - Newbie 4 03-13-2005 07:50 AM
SDL compiling problem kubaj Programming 2 10-27-2004 11:15 AM
gngeo and sdl problem huntermix Slackware 0 08-12-2004 05:15 PM
SDL compiltaion problem!!! buno Programming 1 09-29-2003 03:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration