I’m writing programs in C that use SDL for graphics. I have my program optimized for writing video in a 32 bits per pixel mode. I just go along each scan line writing blue, green, red, skip, blue, green, red, skip, blue, green, red, skip (skipping those extra bytes in the 32 bpp format). Is there any chance this could fail? Could SDL deny me 32 bpp and give me something else instead? Could the byte offsets of different colors end up in a different order and screw up my program?
Share
The
SDL_SetVideoModeby default ensures you get your required pixel depth. Even if the pixel depth is not available, it emulates it virtually (they call this “shadow surface”). Ofcourse, this can be disabled with theSDL_ANYFORMATflag.For more information, refer the following wiki
http://sdl.beuc.net/sdl.wiki/SDL_SetVideoMode
I am also suspecting that there might be a perfomance degradation if the depth is being emulated. Not sure on that.
Also with regards to your logic, I am not sure why you are doing such a native scan line manipulation. If your application really requires such control, then you are probably better off writing OpenGL or DirectX specific code and interface them with SDL through library calls. You can google up for more on interfacing OpenGL or DirectX with SDL.