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 364 forks source link

Add support for rendering to custom textures and FBOs #659

Open kblaschke opened 1 year ago

kblaschke commented 1 year ago

Currently, projectM is only able to render to any native/current surface and render-to-texture support was broken/unimplemented in 3.x and was removed in the 4.1 release renderer rewrite.

To enable proper integration into other applications, projectM should internally render to a framebuffer object, either a self-created one or an existing FBO provided by the external application. projectM should also make sure that the proper render states (e.g. disabling and reenabling the depth buffer) are set before rendering to prevent render errors.

Steps to implement:

As an alternative to passing in a custom FBO, it should also be possible to either retrieve a texture Id from projectM or pass in a texture ID from the outside. In this case, projectM will manage the FBO required to render to this texture internally.

kblaschke commented 3 weeks ago

Settling with just using a framebuffer object for now, as this will contain any offscreen texture. This keeps the API function count lower.