Struct three_d::core::buffer::VertexBuffer
source · pub struct VertexBuffer { /* private fields */ }
Expand description
A buffer containing per vertex data, for example positions, normals, uv coordinates or colors. To send this data to a shader, use the Program::use_vertex_attribute method.
Implementations§
source§impl VertexBuffer
impl VertexBuffer
sourcepub fn new_with_data<T: BufferDataType>(context: &Context, data: &[T]) -> Self
pub fn new_with_data<T: BufferDataType>(context: &Context, data: &[T]) -> Self
Creates a new vertex buffer and fills it with the given data. The data should be in the same format as specified in the shader.
As an example, if specified as vec3
in the shader it needs to be specified as an array of Vector3<T>
where T
is a primitive type that implements BufferDataType, for example can be f16 or f32.
sourcepub fn fill<T: BufferDataType>(&mut self, data: &[T])
pub fn fill<T: BufferDataType>(&mut self, data: &[T])
Fills the vertex buffer with the given data. The data should be in the same format as specified in the shader.
As an example, if specified as vec3
in the shader it needs to be specified as an array of Vector3<T>
where T
is a primitive type that implements BufferDataType, for example can be f16 or f32.
sourcepub fn vertex_count(&self) -> u32
pub fn vertex_count(&self) -> u32
The number of vertex attributes in the buffer.