pub struct Renderer {
pub vbo_handle: Option<GlBuffer>,
pub ebo_handle: Option<GlBuffer>,
pub font_atlas_texture: Option<GlTexture>,
pub vertex_array_object: Option<GlVertexArray>,
pub gl_version: GlVersion,
pub has_clip_origin_support: bool,
pub is_destroyed: bool,
/* private fields */
}
Expand description
Main renderer. Borrows the OpenGL context and texture map when required.
Fields§
§vbo_handle: Option<GlBuffer>
§ebo_handle: Option<GlBuffer>
§font_atlas_texture: Option<GlTexture>
§vertex_array_object: Option<GlVertexArray>
§gl_version: GlVersion
§has_clip_origin_support: bool
§is_destroyed: bool
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn new<T: TextureMap>(
gl: &Context,
imgui_context: &mut ImGuiContext,
texture_map: &mut T,
output_srgb: bool,
) -> Result<Self, InitError>
pub fn new<T: TextureMap>( gl: &Context, imgui_context: &mut ImGuiContext, texture_map: &mut T, output_srgb: bool, ) -> Result<Self, InitError>
Create the renderer, initialising OpenGL objects and shaders.
output_srgb
controls whether the shader outputs sRGB colors, or linear
RGB colors. In short:
- If you’re outputting to a display and haven’t specified the framebuffer
is sRGB (e.g. with
gl.enable(glow::FRAMEBUFFER_SRGB)
), then you probably wantoutput_srgb=true
. - OpenGL ES doesn’t support sRGB framebuffers, so you almost always
want
output_srgb=true
if you’re using OpenGL ES and you’re outputting to a display. - If you’re outputting to a display with an sRGB framebuffer (e.g. with
gl.enable(glow::FRAMEBUFFER_SRGB)
), then you probably wantoutput_srgb=false
, as OpenGL will convert to sRGB itself. - If you’re not outputting to a display, but instead to some intermediate
framebuffer, then you probably want
output_srgb=false
to keep the colors in linear color space, and then convert them to sRGB at some later stage.
§Errors
Any error initialising the OpenGL objects (including shaders) will result in an error.
Sourcepub fn initialize<T: TextureMap>(
gl: &Context,
imgui_context: &mut ImGuiContext,
texture_map: &mut T,
output_srgb: bool,
) -> Result<Self, InitError>
👎Deprecated since 0.13.0: use new
instead
pub fn initialize<T: TextureMap>( gl: &Context, imgui_context: &mut ImGuiContext, texture_map: &mut T, output_srgb: bool, ) -> Result<Self, InitError>
new
insteadCreate the renderer, initialising OpenGL objects and shaders.
Sourcepub fn destroy(&mut self, gl: &Context)
pub fn destroy(&mut self, gl: &Context)
This must be called before being dropped to properly free OpenGL resources.
Sourcepub fn render<T: TextureMap>(
&mut self,
gl: &Context,
texture_map: &T,
draw_data: &DrawData,
) -> Result<(), RenderError>
pub fn render<T: TextureMap>( &mut self, gl: &Context, texture_map: &T, draw_data: &DrawData, ) -> Result<(), RenderError>
§Errors
Some OpenGL errors trigger an error (few are explicitly checked, however)
Sourcepub fn set_up_render_state(
&mut self,
gl: &Context,
draw_data: &DrawData,
fb_width: f32,
fb_height: f32,
) -> Result<(), RenderError>
pub fn set_up_render_state( &mut self, gl: &Context, draw_data: &DrawData, fb_width: f32, fb_height: f32, ) -> Result<(), RenderError>
§Errors
Few GL calls are checked for errors, but any that are found will result in an error. Errors from the state manager lifecycle callbacks will also result in an error.
Auto Trait Implementations§
impl Freeze for Renderer
impl RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl UnwindSafe for Renderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more