-
-
Notifications
You must be signed in to change notification settings - Fork 437
Add texture loading callback for custom texture sources #956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Adds a callback that allows applications to provide textures from non-filesystem sources like archives, network, or procedurally generated content. The callback receives the texture name and can return either raw pixel data or an existing OpenGL texture ID. Fixes #870
Move TextureLoadData and TextureLoadCallback from TextureManager.hpp to a separate TextureTypes.hpp header. This allows ProjectM.hpp to include only the necessary types without pulling in internal dependencies that aren't installed.
450d192 to
a3812ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for loading textures from non-filesystem sources through a callback mechanism. Applications can now provide textures from archives, network sources, or generate them procedurally. The callback can return either raw pixel data or an existing OpenGL texture ID, with automatic fallback to filesystem loading if the callback doesn't provide the requested texture.
Changes:
- Added
TextureLoadCallbacktype andTextureLoadDatastructure to define the callback interface - Extended TextureManager to try callback-based loading before filesystem loading
- Exposed the callback through both C++ (
ProjectM::SetTextureLoadCallback) and C (projectm_set_texture_load_event_callback) APIs - Updated CMakeLists.txt to install new public headers (TextureTypes.hpp, WaveformAligner.hpp, Logging.hpp)
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libprojectM/Renderer/TextureTypes.hpp | Defines TextureLoadData structure and TextureLoadCallback type for the callback interface |
| src/libprojectM/Renderer/TextureManager.hpp | Adds SetTextureLoadCallback method and member variable to store callback |
| src/libprojectM/Renderer/TextureManager.cpp | Implements callback invocation in TryLoadingTexture, checking callback before filesystem loading |
| src/libprojectM/ProjectM.hpp | Exposes SetTextureLoadCallback method in C++ API |
| src/libprojectM/ProjectM.cpp | Stores callback and ensures it's re-applied when TextureManager is recreated |
| src/libprojectM/ProjectMCWrapper.hpp | Adds member variables to store C callback and user data |
| src/libprojectM/ProjectMCWrapper.cpp | Implements C-to-C++ callback bridge with lambda wrapper |
| src/api/include/projectM-4/callbacks.h | Defines C API types and functions for texture loading callback |
| src/libprojectM/CMakeLists.txt | Adds TextureTypes.hpp, WaveformAligner.hpp, and Logging.hpp to installation list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a callback that allows applications to provide textures from non-filesystem sources like archives, network, or procedurally generated content. The callback receives the texture name and can return either raw pixel data or an existing OpenGL texture ID.
Fixes #870