Skip to content

Commit 5f8a0e7

Browse files
committed
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().
1 parent 413c6d7 commit 5f8a0e7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/libprojectM/Renderer/TextureManager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,18 @@ auto TextureManager::LoadTexture(const ScannedFile& file) -> std::shared_ptr<Tex
212212

213213
int width{};
214214
int height{};
215+
int channels{};
215216

216-
unsigned int const tex = SOIL_load_OGL_texture(
217-
file.filePath.c_str(),
218-
SOIL_LOAD_RGBA,
217+
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);
218+
219+
unsigned int const tex = SOIL_create_OGL_texture(
220+
imageData.get(),
221+
&width, &height, SOIL_LOAD_RGBA,
219222
SOIL_CREATE_NEW_ID,
220223
SOIL_FLAG_MULTIPLY_ALPHA);
221224

225+
imageData.reset();
226+
222227
if (tex == 0)
223228
{
224229
return {};

0 commit comments

Comments
 (0)