Trait ul_next::gpu_driver::GpuDriver
source · pub trait GpuDriver {
Show 14 methods
// Required methods
fn begin_synchronize(&mut self);
fn end_synchronize(&mut self);
fn next_texture_id(&mut self) -> u32;
fn create_texture(&mut self, texture_id: u32, bitmap: OwnedBitmap);
fn update_texture(&mut self, texture_id: u32, bitmap: OwnedBitmap);
fn destroy_texture(&mut self, texture_id: u32);
fn next_render_buffer_id(&mut self) -> u32;
fn create_render_buffer(
&mut self,
render_buffer_id: u32,
render_buffer: RenderBuffer,
);
fn destroy_render_buffer(&mut self, render_buffer_id: u32);
fn next_geometry_id(&mut self) -> u32;
fn create_geometry(
&mut self,
geometry_id: u32,
vertex_buffer: VertexBuffer,
index_buffer: IndexBuffer,
);
fn update_geometry(
&mut self,
geometry_id: u32,
vertex_buffer: VertexBuffer,
index_buffer: IndexBuffer,
);
fn destroy_geometry(&mut self, geometry_id: u32);
fn update_command_list(&mut self, command_list: Vec<GpuCommand>);
}
Expand description
GpuDriver
trait, dispatches GPU calls to the native driver.
This is automatically provided for you when you use App::new
,
AppCore
provides platform-specific implementations of GpuDriver
for each OS.
If you are using Renderer::create
,
you will need to provide your own implementation of this trait if you
have enabled the GPU renderer in the Config.
(See platform::set_gpu_driver
).
Required Methods§
sourcefn begin_synchronize(&mut self)
fn begin_synchronize(&mut self)
Called before any commands are dispatched during a frame.
Called before any state is updated during a call to
Renderer::render
.
This is a good time to prepare the GPU for any state updates.
sourcefn end_synchronize(&mut self)
fn end_synchronize(&mut self)
Called after any commands are dispatched during a frame.
Called after all state has been updated during a call to
Renderer::render
.
sourcefn next_texture_id(&mut self) -> u32
fn next_texture_id(&mut self) -> u32
Get the next available texture ID. DO NOT return 0
(reserved).
This is used to generate a unique texture ID for each texture created by the library. The GPU driver implementation is responsible for mapping these IDs to a native ID.
sourcefn create_texture(&mut self, texture_id: u32, bitmap: OwnedBitmap)
fn create_texture(&mut self, texture_id: u32, bitmap: OwnedBitmap)
Create a texture with a certain ID and optional bitmap.
NOTE: If the Bitmap is empty OwnedBitmap::is_empty
,
then a RTT Texture should be created instead.
This will be used as a backing texture for a new RenderBuffer.
Even if the bitmap is empty, it will still contain the width
and height
information, which can be used to know the size of the backing texture.
sourcefn update_texture(&mut self, texture_id: u32, bitmap: OwnedBitmap)
fn update_texture(&mut self, texture_id: u32, bitmap: OwnedBitmap)
Update an existing non-RTT texture with new bitmap data.
sourcefn destroy_texture(&mut self, texture_id: u32)
fn destroy_texture(&mut self, texture_id: u32)
Destroy a texture.
sourcefn next_render_buffer_id(&mut self) -> u32
fn next_render_buffer_id(&mut self) -> u32
Generate the next available render buffer ID. DO NOT return 0
(reserved).
sourcefn create_render_buffer(
&mut self,
render_buffer_id: u32,
render_buffer: RenderBuffer,
)
fn create_render_buffer( &mut self, render_buffer_id: u32, render_buffer: RenderBuffer, )
Create a render buffer with certain ID and buffer description.
sourcefn destroy_render_buffer(&mut self, render_buffer_id: u32)
fn destroy_render_buffer(&mut self, render_buffer_id: u32)
Destroy a render buffer.
sourcefn next_geometry_id(&mut self) -> u32
fn next_geometry_id(&mut self) -> u32
Get the next available geometry ID. DO NOT return 0
.
sourcefn create_geometry(
&mut self,
geometry_id: u32,
vertex_buffer: VertexBuffer,
index_buffer: IndexBuffer,
)
fn create_geometry( &mut self, geometry_id: u32, vertex_buffer: VertexBuffer, index_buffer: IndexBuffer, )
Create geometry with certain ID and vertex/index data.
sourcefn update_geometry(
&mut self,
geometry_id: u32,
vertex_buffer: VertexBuffer,
index_buffer: IndexBuffer,
)
fn update_geometry( &mut self, geometry_id: u32, vertex_buffer: VertexBuffer, index_buffer: IndexBuffer, )
Update existing geometry with new vertex/index data.
sourcefn destroy_geometry(&mut self, geometry_id: u32)
fn destroy_geometry(&mut self, geometry_id: u32)
Destroy a geometry.
sourcefn update_command_list(&mut self, command_list: Vec<GpuCommand>)
fn update_command_list(&mut self, command_list: Vec<GpuCommand>)
Update command list (here you should render the commands).