[feat] update SDL2 to SDL3

This commit is contained in:
dijunkun
2025-08-25 19:46:30 +08:00
parent 9912a88a13
commit d60fdf9050
9 changed files with 205 additions and 234 deletions

View File

@@ -38,9 +38,10 @@ bool LoadTextureFromMemory(const void* data, size_t data_size,
}
// ABGR
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(
(void*)image_data, image_width, image_height, channels * 8,
channels * image_width, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
int pitch = image_width * channels;
SDL_Surface* surface =
SDL_CreateSurfaceFrom(image_width, image_height, SDL_PIXELFORMAT_RGBA32,
(void*)image_data, pitch);
if (surface == nullptr) {
LOG_ERROR("Failed to create SDL surface: [{}]", SDL_GetError());
return false;
@@ -55,7 +56,7 @@ bool LoadTextureFromMemory(const void* data, size_t data_size,
*out_width = image_width;
*out_height = image_height;
SDL_FreeSurface(surface);
SDL_DestroySurface(surface);
stbi_image_free(image_data);
return true;