pub fn from_buffer(access_primitives: usize, buffer: PrimitiveBuffer<T>) -> TextureBuffer<T> {
        assert!(access_primitives > 0 && access_primitives <= 4, 
                "access_primitives ({}) must be equal to the number of primitives in a valid image format (R, RG, RGB or RGBA)",
                access_primitives);
        assert!(T::primitives() % access_primitives == 0,
                "T::primitives() ({}) must be divisible by access_primitives ({})",
                T::primitives(), access_primitives);

        let mut texture = 0;
        let format = match (T::Primitive::GL_ENUM, access_primitives) {
            (gl::FLOAT, 1) => gl::R32F,
            (gl::FLOAT, 2) => gl::RG32F,
            (gl::FLOAT, 3) => gl::RGB32F,
            (gl::FLOAT, 4) => gl::RGBA32F,
            // I cant be bothered to implement other types as I probably never will use them. This
            // should be trivial to extend if you get a panic.
            _ => panic!(
                "Invalid vertex data for texture buffer (access_primitives: {}, type: {})",
                access_primitives, T::Primitive::RUST_NAME
            ),
        };

        unsafe {
            gl::GenTextures(1, &mut texture);
            gl::BindTexture(gl::TEXTURE_BUFFER, texture);
            gl::TexBuffer(gl::TEXTURE_BUFFER, format, buffer.buffer);
        }

        TextureBuffer {
            bound_buffer: UnsafeCell::new(buffer.buffer),
            buffer: buffer,
            format: format,
            texture: texture,
        }
    }
/// Converts a vertex buffer into a texture buffer. 
///
/// `access_primitives` specifies the number of primitives that will be accessible per texel in
/// a shader. This must be between 1 and 4 (both inclusive), and `T::primitives()` must be 
/// divisible by it. For example, if your vertex data has 10 primitives `access_primitives` can
/// be 1 and 2.
Converts a vertex buffer into a texture buffer.
`access_primitives` specifies the number of primitives that will be accessible per texel in
a shader. This must be between 1 and 4 (both inclusive), and `T::primitives()` must be
divisible by it. For example, if your vertex data has 10 primitives `access_primitives` can
be 1 and 2.
Converts a vertex buffer into a texture buffer . ` access_primitives ` specifies the number of primitives that will be accessible per texel in a shader . This must be between 1 and 4 ( both inclusive ) and ` T :: primitives () ` must be divisible by it . For example if your vertex data has 10 primitives ` access_primitives ` can be 1 and 2 .
pub fn from_buffer(access_primitives: usize, buffer: PrimitiveBuffer<T>) -> TextureBuffer<T> {
        assert!(access_primitives > 0 && access_primitives <= 4, 
                "access_primitives ({}) must be equal to the number of primitives in a valid image format (R, RG, RGB or RGBA)",
                access_primitives);
        assert!(T::primitives() % access_primitives == 0,
                "T::primitives() ({}) must be divisible by access_primitives ({})",
                T::primitives(), access_primitives);
        let mut texture = 0;
        let format = match (T::Primitive::GL_ENUM, access_primitives) {
            (gl::FLOAT, 1) => gl::R32F,
            (gl::FLOAT, 2) => gl::RG32F,
            (gl::FLOAT, 3) => gl::RGB32F,
            (gl::FLOAT, 4) => gl::RGBA32F,
            // I cant be bothered to implement other types as I probably never will use them. This
            // should be trivial to extend if you get a panic.
            _ => panic!(
                "Invalid vertex data for texture buffer (access_primitives: {}, type: {})",
                access_primitives, T::Primitive::RUST_NAME
            ),
        };
        unsafe {
            gl::GenTextures(1, &mut texture);
            gl::BindTexture(gl::TEXTURE_BUFFER, texture);
            gl::TexBuffer(gl::TEXTURE_BUFFER, format, buffer.buffer);
        }
        TextureBuffer {
            bound_buffer: UnsafeCell::new(buffer.buffer),
            buffer: buffer,
            format: format,
            texture: texture,
        }
    }
pub fn from_buffer ( access_primitives : usize , buffer : PrimitiveBuffer < T > ) -> TextureBuffer < T > { assert ! ( access_primitives 0 access_primitives 4 " " access_primitives ) ; assert ! ( T primitives ( ) access_primitives 0 " " T primitives ( ) access_primitives ) ; let mut texture = 0 ; let format = match ( T :: Primitive :: GL_ENUM , access_primitives ) { ( gl :: FLOAT , 1 ) => gl :: R32F , ( gl :: FLOAT , 2 ) => gl :: RG32F , ( gl :: FLOAT , 3 ) => gl :: RGB32F , ( gl :: FLOAT , 4 ) => gl :: RGBA32F , // I cant be bothered to implement other types as I probably never will use them. This // should be trivial to extend if you get a panic. _ => panic ! ( " " access_primitives T Primitive RUST_NAME ) , } ; unsafe { gl :: GenTextures ( 1 , & mut texture ) ; gl :: BindTexture ( gl :: TEXTURE_BUFFER , texture ) ; gl :: TexBuffer ( gl :: TEXTURE_BUFFER , format , buffer . buffer ) ; } TextureBuffer { bound_buffer : UnsafeCell :: new ( buffer . buffer ) , buffer : buffer , format : format , texture : texture , } }
Converts a vertex buffer into a texture buffer.
Converts a vertex buffer into a texture buffer .
access_primitives
usize
buffer
PrimitiveBuffer<T>
access_primitives
usize
buffer
PrimitiveBuffer<T>