[SDL] SDL_CreateRGBSurface is black?

mutable rswhite4 at gmail.com
Sun Jul 11 14:20:23 PDT 2010


Hi i'm new here and my english isn't good, but i have the following code:

Code:

SDL_Surface * tile = SDL_CreateRGBSurface(
	SDL_SWSURFACE,
	tilesize[0],
	tilesize[1],
	this._tileset.format.BitsPerPixel,
	0, 0, 0, 0
);

for (ushort y = 0; y < height; y++) {
	for (ushort x = 0; x < width; x++) {
		SDL_Rect rect = {
			cast(ushort) (x * 16),
			cast(ushort) (y * 16),
			16, 16
		};

		SDL_BlitSurface(this._tileset, &rect, tile, null);
		if (!tile) {
			writeln("Tile konnte nicht aus dem Tileset geladen werden");
			exit(0);
		}

		this._tiles ~= tile;
	}
}



The tileset grafic is ok and the code give me no error, the lopp runs correct, but if i try to take one of the tiles to blit them on the screen, i get a black rectangle.
How is that possible? I think that SDL_CreateRGBSurface create the failure, but what think the others and can anyone help me?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20100711/d0eb4d25/attachment-0007.htm>


More information about the SDL mailing list