[SDL] SDL_CreateSurfaceFrom crashes

L-28C kixdemp at gmail.com
Thu Aug 9 07:06:27 PDT 2007


> Uh - why?
Because I'm dumb and thought it would cause conflicts with Lua... XD

I made it a pointer and uppercased the 'B'.

And this code:

-----------------------
/* Create a 32-bit surface with the bytes of each pixel in R,G,B,A 
order, as expected by OpenGL for textures */
	
Uint32 rmask, gmask, bmask, amask;

/* SDL interprets each pixel as a 32-bit number, so our masks must 
depend on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
	rmask = 0xff000000;
	gmask = 0x00ff0000;
	bmask = 0x0000ff00;
	amask = 0x000000ff;
#else
	rmask = 0x000000ff;
	gmask = 0x0000ff00;
	bmask = 0x00ff0000;
	amask = 0xff000000;
#endif

Base = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
	rmask, gmask, bmask, amask);
-----------------------

provides per-surface alpha (nothing is displayed at first, then if I 
fill it with black my objects show over a black background, if I fill it 
with 50% white then it shows the same thing but transparent), and I need 
per-pixel alpha.

Also, that same code, for some reason makes blitting slow... :-/
Maybe I'm missing some depth conversions? Doesn't SDL convert all 
surfaces to screen depth upon creation? Or must I do that? What about 
images loaded with IMG_Load(...)?

Thanks all of you for helping this noob in despair!




More information about the SDL mailing list