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.32k stars 372 forks source link

Check if active preset output texture is valid before copying #824

Closed hack-s closed 2 months ago

hack-s commented 2 months ago

Possible fix for https://github.com/projectM-visualizer/projectm/issues/823

hack-s commented 2 months ago

I think a better fix would be using a nullptr for the output texture initially instead of initializing it empty. But that would be a more intrusive change.

kblaschke commented 2 months ago

I think a better fix would be using a nullptr for the output texture initially instead of initializing it empty. But that would be a more intrusive change.

I absolutely don't mind intrusive changes if they are cleaner. If there's no texture, we can surely leave the shared pointer empty. Easier to check, and not more complicated to initialize it later.

If you want to make this change, please do so, that'd be highly appreciated!

kblaschke commented 2 months ago

Issue comes from a preset not having an output texture yet (e.g. framebuffer color attachment is not yet initialized), so the texture has to be there, but will be created when the framebuffer is resized to something larger than 0x0, which happens on the first frame draw call.

Applied a fix to check for an empty texture ID in CopyTexture, and openend PRs #826 and #827, closing this one here.