simplify SDL_DUMMY/OFFSCREEN_CreateWindowFramebuffer

This commit is contained in:
pionere 2022-01-22 10:33:38 +01:00 committed by Ryan C. Gordon
parent ecd922b5cf
commit 19df4af2aa
No known key found for this signature in database
GPG key ID: FA148B892AB48044
2 changed files with 4 additions and 12 deletions

View file

@ -33,17 +33,13 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
int w, h;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
/* Free the old framebuffer surface */
surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE);
SDL_FreeSurface(surface);
SDL_DUMMY_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
if (!surface) {
return -1;
}

View file

@ -34,17 +34,13 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * f
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
int w, h;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
/* Free the old framebuffer surface */
surface = (SDL_Surface *) SDL_GetWindowData(window, OFFSCREEN_SURFACE);
SDL_FreeSurface(surface);
SDL_OFFSCREEN_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
SDL_GetWindowSize(window, &w, &h);
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
if (!surface) {
return -1;
}