Initial image implementation #5
Open
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 initial support for
PImagebacked by abevy::image::Image. This doesn't include everything we'll need, just enough to render a background image to demonstrate the basic flow works.Some important implementation notes:
Entityrather than exposeHandle<Image>to users. This allows us to have a consistent return type across FFI for anything stored in the ECS.PImagestores a variety of things useful for interacting with an image, most notable including a readback staging buffer for us to copy it into. This is expensive (basically doubles the cost of every texture in vram) but avoids having to allocate on demand when the user callsloadPixels. We can add more intelligent deferral/caching later.image.rs. In short, to avoid annoying borrowing errors when interacting with&mut World, we create a one-off system that we call instead, which allows Bevy to do the validation at runtime that our borrows are okay. A basic sketch of how this works:You may not have seen systems with
Inparameters and return arguments, but systems can accept context this way when called directly! Note that thecachedon theworld.run_system_cached_withmeans that the system is registered behind the scenes so its query will be cached.Minor notes:
create_surfacetosurface_createto properly namespace things in our FFI layer. We'll probably want to go even further here just for good measure (i.e.processing_graphics_begin_draw) but that's for another PR.