Struct rin::gl::vao::Builder[][src]

pub struct Builder { /* fields omitted */ }

Implementations

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]

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]

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]

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]

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]

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<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<V> IntoPnt<V> for V[src]

impl<V> IntoVec<V> for V[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]