Trait glitter::shader::ContextShaderBuilderExt
[−]
[src]
pub trait ContextShaderBuilderExt: AContext + Sized { fn build_shader<'a>(
&'a self,
ty: ShaderType,
source: &'a str
) -> ShaderBuilder<'a, Self>; fn build_fragment_shader<'a>(
&'a self,
source: &'a str
) -> ShaderBuilder<'a, Self> { ... } fn build_vertex_shader<'a>(
&'a self,
source: &'a str
) -> ShaderBuilder<'a, Self> { ... } }
An extension trait for ContextOf
that
adds functions to build shaders using the ShaderBuilder
interface.
Required Methods
fn build_shader<'a>(
&'a self,
ty: ShaderType,
source: &'a str
) -> ShaderBuilder<'a, Self>
&'a self,
ty: ShaderType,
source: &'a str
) -> ShaderBuilder<'a, Self>
Build a new shader with the provided shader type and shader source.
Example
#[macro_use] extern crate glitter; use glitter::prelude::*; let vertex_source = r##"#version 100 attribute vec4 position; void main() { gl_Position = position; _color = color; } "##; let gl = unsafe { glitter::Context::current_context() }; let shader = gl.build_shader(glitter::VERTEX_SHADER, vertex_source).unwrap();
Provided Methods
fn build_fragment_shader<'a>(
&'a self,
source: &'a str
) -> ShaderBuilder<'a, Self>
&'a self,
source: &'a str
) -> ShaderBuilder<'a, Self>
Build a new fragment shader with the provided shader source.
Example
#[macro_use] extern crate glitter; use glitter::prelude::*; let fragment_source = r##"#version 100 void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0); } "##; let gl = unsafe { glitter::Context::current_context() }; let shader = gl.build_fragment_shader(fragment_source).unwrap();
fn build_vertex_shader<'a>(&'a self, source: &'a str) -> ShaderBuilder<'a, Self>
Build a new vertex shader with the provided shader source.
Example
#[macro_use] extern crate glitter; use glitter::prelude::*; let vertex_source = r##"#version 100 attribute vec4 position; void main() { gl_Position = position; _color = color; } "##; let gl = unsafe { glitter::Context::current_context() }; let shader = gl.build_vertex_shader(vertex_source).unwrap();
Implementors
impl<C: AContext> ContextShaderBuilderExt for C