Struct GlGraphics

Source
pub struct GlGraphics { /* private fields */ }
Expand description

Contains OpenGL data.

Implementations§

Source§

impl GlGraphics

Source

pub fn get_uniform<T: UniformType + ?Sized>( &self, name: &str, ) -> Option<ShaderUniform<T>>

Try to get uniform from the current shader of a given name.

Source§

impl GlGraphics

Source

pub fn new(opengl: OpenGL) -> Self

Creates a new OpenGL back-end.

§Panics

If the OpenGL function pointers have not been loaded yet. See https://github.com/PistonDevelopers/opengl_graphics/issues/103 for more info.

Source

pub fn from_pieces( colored: Colored, textured: Textured, textured_color: TexturedColor, ) -> Self

Create a new OpenGL back-end with Colored, Textured and TexturedColor structs to describe how to render objects.

§Panics

If the OpenGL function pointers have not been loaded yet. See https://github.com/PistonDevelopers/opengl_graphics/issues/103 for more info.

Source

pub fn get_current_program(&self) -> Option<GLuint>

Returns the current program

Source

pub fn use_program(&mut self, program: GLuint)

Sets the current program only if the program is not in use.

Source

pub fn clear_program(&mut self)

Unset the current program.

This forces the current program to be set on next drawing call.

Source

pub fn use_draw_state(&mut self, draw_state: &DrawState)

Sets the current draw state, by detecting changes.

Source

pub fn clear_draw_state(&mut self)

Unsets the current draw state.

This forces the current draw state to be set on next drawing call.

Source

pub fn draw_begin(&mut self, viewport: Viewport) -> Context

Setup that should be called at the start of a frame’s draw call.

Source

pub fn draw_end(&mut self)

Finalize the frame’s draw calls.

Source

pub fn draw<F, U>(&mut self, viewport: Viewport, f: F) -> U
where F: FnOnce(Context, &mut Self) -> U,

Convenience for wrapping draw calls with the begin and end methods.

This is preferred over using the draw_begin & draw_end methods explicitly but may be less flexible.

Source

pub fn has_texture_alpha(&self, _texture: &Texture) -> bool

Assume all textures has alpha channel for now.

Trait Implementations§

Source§

impl Graphics for GlGraphics

Source§

type Texture = Texture

The texture type associated with the back-end. Read more
Source§

fn clear_color(&mut self, color: [f32; 4])

Clears background with a color. Read more
Source§

fn clear_stencil(&mut self, value: u8)

Clears stencil buffer with a value, usually 0. Read more
Source§

fn tri_list<F>(&mut self, draw_state: &DrawState, color: &[f32; 4], f: F)
where F: FnMut(&mut dyn FnMut(&[[f32; 2]])),

Renders list of 2d triangles using a solid color. Read more
Source§

fn tri_list_c<F>(&mut self, draw_state: &DrawState, f: F)
where F: FnMut(&mut dyn FnMut(&[[f32; 2]], &[[f32; 4]])),

Same as tri_list, but with individual vertex colors. Read more
Source§

fn tri_list_uv<F>( &mut self, draw_state: &DrawState, color: &[f32; 4], texture: &Texture, f: F, )
where F: FnMut(&mut dyn FnMut(&[[f32; 2]], &[[f32; 2]])),

Renders list of 2d triangles using a color and a texture. Read more
Source§

fn tri_list_uv_c<F>(&mut self, draw_state: &DrawState, texture: &Texture, f: F)
where F: FnMut(&mut dyn FnMut(&[[f32; 2]], &[[f32; 2]], &[[f32; 4]])),

Same as tri_list_uv, but with individual vertex colors. Read more
Source§

fn rectangle<R>( &mut self, r: &Rectangle, rectangle: R, draw_state: &DrawState, transform: [[f64; 3]; 2], )
where R: Into<[f64; 4]>,

Draws a rectangle. Read more
Source§

fn polygon( &mut self, p: &Polygon, polygon: &[[f64; 2]], draw_state: &DrawState, transform: [[f64; 3]; 2], )

Draws a polygon. Read more
Source§

fn polygon_tween_lerp( &mut self, p: &Polygon, polygons: &[&[[f64; 2]]], tween_factor: f64, draw_state: &DrawState, transform: [[f64; 3]; 2], )

Draws a tweened polygon using linear interpolation. Read more
Source§

fn image( &mut self, image: &Image, texture: &Self::Texture, draw_state: &DrawState, transform: [[f64; 3]; 2], )

Draws image. Read more
Source§

fn ellipse<R>( &mut self, e: &Ellipse, rectangle: R, draw_state: &DrawState, transform: [[f64; 3]; 2], )
where R: Into<[f64; 4]>,

Draws ellipse. Read more
Source§

fn line<L>( &mut self, l: &Line, line: L, draw_state: &DrawState, transform: [[f64; 3]; 2], )
where L: Into<[f64; 4]>,

Draws line. Read more
Source§

fn circle_arc<R>( &mut self, c: &CircleArc, rectangle: R, draw_state: &DrawState, transform: [[f64; 3]; 2], )
where R: Into<[f64; 4]>,

Draws circle arc. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.