Trait lux::graphics::PrimitiveCanvas
[−]
[src]
pub trait PrimitiveCanvas {
fn clear<C: Color>(&mut self, color: C);
fn clear_stencil(&mut self, v: i32);
fn draw_colored(&mut self, typ: PrimitiveType, vs: &[ColorVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>) -> LuxResult<()>;
fn draw_colored_now(&mut self, typ: PrimitiveType, points: &[ColorVertex], idxs: Option<&[Idx]>, base_mat: Option<[[Float; 4]; 4]>) -> LuxResult<()>;
fn draw_colored_no_batch(&mut self, typ: PrimitiveType, vs: &[ColorVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>) -> LuxResult<()>;
fn draw_tex(&mut self, typ: PrimitiveType, vs: &[TexVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>, Rc<Texture2d>, color_mult: Option<[Float; 4]>) -> LuxResult<()>;
fn draw_textured_now(&mut self, typ: PrimitiveType, points: &[TexVertex], idxs: Option<&[Idx]>, base_mat: Option<[[Float; 4]; 4]>, texture: &Texture2d, color_mult: [Float; 4]) -> LuxResult<()>;
fn draw_tex_no_batch(&mut self, typ: PrimitiveType, vs: &[TexVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>, &Texture2d, color_mult: Option<[Float; 4]>) -> LuxResult<()>;
fn flush_draw(&mut self) -> LuxResult<()>;
}A Primitive canvas is a trait that is implemented by objects that can have draw commands issued to them.
As the name implies, this is a lower-level API and you should probably
be using methods on the Canvas trait instead.
Required Methods
fn clear<C: Color>(&mut self, color: C)
Clears the canvas with a color.
fn clear_stencil(&mut self, v: i32)
Clears the stencil buffer.
fn draw_colored(&mut self, typ: PrimitiveType, vs: &[ColorVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>) -> LuxResult<()>
Draws the verteces to the canvas. This function uses caching to batch draw calls that are similar.
typ: The primitive type used to draw the vertices. vs : A slice of vertices to be drawn. idxs: An optional list of indices that can be used to index into the ColorVertex array. Useful if you have many points that are duplicates of each other. mat: An optional transformation matrix that would be applied to the each point before drawing.
fn draw_colored_now(&mut self, typ: PrimitiveType, points: &[ColorVertex], idxs: Option<&[Idx]>, base_mat: Option<[[Float; 4]; 4]>) -> LuxResult<()>
Draws colored vertices to the canvas with no thought given to the cached draw commands.
This function is meant for internal use and shouldn't regularly show
up in user code. Instead, prefer draw_colored or draw_colored_no_batch
fn draw_colored_no_batch(&mut self, typ: PrimitiveType, vs: &[ColorVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>) -> LuxResult<()>
Immediately draws colored vertices to the canvas.
The vertex batch cache is cleared before drawing. These vertices are not cached.
fn draw_tex(&mut self, typ: PrimitiveType, vs: &[TexVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>, Rc<Texture2d>, color_mult: Option<[Float; 4]>) -> LuxResult<()>
Same as draw_colored but for textured vertices.
fn draw_textured_now(&mut self, typ: PrimitiveType, points: &[TexVertex], idxs: Option<&[Idx]>, base_mat: Option<[[Float; 4]; 4]>, texture: &Texture2d, color_mult: [Float; 4]) -> LuxResult<()>
Same as draw_colored_now but for textured vertices.
fn draw_tex_no_batch(&mut self, typ: PrimitiveType, vs: &[TexVertex], idxs: Option<&[Idx]>, mat: Option<[[Float; 4]; 4]>, &Texture2d, color_mult: Option<[Float; 4]>) -> LuxResult<()>
Same as draw_colored_no_batch but for textured vertices.
fn flush_draw(&mut self) -> LuxResult<()>
Flush all stored draw calls to the screen.
This is an interal function that should not usually be called by the user of this library.
Implementors
impl<T> PrimitiveCanvas for T where T: HasDisplay + HasSurface + HasDrawCache + DrawParamMod + Transform + Fetch<Vec<Idx>> + Fetch<Vec<TexVertex>> + Fetch<Vec<ColorVertex>>