Bug report: SDL_CreateRGBSurface with SDL_HWSURFACE crashes on OS X

If SDL is in full-screen mode with a hardware video surface on OS X,
SDL_CreateRGBSurface with SDL_HWSURFACE crashes. The crash occurs on
line 109 of SDL_Surface.c. This was tested on OS X 10.3.9 with both SDL
1.2.8 and the latest CVS. Here is a small C++ program that demonstrates
the problem:

#include “SDL.h”
#include “acorn/graphics.hpp”
#include <stdio.h>

namespace {

void wait_for_key()
{
SDL_Event e;
printf("%d\n", SDL_GetAppState());
while (SDL_WaitEvent(&e)) {
if (e.type == SDL_KEYDOWN || e.type == SDL_QUIT) return;
}
}

}

int main(int, char *[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen
= SDL_SetVideoMode(640, 480, 32, SDL_FULLSCREEN | SDL_HWSURFACE);
SDL_Surface *s = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 32,
screen->format->Rmask, screen->format->Gmask,
screen->format->Bmask, screen->format->Amask);
wait_for_key();
if (s) SDL_FreeSurface(s);
SDL_Quit();
printf(“Success!\n”);
return 0;
}–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com

If SDL is in full-screen mode with a hardware video surface on OS X,
SDL_CreateRGBSurface with SDL_HWSURFACE crashes. The crash occurs on
line 109 of SDL_Surface.c. This was tested on OS X 10.3.9 with both SDL
1.2.8 and the latest CVS. Here is a small C++ program that demonstrates
the problem:

I put a patch in CVS to fix the crash (there was a NULL function pointer
in the Quartz driver for creating hardware surfaces).

However, please note that you won’t be able to create a hardware surface
on MacOS X (the CreateRGBSurface call will return a SWSURFACE)…this
patch just prevents the crash inside SDL. I don’t know if this is a
limitation of Quartz, or if it was just never implemented in SDL.

Usual advice applies: if you positively must have hardware surfaces, use
OpenGL…at least on MacOS, you know it’s a well-supported codepath.

Otherwise, someone please volunteer to implement this in the Quartz
driver if possible.

Thanks,
–ryan.