[][src]Module glium::buffer

A buffer is a memory location accessible to the video card.

The purpose of buffers is to serve as a space where the GPU can read from or write data to. It can contain a list of vertices, indices, uniform data, etc.

Buffers management in glium

There are three levels of abstraction in glium:

Unsized types

In order to put some data in a buffer, it must implement the Content trait. This trait is automatically implemented on all Sized types and on slices (like [u8]). This means that you can create a Buffer<Foo> (if Foo is sized) or a Buffer<[u8]> for example without worrying about it.

However unsized structs don't automatically implement this trait and you must call the implement_buffer_content! macro on them. You must then use the empty_unsized constructor.

struct Data {
    data: [f32],        // `[f32]` is unsized, therefore `Data` is unsized too
}

implement_buffer_content!(Data);    // without this, you can't put `Data` in a glium buffer

// creates a buffer of 64 bytes, which thus holds 8 f32s
let mut buffer = glium::buffer::Buffer::<Data>::empty_unsized(&display, BufferType::UniformBuffer,
                                                              64, BufferMode::Default).unwrap();

// you can then write to it like you normally would
buffer.map().data[4] = 2.1;

Structs

Buffer

Represents a view of a buffer.

BufferAny

Represents a sub-part of a buffer.

BufferAnySlice

Slice of a Buffer without any type info.

BufferMutSlice

Represents a sub-part of a buffer.

BufferSlice

Represents a sub-part of a buffer.

BufferView

Represents a view of a buffer.

BufferViewAny

Represents a sub-part of a buffer.

BufferViewAnySlice

Slice of a Buffer without any type info.

BufferViewMutSlice

Represents a sub-part of a buffer.

BufferViewSlice

Represents a sub-part of a buffer.

Inserter

Allows inserting a fence in the list.

Mapping

A mapping of a buffer for reading and writing.

ReadMapping

A mapping of a buffer for reading.

WriteMapping

A mapping of a buffer for write only.

Enums

BufferCreationError

Error that can happen when creating a buffer.

BufferMode

How the buffer is created.

BufferType

Type of a buffer.

CopyError

Error that can happen when copying data between buffers.

ReadError

Error that can happen when reading from a buffer.

Traits

Content

Trait for types of data that can be put inside buffers.

Functions

is_buffer_read_supported

Returns true if reading from a buffer is supported by the backend.