[SDL] Do all SDL_Surfaces have to be initialized?

Paul Duffy odubtaig at yahoo.co.uk
Fri Sep 21 08:39:19 PDT 2007


On Sun, 2002-07-21 at 00:39 -0400, L-28C wrote:
> Hello everyone!
> Hey, just wondering...  Do all surfaces have to be initialized, even if 
> they are only 24x24 pixels?  This code returns false:
> 
> ====================
> if (this->sandTiles[x] = SDL_SetVideoMode(TILE_WIDTH, TILE_HEIGHT, 32, 
> SDL_SWSURFACE))
> {
> 	cout << x;
> 	exit(0);
> }
> ====================
> 
> Why is that?  Thanks!
> 
> P.S: Maybe this will help... lol:
> 
> Length of sandTiles:	3
> TILE_WIDTH:		24
> TILE_HEIGHT:		24
> x:			0 through 2 (stdout.txt gives 0)

The problem you've got there is that you're using the command to create
a display surface. What you actually want to do is use either
SDL_CreateRGBSurfaceFrom or (better) this->sandTiles[x] =
IMG_Load( <filename> ); which requires SDL_Image.

Have a look at http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fimage


		
___________________________________________________________ 
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street Journal 
http://uk.docs.yahoo.com/nowyoucan.html


More information about the SDL mailing list