Add texture loading callback for custom texture sources#956
Merged
Conversation
450d192 to
a3812ea
Compare
There was a problem hiding this comment.
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.
Member
|
I do not like to talk to Coslop in code reviews... |
kblaschke
reviewed
Feb 1, 2026
kblaschke
reviewed
Feb 1, 2026
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. Changes: - Add SetTextureLoadCallback API for custom texture loading - Add texture ownership tracking to prevent deletion of app-provided textures - Update texture creation to use stb_image instead of SOIL - Add validation and error logging for callback-provided textures Fixes #870 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
74ca73d to
241c279
Compare
Member
Author
|
Addressed the feedback:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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