graphics!: separate texture binding from the Bindings
struct
#521
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.
Warning
This PR will break most of the existing code
This PR aims to make MINIQUAD api more flexible by separating texture binding to its own method
RenderingBackend::apply_images
Why?
Sometimes i need to use the same buffer bindings (vertex and index buffers) for different sprites for example (because they all are quads), but creating a new
Bindings
for each sprite just to change their texture is tedious.This is especially frustrating when, for example, you need to load hundreds of .png files and create a texture for each of them. This can also lead to relatively huge memory usage and poor performance, as you need to allocate and store a vector of buffer IDs + another buffer ID for each texture.
Migration
Example
This code is significantly simplified for clarity
Initialization:
Drawing logic:
Drawing sprites:
Result:
P.S.
Thanks for your time!
Hopefully this PR will be merged, but as I said earlier, it will break most of the existing code.