Trait glitter::context::ContextExt [] [src]

pub trait ContextExt: BaseContext {
    fn clear_color(&mut self, color: Color) { ... }
    fn enable(&mut self, cap: Capability) { ... }
    fn disable(&mut self, cap: Capability) { ... }
    fn enable_vertex_attrib_array(&self, attrib: ProgramAttrib) { ... }
    fn viewport(&self, viewport: Viewport) { ... }
}

An extension trait that contains some of the core OpenGL methods that maintain state, such as the current clear color or whether depth testing is enabled.

Provided Methods

fn clear_color(&mut self, color: Color)

Set the clear value when clearing a color buffer with gl.clear(glitter::COLOR_BUFFER_BIT).

Example

#[macro_use] extern crate glitter;
use glitter::prelude::*;

let mut gl = unsafe { glitter::Context::current_context() };
// Clear the screen with solid red
gl.clear_color(glitter::Color { r: 1.0, g: 0.0, b: 0.0, a: 1.0 });
gl.clear(glitter::COLOR_BUFFER_BIT);

fn enable(&mut self, cap: Capability)

Enable an OpenGL capability.

Example

#[macro_use] extern crate glitter;
use glitter::prelude::*;

let mut gl = unsafe { glitter::Context::current_context() };
// Enable depth testing
gl.enable(glitter::DEPTH_TEST);

fn disable(&mut self, cap: Capability)

Disable an OpenGL capability.

Example

#[macro_use] extern crate glitter;
use glitter::prelude::*;

let mut gl = unsafe { glitter::Context::current_context() };
// Disable depth testing
gl.disable(glitter::DEPTH_TEST);

fn enable_vertex_attrib_array(&self, attrib: ProgramAttrib)

Enable the vertex attribute array to be used while drawing with gl.draw_arrays_range, gl.draw_elements, gl.draw_n_elements, gl.draw_n_elements_buffered.

Panics

This function will panics on an OpenGL error in debug mode.

fn viewport(&self, viewport: Viewport)

Set the OpenGL viewport dimensions, which maps from device coordinates to window coordinates.

Implementors