[SDL] data type of void pixels in SDL_Surface

Peter Mulholland darkmatter at freeuk.com
Fri Oct 6 12:31:48 PDT 2006


Hello matt,

Friday, October 6, 2006, 8:24:11 PM, you wrote:

> i am drawing pixels directly to the pixels buffer in the struct  
> SDL_Surface.  i can get it to work but gets messy when i change to a 
> different arch.  seems that the void is a char, short, or an int.  i was
> using it as an array of char, but i am noticing endian issues.  i was 
> coding for big and little endian, but at a loss when the BitsPerPixel is
> 24 and/or the BytesPerPixel is 3.  is there a correct way to code with
> the void pointer and determine the rgba order for all video modes?

Macro-ize it and have the macro's change depending on whether you're
compiling on big or little endian systems. Unfortunately, there is no
automatic way to do it other than that.

24bpp is a big pain which is why it's seldom used now. It is much
better to use 32bpp and just set alpha to 255 in each pixel, or use
16bpp if 32bpp is not available.

-- 
Best regards,
 Peter                            mailto:darkmatter at freeuk.com





More information about the SDL mailing list