Struct glitter::vertex_buffer::AttribBinder
[−]
[src]
pub struct AttribBinder { /* fields omitted */ }
A type used to perform operations on a list of program attributes. An
instance of an AttribBinder
can be created with the attrib_pointers!
macro or with the new
method.
Note
Currently, AttribBinder
when both adding vertex attributes and when
operating on vertex attributes. Consider using the direct lower-level
glitter API's if heap allocations become a performance bottleneck.
Methods
impl AttribBinder
[src]
pub fn new() -> Self
[src]
Create a new, empty AttribBinder
.
pub fn add(
&mut self,
name: &str,
attrib: ProgramAttrib
) -> Result<(), AttribAddError>
[src]
&mut self,
name: &str,
attrib: ProgramAttrib
) -> Result<(), AttribAddError>
Add an attribute to the AttribBinder
.
Failures
add
will return an error if the attribute being added is already
present.
Note
Each call to add
can potentially cause a heap allocation.
pub fn enable<V, C>(&self, gl: &mut C) -> Result<(), AttribError> where
V: VertexData,
C: AContext,
[src]
V: VertexData,
C: AContext,
Enable all of the vertex attributes contained within the AttribBinder
.
The provided type of VertexData
is used to to verify the list
of attributes.
Failures
An error will be returned if the set of vertex attributes contained
by the VertexData
types does not exactly match the list of attributes
contained by the AttribBinder
.
Note
Currently, calling enable
will perform a heap allocation. Consider
using gl.enable_vertex_attrib_array
if this becomes a performance concern.
pub fn bind<V, C>(&self, gl: &C) -> Result<(), AttribError> where
V: VertexData,
C: AContext,
[src]
V: VertexData,
C: AContext,
Set up each vertex attribute with the appropriate attribute options
(using glVertexAttribPointer
). The VertexData
type
parameter is used to get the attribute options for each attribute.
Failures
An error will be returned if the set of vertex attributes contained
by the VertexData
types does not exactly match the list of attributes
contained by the AttribBinder.
Note
Currently, calling bind
will perform a heap allocation. Consider
using gl.enable_vertex_attrib_array
if this becomes a performance concern.