Struct Renderer

Source
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

Source

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 want output_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 want output_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.

Source

pub 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

Create the renderer, initialising OpenGL objects and shaders.

Source

pub fn destroy(&mut self, gl: &Context)

This must be called before being dropped to properly free OpenGL resources.

Source

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)

Source

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§

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, 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.