29 lines
623 B
Text
29 lines
623 B
Text
|
|
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};
|
||
|
|
}
|
||
|
|
}
|