pub trait Renderable: Sized {
type Buffer: BufferClient;
type Descriptor: DescriptorClient;
type DataAccessor: AccessorClient;
type IndexAccessor: AccessorClient;
type Texture: TextureClient;
type Material: MaterialClient;
type Vertices: VerticesClient;
// Required methods
fn init_buffer_data_client(
&mut self,
client: &mut Self::Buffer,
buffer_data: &BufferData<'_, Self>,
);
fn init_buffer_desc_client(
&mut self,
client: &mut Self::Descriptor,
buffer_desc: &BufferDescriptor<'_, Self>,
);
fn init_index_accessor_client(
&mut self,
client: &mut Self::IndexAccessor,
buffer_view: &BufferIndexAccessor<'_, Self>,
);
fn init_data_accessor_client(
&mut self,
client: &mut Self::DataAccessor,
buffer_view: &BufferDataAccessor<'_, Self>,
);
fn create_vertices_client(
&mut self,
vertices: &Vertices<'_, Self>,
) -> Self::Vertices;
fn create_texture_client(
&mut self,
texture: &Texture<'_, Self>,
) -> Self::Texture;
fn create_material_client<M>(
&mut self,
object: &Object<'_, M, Self>,
material: &M,
) -> Self::Material
where M: Material;
fn init_material_client<M: Material>(
&mut self,
client: &mut Self::Material,
material: &M,
);
}
Expand description
The Renderable trait must be implemented by a type that is a client of the 3D model system. It provides associated types for a renderable context (this might be a particular shader program within a OpenGL context, for example), and then its own structures that are used to hold BufferData, textures, materials, and sets of renderable Vertices.
Required Associated Types§
Sourcetype Buffer: BufferClient
type Buffer: BufferClient
The renderer’s type that reflects a BufferData
A BufferData is a slice of u8 that contains some data (indices, vertex data, etc) for an object
Sourcetype Descriptor: DescriptorClient
type Descriptor: DescriptorClient
The renderer’s type that reflects a BufferDescriptor
A buffer descriptor is a slice of a BufferData that contains multiple records, each of which contains a number of fields for different VertexAttr
Sourcetype DataAccessor: AccessorClient
type DataAccessor: AccessorClient
The renderer’s type that reflects a BufferDataAccessor
A BufferDataAccessor is a reference to a single entry in a BufferDescriptor; hence it might be ‘Position’ for a vertex, from a large array of vertex records in an object
Sourcetype IndexAccessor: AccessorClient
type IndexAccessor: AccessorClient
The renderer’s type that reflects a BufferIndexAccessor
A BufferIndexAccessor represents a slice of a BufferData containing indices for accessing an array of vertex records for rendering a primitive in an object
Sourcetype Texture: TextureClient
type Texture: TextureClient
The renderer’s type that represents a texture; this is supplied to material creation, and hence is less a product of the renderer and more an input to the 3D model library
Sourcetype Material: MaterialClient
type Material: MaterialClient
The renderer’s type that reflects a Material; this is expected to be an extraction of the aspects of a material that the renderer pipelines can apply.
Sourcetype Vertices: VerticesClient
type Vertices: VerticesClient
The renderer’s type that reflects a [BufferAccessor] of indices and the associated [BufferAccessor]s of attributes supported by a particular pipeline within the renderer
Required Methods§
Sourcefn init_buffer_data_client(
&mut self,
client: &mut Self::Buffer,
buffer_data: &BufferData<'_, Self>,
)
fn init_buffer_data_client( &mut self, client: &mut Self::Buffer, buffer_data: &BufferData<'_, Self>, )
Initialize a buffer data client - it will have been created using default()
This is invoked by the base library only when the client invoked ‘create_client’ for a data buffer
Sourcefn init_buffer_desc_client(
&mut self,
client: &mut Self::Descriptor,
buffer_desc: &BufferDescriptor<'_, Self>,
)
fn init_buffer_desc_client( &mut self, client: &mut Self::Descriptor, buffer_desc: &BufferDescriptor<'_, Self>, )
Initialize a buffer descriptor client - it will have been created using default()
Sourcefn init_index_accessor_client(
&mut self,
client: &mut Self::IndexAccessor,
buffer_view: &BufferIndexAccessor<'_, Self>,
)
fn init_index_accessor_client( &mut self, client: &mut Self::IndexAccessor, buffer_view: &BufferIndexAccessor<'_, Self>, )
Initialize the client of an index accessor of a buffer data
Sourcefn init_data_accessor_client(
&mut self,
client: &mut Self::DataAccessor,
buffer_view: &BufferDataAccessor<'_, Self>,
)
fn init_data_accessor_client( &mut self, client: &mut Self::DataAccessor, buffer_view: &BufferDataAccessor<'_, Self>, )
Initialize the client of a data accessor of a buffer data
Sourcefn create_vertices_client(
&mut self,
vertices: &Vertices<'_, Self>,
) -> Self::Vertices
fn create_vertices_client( &mut self, vertices: &Vertices<'_, Self>, ) -> Self::Vertices
Create a client
Sourcefn create_texture_client(
&mut self,
texture: &Texture<'_, Self>,
) -> Self::Texture
fn create_texture_client( &mut self, texture: &Texture<'_, Self>, ) -> Self::Texture
Create a client
Sourcefn create_material_client<M>(
&mut self,
object: &Object<'_, M, Self>,
material: &M,
) -> Self::Materialwhere
M: Material,
fn create_material_client<M>(
&mut self,
object: &Object<'_, M, Self>,
material: &M,
) -> Self::Materialwhere
M: Material,
Create a client
Sourcefn init_material_client<M: Material>(
&mut self,
client: &mut Self::Material,
material: &M,
)
fn init_material_client<M: Material>( &mut self, client: &mut Self::Material, material: &M, )
Create a client for a reason - reason 0 is reserved Can we lose this?
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.