ivlab / MinGfx

Minimalist cross-platform package for 2D/3D graphics. Primarily for use with student projects in courses.
Apache License 2.0
12 stars 7 forks source link

Const specifier in Texture2D is blocking stbi_image_free(data_); #25

Open dtorban opened 8 months ago

dtorban commented 8 months ago

Saw there was a comment here about not being able to call stbi_image_free(...):

https://github.com/ivlab/MinGfx/blob/b5f51d9c17b88c0777b3ff48c1eaf349eaec8f12/src/texture2d.cc#L52C11-L52C34

I'm pretty sure this is because it is defined as const unsigned char* here:

https://github.com/ivlab/MinGfx/blob/b5f51d9c17b88c0777b3ff48c1eaf349eaec8f12/src/texture2d.h#L124

Removing the const should fix this issue. Otherwise, we could always make a copy of the array so that it is const and free after the copy.