Add Api trait for hooking into Instance and Device creation#7700
Add Api trait for hooking into Instance and Device creation#7700geieredgar wants to merge 2 commits intobevyengine:mainfrom
Api trait for hooking into Instance and Device creation#7700Conversation
|
Example |
|
I believe bevy is moving away from using resources to configure plugins, e.g. |
|
I would generally agree with you, but there are several reasons why I didn't do that:
impl RenderPlugin {
pub fn with_api(self, api: impl Api) -> impl FnOnce(&mut App) -> Self {
|app| {
app.insert_resource(RenderApi(Box::new(api)));
self
}
}
}
fn main() {
App::new().add_plugin(RenderPlugin::default().with_api(CustomApi)).run();
} |
I would expect only the folks doing strange things with rendering already would be broken by this, so I don't think this is a concern. |
|
This is listed as superseded in the Triage Doc. If no one disagrees, I propose we close this. |
Objective
Solution
Apitrait and correspondingRenderApiresource that can be inserted before adding theRenderPluginto gain control over wgpuInstance,Surface,Adapter,Device, andQueuecreation.RenderApiusingDefaultApiis inserted automatically atRenderPluginbuild time, when aRenderApiis missing.DefaultApiuses the same wgpu functions and methods that were used before this change.