pub fn with_data(target: BufferTarget, data: &[T]) -> PrimitiveBuffer<T> {
        if data.is_empty() {
            return PrimitiveBuffer::new(target, BufferUsage::StaticDraw);
        }

        let mut buffer = 0;
        let bytes = data.len() * mem::size_of::<T>();

        unsafe {
            gl::GenBuffers(1, &mut buffer);
            gl::BindBuffer(target as GLenum, buffer);
            gl::BufferData(
                target as GLenum,
                bytes as GLsizeiptr,
                mem::transmute(&data[0]),
                BufferUsage::StaticDraw as GLenum
            );
        }

        PrimitiveBuffer {
            phantom: PhantomData,

            buffer: buffer,
            target: target,
            usage: BufferUsage::StaticDraw,
            allocated: data.len(),
            primitive_count: data.len(),
        }
    }
/// Stores the given data in a new buffer. The buffer will have its usage set to `BufferUsage::StaticDraw`
Stores the given data in a new buffer. The buffer will have its usage set to `BufferUsage::StaticDraw`
Stores the given data in a new buffer . The buffer will have its usage set to ` BufferUsage :: StaticDraw `
pub fn with_data(target: BufferTarget, data: &[T]) -> PrimitiveBuffer<T> {
        if data.is_empty() {
            return PrimitiveBuffer::new(target, BufferUsage::StaticDraw);
        }
        let mut buffer = 0;
        let bytes = data.len() * mem::size_of::<T>();
        unsafe {
            gl::GenBuffers(1, &mut buffer);
            gl::BindBuffer(target as GLenum, buffer);
            gl::BufferData(
                target as GLenum,
                bytes as GLsizeiptr,
                mem::transmute(&data[0]),
                BufferUsage::StaticDraw as GLenum
            );
        }
        PrimitiveBuffer {
            phantom: PhantomData,
            buffer: buffer,
            target: target,
            usage: BufferUsage::StaticDraw,
            allocated: data.len(),
            primitive_count: data.len(),
        }
    }
pub fn with_data ( target : BufferTarget , data : & [ T ] ) -> PrimitiveBuffer < T > { if data . is_empty ( ) { return PrimitiveBuffer :: new ( target , BufferUsage :: StaticDraw ) ; } let mut buffer = 0 ; let bytes = data . len ( ) * mem :: size_of :: < T > ( ) ; unsafe { gl :: GenBuffers ( 1 , & mut buffer ) ; gl :: BindBuffer ( target as GLenum , buffer ) ; gl :: BufferData ( target as GLenum , bytes as GLsizeiptr , mem :: transmute ( & data [ 0 ] ) , BufferUsage :: StaticDraw as GLenum ) ; } PrimitiveBuffer { phantom : PhantomData , buffer : buffer , target : target , usage : BufferUsage :: StaticDraw , allocated : data . len ( ) , primitive_count : data . len ( ) , } }
Stores the given data in a new buffer.
Stores the given data in a new buffer .
target
BufferTarget
data
&[T]
target
BufferTarget
data
&[T]