Add wrappers for SDL functions and structs

This commit is contained in:
Lexi / Zoe 2025-11-23 21:50:57 +01:00
parent 4277f4c818
commit d180b8a5b4
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
18 changed files with 410 additions and 206 deletions

View file

@ -0,0 +1,28 @@
module;
#include <string>
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
export module wrappers.sdl_image;
import utils.memory;
import wrappers.sdl.error;
import wrappers.sdl.render;
export namespace sdl_image
{
/**
* Wrapper around IMG_LoadTexture().
*/
sdl::Texture LoadTexture(const sdl::Renderer& renderer, const std::string& filename)
{
SDL_Texture* sdl_texture = IMG_LoadTexture(renderer.get_raw(), filename.c_str());
if (sdl_texture == nullptr) {
throw sdl::SDLException("IMG_LoadTexture");
}
return sdl::Texture{sdl_texture};
}
}