Provide built-in API for generating "render target texture" and/or simplify "Render to Texture" example #7358
Labels
A-Rendering
Drawing game state to the screen
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Straightforward
Simple bug fixes and API improvements, docs, test and examples
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
What problem does this solve or what need does it fill?
A snippet from the Render to Texture example on main:
There's quite a lot going on in this snippet that, not coming from a rendering background, and just wanting to make pretty pictures, I simply don't understand.
What solution would you like?
My less-preferred solution is to simplify the example by creating a helper function, that uses the
Default
impl forImage
, and calling it in thesetup
.By using the
Default
impl it also removes 3use
s, and perhaps the remaininguse
s withinfn create_render_target_texture
could be put into the body or fully qualified.My more-preferred solution would be to expose this same helper function (with a better name) as a constructor on
Image
. The example can simply call that constructor.What alternative(s) have you considered?
Leave it as it is, and force future users to dive into (some of) the implementation details to understand what's going on.
Perhaps there is a missing higher level API to achieve the same outcomes?
Being new to rendering in general, there are a large number of properties that I'm not really sure what they do (hence my reliance on the
Default
impl). Maybe some of these it makes sense to expose as parameters for the helper function / constructor.Additional context
Initially all I had read was the Bevy 0.8 release notes, and just tried to construct an
Image
and see if I could get it working(I thought it couldn't be that hard), then I got a few crashes / things I had to import / all these weird rendering concepts / etc., until I folded and decided to see if there was an example (and of course there was).
Strictly speaking, there are two small differences between my proposed version and the example:
The example sets the
size
when initially constructing theImage
, thenresize
s, butresize
sets thesize
anyway so we don't need to do this extra step.The example sets
Image.texture_descriptor.format
toTextureFormat::Bgra8UnormSrgb
, but the default impl sets this toTextureFormat::Rgba8UnormSrgb
viawgpu::TextureFormat::bevy_default()
. I don't know what sort of impact this has, but it works on my machine.The text was updated successfully, but these errors were encountered: