Skip to content

Commit

Permalink
updated FrameBufferWindow to use the added types from the fb video dr…
Browse files Browse the repository at this point in the history
…iver
  • Loading branch information
GPF committed Oct 24, 2024
1 parent 14f3e7b commit 615c485
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/video/dreamcast/SDL_dreamcastframebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,35 @@
#include "SDL_dreamcastframebuffer_c.h"

#define DREAMCAST_SURFACE "_SDL_DreamcastSurface"

int SDL_DREAMCAST_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
{
SDL_Surface *surface;
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
int w, h;

/* Free the old framebuffer surface */
SDL_DREAMCAST_DestroyWindowFramebuffer(_this, window);

/* Create a new one */
SDL_GetWindowSizeInPixels(window, &w, &h);
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, surface_format);

// Retrieve the display mode's format to ensure consistency with the surface creation
SDL_DisplayMode mode;
if (SDL_GetWindowDisplayMode(window, &mode) != 0) {
return SDL_SetError("Failed to get window display mode");
}

// Use the format from the display mode or fallback to the default
Uint32 surface_format = mode.format;
if (surface_format != SDL_PIXELFORMAT_RGB565 &&
surface_format != SDL_PIXELFORMAT_ARGB1555 &&
surface_format != SDL_PIXELFORMAT_RGB888 &&
surface_format != SDL_PIXELFORMAT_ARGB8888) {
surface_format = SDL_PIXELFORMAT_RGB888; // Default format if unsupported
}

// Create the surface with the appropriate format
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h,
SDL_BITSPERPIXEL(surface_format),
surface_format);
if (!surface) {
return -1;
}
Expand All @@ -51,8 +67,6 @@ int SDL_DREAMCAST_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for
return 0;
}

#include <string.h> // For memcpy

int SDL_DREAMCAST_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
{
SDL_Surface *surface;
Expand Down

0 comments on commit 615c485

Please sign in to comment.