Add wrappers for SDL functions and structs
This commit is contained in:
parent
4277f4c818
commit
d180b8a5b4
18 changed files with 410 additions and 206 deletions
28
src/wrappers/sdl_image.cppm
Normal file
28
src/wrappers/sdl_image.cppm
Normal 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};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue