Struct rin::gl::vao::Builder [−][src]
pub struct Builder { /* fields omitted */ }
Implementations
impl Builder
[src]
impl Builder
[src]Builder for a VAO
pub fn bindings_from<T, B, BI>(self, bindings: &BI, from: B) -> Builder where
B: BufferRange<T> + 'static,
T: 'static + VertexFormat,
BI: Bindings,
[src]
B: BufferRange<T> + 'static,
T: 'static + VertexFormat,
BI: Bindings,
Specify attribute bindings and vertex buffer bindings
bindings: This is usually a glsl program or a HashMap with predefined bindings from: Some kind of buffer like a Buffer, a SharedBuffer or a range of a buffer
The bindings are used to recover the formats (including location) for each attribute and that + the passed buffer to create the full relation: buffer -> vertex buffer binding point <- attributes
#[macro_use] extern crate glin; use std::mem; #[derive(VertexFormat)] struct Vertex{ position: [f32;4] } fn main(){ let gl: glin::Context = unsafe{ mem::uninitialized() }; let vertices: &[Vertex] = &[]; let buffer: glin::Buffer<Vertex> = gl.new_buffer() .from_data(vertices, glin::gl::STATIC_DRAW).unwrap(); let program: glin::Program = unsafe{ mem::uninitialized() }; let vao = gl.new_vao() .bindings_from(&program, buffer) .create() .unwrap(); }
Creates a Vao that reads from buffer
and binds each vertex element in it’s vertex type
to the attribute with the same name in the glsl program
The type of the buffer has to implement VertexFormat
pub fn attributes_from<T, B, I>(self, formats: I, from: B) -> Builder where
B: BufferRange<T> + 'static,
T: 'static,
I: Into<Vec<Format, Global>>,
[src]
B: BufferRange<T> + 'static,
T: 'static,
I: Into<Vec<Format, Global>>,
Specify attribute bindings and vertex buffer bindings
Similar to bindings_from
but instead of passing a bindings source we pass the attribute
formats.
This method is rarely used directly unless we need to specify complex formats or we have vertex types that don’t specify VertexFormat
pub fn instance_bindings_from<T, B, BI>(
self,
bindings: &BI,
from: B,
divisor: usize
) -> Builder where
B: BufferRange<T> + 'static,
T: 'static + VertexFormat,
BI: Bindings,
[src]
self,
bindings: &BI,
from: B,
divisor: usize
) -> Builder where
B: BufferRange<T> + 'static,
T: 'static + VertexFormat,
BI: Bindings,
Specify attributes that will be read per instance
#[macro_use] extern crate glin; extern crate na; use std::mem; use glin::VertexFormat; #[derive(VertexFormat)] struct Vertex{ position: na::Vec3, } #[derive(VertexFormat)] struct InstanceAttributes{ model_matrix: na::Mat4, } fn main(){ let gl: glin::Context = unsafe{ mem::uninitialized() }; let program: glin::Program = unsafe { mem::uninitialized() }; let buffer: glin::Buffer<Vertex> = unsafe { mem::uninitialized() }; let instance_buffer: glin::Buffer<InstanceAttributes> = unsafe { mem::uninitialized() }; let vao = gl.new_vao() .bindings_from(&program, buffer) .instance_bindings_from(&program, instance_buffer, 1) .create() .unwrap(); }
divisor 0 means attribute per vertex, 1 attribute per instance, 2 attribute per 2 instances…
pub fn instance_attributes_from<T, B, I>(
self,
formats: I,
from: B,
divisor: usize
) -> Builder where
B: BufferRange<T> + 'static,
T: 'static,
I: Into<Vec<Format, Global>>,
[src]
self,
formats: I,
from: B,
divisor: usize
) -> Builder where
B: BufferRange<T> + 'static,
T: 'static,
I: Into<Vec<Format, Global>>,
Specify attributes that will be read per instance
#[macro_use] extern crate glin; extern crate na; use std::mem; use glin::VertexFormat; #[derive(VertexFormat)] struct Vertex{ position: na::Vec3, } #[derive(VertexFormat)] struct InstanceAttributes{ model_matrix: na::Mat4, } fn main(){ let gl: glin::Context = unsafe{ mem::uninitialized() }; let program: glin::Program = unsafe { mem::uninitialized() }; let buffer: glin::Buffer<Vertex> = unsafe { mem::uninitialized() }; let instance_buffer: glin::Buffer<InstanceAttributes> = unsafe { mem::uninitialized() }; let vertex_attributes = Vertex::attributes_formats(&program); let instance_attributes = InstanceAttributes::attributes_formats(&program); let vao = gl.new_vao() .attributes_from(vertex_attributes, buffer) .instance_attributes_from(instance_attributes, instance_buffer, 1) .create() .unwrap(); }
divisor 0 means attribute per vertex, 1 attribute per instance, 2 attribute per 2 instances…
pub fn indices<B, I>(self, indices: I) -> Builder where
B: BufferRangeMut<u32> + 'static,
I: Into<Option<B>>,
[src]
B: BufferRangeMut<u32> + 'static,
I: Into<Option<B>>,
Add an index buffer to the VAO
pub fn create(self) -> Result<Vao, Error>
[src]
Returns the VAO
with the specified bindings
Auto Trait Implementations
impl !RefUnwindSafe for Builder
impl !Send for Builder
impl !Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]pub fn to_subset(&self) -> Option<SS>
[src]
pub fn is_in_subset(&self) -> bool
[src]
pub fn to_subset_unchecked(&self) -> SS
[src]
pub fn from_subset(element: &SS) -> SP
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]