-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
Issue description
- I had an issue where textures were loaded upside-down.
- As it turns out, stb_image has thread-local variables to make an image be flipped after loading here.
- With
-O3, these variables are not initialized and contain garbage. With-O0they are zeroed apparently. - As a result, they evaluate to
trueand the STBI image loading code took the branch (if (stbi__vertically_flip_on_load)) to vertically flip the image.
Environment
clang 16.0.6 (from zig 0.12.0-dev.252+5dc2db805), mingw64, -O3 (-Doptimize=ReleaseFast)
Code Example
examples/textures/textures_image_loading.c
Suggested Fix
- Either the thread-locals are kept and initialized with
stbi_set_flip_vertically_on_load_threadbefore being used, or - I prefer disabling them with
#define STBI_NO_THREAD_LOCALSinrtextures.c(1-line PR will follow)
Metadata
Metadata
Assignees
Labels
No labels