Struct opengl_graphics::GlGraphics
source · pub struct GlGraphics { /* private fields */ }
Expand description
Contains OpenGL data.
Implementations§
source§impl GlGraphics
impl GlGraphics
sourcepub fn get_uniform<T: UniformType + ?Sized>(
&self,
name: &str
) -> Option<ShaderUniform<T>>
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<'a> GlGraphics
impl<'a> GlGraphics
sourcepub fn new(opengl: OpenGL) -> Self
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.
sourcepub fn from_colored_textured(colored: Colored, textured: Textured) -> Self
pub fn from_colored_textured(colored: Colored, textured: Textured) -> Self
Create a new OpenGL back-end with Colored
and Textured
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.
sourcepub fn viewport(&mut self, x: i32, y: i32, w: i32, h: i32)
pub fn viewport(&mut self, x: i32, y: i32, w: i32, h: i32)
Sets viewport with normalized coordinates and center as origin.
sourcepub fn get_current_program(&self) -> Option<GLuint>
pub fn get_current_program(&self) -> Option<GLuint>
Returns the current program
sourcepub fn use_program(&mut self, program: GLuint)
pub fn use_program(&mut self, program: GLuint)
Sets the current program only if the program is not in use.
sourcepub fn clear_program(&mut self)
pub fn clear_program(&mut self)
Unset the current program.
This forces the current program to be set on next drawing call.
sourcepub fn use_draw_state(&mut self, draw_state: &DrawState)
pub fn use_draw_state(&mut self, draw_state: &DrawState)
Sets the current draw state, by detecting changes.
sourcepub fn clear_draw_state(&mut self)
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.
sourcepub fn draw_begin(&mut self, viewport: Viewport) -> Context
pub fn draw_begin(&mut self, viewport: Viewport) -> Context
Setup that should be called at the start of a frame’s draw call.
sourcepub fn draw<F, U>(&mut self, viewport: Viewport, f: F) -> Uwhere
F: FnOnce(Context, &mut Self) -> U,
pub fn draw<F, U>(&mut self, viewport: Viewport, f: F) -> Uwhere
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.
sourcepub fn has_texture_alpha(&self, _texture: &Texture) -> bool
pub fn has_texture_alpha(&self, _texture: &Texture) -> bool
Assume all textures has alpha channel for now.