/// 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.
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 `), 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 `), 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.
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 ` ) 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 ` ) 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 .
pub fn initialize<T: TextureMap>(
        gl: &Context,
        imgui_context: &mut imgui::Context,
        texture_map: &mut T,
        output_srgb: bool,
    ) -> Result<Self, InitError> {
        #![allow(
            clippy::similar_names,
            clippy::cast_sign_loss,
            clippy::shadow_unrelated
        )]
        let gl_version = GlVersion::read(gl);
        #[cfg(feature = "clip_origin_support")]
        let has_clip_origin_support = {
            let support = gl_version.clip_origin_support();
            #[cfg(feature = "gl_extensions_support")]
            if support {
                support
            } else {
                let extensions_count = unsafe { gl.get_parameter_i32(glow::NUM_EXTENSIONS) } as u32;
                (0..extensions_count).any(|index| {
                    let extension_name =
                        unsafe { gl.get_parameter_indexed_string(glow::EXTENSIONS, index) };
                    extension_name == "GL_ARB_clip_control"
                })
            }
            #[cfg(not(feature = "gl_extensions_support"))]
            support
        };
        #[cfg(not(feature = "clip_origin_support"))]
        let has_clip_origin_support = false;
        let mut state_backup = GlStateBackup::default();
        state_backup.pre_init(gl);
        let font_atlas_texture = prepare_font_atlas(gl, imgui_context.fonts(), texture_map)?;
        let shaders = Shaders::new(gl, gl_version, output_srgb)?;
        let vbo_handle = unsafe { gl.create_buffer() }.map_err(InitError::CreateBufferObject)?;
        let ebo_handle = unsafe { gl.create_buffer() }.map_err(InitError::CreateBufferObject)?;
        state_backup.post_init(gl);
        let out = Self {
            shaders,
            state_backup,
            vbo_handle,
            ebo_handle,
            font_atlas_texture,
            #[cfg(feature = "bind_vertex_array_support")]
            vertex_array_object: 0,
            gl_version,
            has_clip_origin_support,
            is_destroyed: false,
        };
        // Leave this until the end of the function to avoid changing state if
        // there was ever an error above
        out.configure_imgui_context(imgui_context);
        Ok(out)
    }
pub fn initialize < T : TextureMap > ( gl : & Context , imgui_context : & mut imgui :: Context , texture_map : & mut T , output_srgb : bool , ) -> Result < Self , InitError > { # ! [ allow ( clippy similar_names clippy cast_sign_loss clippy shadow_unrelated ) ] let gl_version = GlVersion :: read ( gl ) ; # [ cfg ( feature " " ) ] let has_clip_origin_support = { let support = gl_version . clip_origin_support ( ) ; # [ cfg ( feature " " ) ] if support { support } else { let extensions_count = unsafe { gl . get_parameter_i32 ( glow :: NUM_EXTENSIONS ) } as u32 ; ( 0 .. extensions_count ) . any ( | index | { let extension_name = unsafe { gl . get_parameter_indexed_string ( glow :: EXTENSIONS , index ) } ; extension_name == " " } ) } # [ cfg ( not ( feature " " ) ) ] support } ; # [ cfg ( not ( feature " " ) ) ] let has_clip_origin_support = false ; let mut state_backup = GlStateBackup :: default ( ) ; state_backup . pre_init ( gl ) ; let font_atlas_texture = prepare_font_atlas ( gl , imgui_context . fonts ( ) , texture_map ) ? ; let shaders = Shaders :: new ( gl , gl_version , output_srgb ) ? ; let vbo_handle = unsafe { gl . create_buffer ( ) } . map_err ( InitError :: CreateBufferObject ) ? ; let ebo_handle = unsafe { gl . create_buffer ( ) } . map_err ( InitError :: CreateBufferObject ) ? ; state_backup . post_init ( gl ) ; let out = Self { shaders , state_backup , vbo_handle , ebo_handle , font_atlas_texture , # [ cfg ( feature " " ) ] vertex_array_object : 0 , gl_version , has_clip_origin_support , is_destroyed : false , } ; // Leave this until the end of the function to avoid changing state if // there was ever an error above out . configure_imgui_context ( imgui_context ) ; Ok ( out ) }
Create the renderer, initialising OpenGL objects and shaders.
Create the renderer initialising OpenGL objects and shaders .
gl
&Context
imgui_context
&mut imgui::Context
texture_map
&mut T
output_srgb
bool
errors
Any error initialising the OpenGL objects (including shaders) will
result in an error.
Any error initialising the OpenGL objects ( including shaders ) will result in an error .