projectM-visualizer / projectm

projectM - Cross-platform Music Visualization Library. Open-source and Milkdrop-compatible.
https://discord.gg/mMrxAqaa3W
GNU Lesser General Public License v2.1
3.22k stars 365 forks source link

Search preloaded random textures in TextureManager::GetRandomTexture #783

Closed dpw13 closed 4 months ago

dpw13 commented 4 months ago

We currently only check textures loaded from files when selecting a random texture. Since we purge textures between presets, if a preset uses something like sampler_rand00, no presets will be found, the returned sampler will be null, and we end up creating invalid GLSL. This PR doesn't check the results of GetRandomSampler to make sure they're valid, but does extend GetRandomSampler to include preloaded textures. As this list includes volumetric textures, also filter textures by type. This type defaults to 2D textures and is not otherwise specified elsewhere as I can't find evidence that GetRandomSampler is ever expected to return a 3D texture.

dpw13 commented 4 months ago

This turned out to be an empty search path in frontend-sdl2, which I'll fix separately. It looks like things work as expected when the texture search path is sane.