Load image file and create texture separately with SOIL2

The new combined function no longer returns the image size, so we need to load the image ourselves, store the size and then pass the buffer to SOIL_create_OGL_texture().
This commit is contained in:
Kai Blaschke
2025-11-11 15:39:43 +01:00
parent 413c6d7d06
commit 5158ecbf7a

View File

@ -212,13 +212,23 @@ auto TextureManager::LoadTexture(const ScannedFile& file) -> std::shared_ptr<Tex
int width{};
int height{};
int channels{};
unsigned int const tex = SOIL_load_OGL_texture(
file.filePath.c_str(),
SOIL_LOAD_RGBA,
std::unique_ptr<unsigned char, decltype(&SOIL_free_image_data)> imageData(SOIL_load_image(file.filePath.c_str(), &width, &height, &channels, SOIL_LOAD_RGBA), SOIL_free_image_data);
if (imageData == nullptr)
{
return {};
}
unsigned int const tex = SOIL_create_OGL_texture(
imageData.get(),
&width, &height, SOIL_LOAD_RGBA,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MULTIPLY_ALPHA);
imageData.reset();
if (tex == 0)
{
return {};