Trait glitter::context::buffer_context::ContextBufferExt [] [src]

pub trait ContextBufferExt: BaseContext {
    fn gen_buffer(&self) -> Buffer { ... }
    fn buffer_bytes<B>(&self, gl_buffer: &mut B, bytes: &[u8], usage: BufferDataUsage) where B: BufferBinding { ... }
    unsafe fn vertex_attrib_pointer(&self, attrib: ProgramAttrib, components: i8, gl_type: DataType, normalized: bool, stride: usize, offset: usize) { ... }
    unsafe fn draw_arrays_range(&self, _ab: &ArrayBufferBinding, mode: DrawingMode, first: u32, count: usize) { ... }
    unsafe fn draw_n_elements_buffered(&self, _ab: &ArrayBufferBinding, _eab: &ElementArrayBufferBinding, mode: DrawingMode, count: usize, index_type: IndexDatumType) { ... }
    unsafe fn draw_n_elements<I>(&self, _ab: &ArrayBufferBinding, mode: DrawingMode, count: usize, indices: &[I]) where I: IndexDatum, [I]: IndexData { ... }
    unsafe fn draw_elements<I>(&self, _ab: &ArrayBufferBinding, mode: DrawingMode, indices: &[I]) where I: IndexDatum, [I]: IndexData { ... }
}

An extension trait that includes buffer object-related OpenGL methods.

Provided Methods

fn gen_buffer(&self) -> Buffer

Create a new, empty OpenGL buffer object.

See also

glGenBuffers OpenGL docs

gl.new_vertex_buffer: Create a new vertex buffer, which wraps a raw OpenGL buffer.

gl.new_index_buffer: Create a new index buffer, which wraps a raw OpenGL buffer.

gl.buffer_bytes: Send data to a buffer.

fn buffer_bytes<B>(&self, gl_buffer: &mut B, bytes: &[u8], usage: BufferDataUsage) where B: BufferBinding

Send data to a buffer object. Note that this will replace the buffer's current contents, if any.

See also

glBufferData OpenGL docs

unsafe fn vertex_attrib_pointer(&self, attrib: ProgramAttrib, components: i8, gl_type: DataType, normalized: bool, stride: usize, offset: usize)

Specify how an array of vertex data will be treated while rendering. Most uses of this function can be replaced by using a VertexBuffer, which provides a nicer interface for setting up vertex attributes.

Panics

This function will panic in debug mode if components is less than 1 or greater than 4.

Safety

Using this function can cause an OpenGL draw call to read uninitialized memory from a buffer.

See also

glVertexAttribPointer OpenGL docs

unsafe fn draw_arrays_range(&self, _ab: &ArrayBufferBinding, mode: DrawingMode, first: u32, count: usize)

Use the vertex data from the provided array buffer binding to render primitives.

  • _ab: The binding for the array buffer to read vertices from.
  • mode: The type of primitives to draw.
  • first: The index of the first vertex to read.
  • count: The number of vertices to read.

Safety

The vertex attributes for the need to be set up before calling this method by using the gl.vertex_attrib_pointer method.

See also

glDrawArrays OpenGL docs

unsafe fn draw_n_elements_buffered(&self, _ab: &ArrayBufferBinding, _eab: &ElementArrayBufferBinding, mode: DrawingMode, count: usize, index_type: IndexDatumType)

Draw primitives specified by the provided element array buffer, treated as indices of the vertices from the provided array buffer.

  • _ab: The binding for the array buffer that contains the vertex data.
  • _eab: The binding for the element array buffer that contains the index data.
  • mode: The type of primitives to draw.
  • count: The number of indices to read.
  • index_type: Specifies the data type of the index (whether it is a byte or short, signed unsigned, etc).

See also

glDrawElements OpenGL docs

unsafe fn draw_n_elements<I>(&self, _ab: &ArrayBufferBinding, mode: DrawingMode, count: usize, indices: &[I]) where I: IndexDatum, [I]: IndexData

Draw primtives specified by the provided index array, treated as indices of the vertices from the provided array buffer.

  • _ab: The binding for the array buffer that contains the vertex data.
  • mode: The type of primitives to draw.
  • count: The number of indices to read.
  • indices: The index array to use.

See also

glDrawElements OpenGL docs

unsafe fn draw_elements<I>(&self, _ab: &ArrayBufferBinding, mode: DrawingMode, indices: &[I]) where I: IndexDatum, [I]: IndexData

Draw primtives specified by the provided index array, treated as indices of the vertices from the provided array buffer.

  • _ab: The binding for the array buffer that contains the vertex data.
  • mode: The type of primitives to draw.
  • indices: The index array to use.

See also

glDrawElements OpenGL docs

Implementors