Add a few more docs

This commit is contained in:
John-Mark Allen 2021-06-09 23:14:55 +01:00 committed by Jack Spira
parent f1bd13b73e
commit f92e9c4beb

View File

@ -42,6 +42,14 @@ impl<
/// you probably want to take more control (including ownership of the GL /// you probably want to take more control (including ownership of the GL
/// context). In those cases, construct an appropriate renderer with /// context). In those cases, construct an appropriate renderer with
/// `RendererBuilder`. /// `RendererBuilder`.
///
/// By default, it constructs a renderer which owns the OpenGL context and
/// attempts to backup the OpenGL state before rendering and restore it after
/// rendering.
///
/// # Errors
/// Any error initialising the OpenGL objects (including shaders) will
/// result in an error.
pub fn auto_renderer<G: Gl>( pub fn auto_renderer<G: Gl>(
gl: G, gl: G,
imgui_context: &mut imgui::Context, imgui_context: &mut imgui::Context,
@ -117,7 +125,12 @@ where
phantom_gl: self.phantom_gl, phantom_gl: self.phantom_gl,
} }
} }
/// Build a renderer which owns the OpenGL context (which can be borrowed
/// from the renderer, but not taken).
///
/// # Errors
/// Any error initialising the OpenGL objects (including shaders) will
/// result in an error.
pub fn build_owning( pub fn build_owning(
self, self,
gl: G, gl: G,
@ -127,6 +140,11 @@ where
Ok(OwningRenderer::<G, T, S, C> { gl, renderer }) Ok(OwningRenderer::<G, T, S, C> { gl, renderer })
} }
/// Build a renderer which needs to borrow a context in order to render.
///
/// # Errors
/// Any error initialising the OpenGL objects (including shaders) will
/// result in an error.
pub fn build_borrowing( pub fn build_borrowing(
self, self,
gl: &G, gl: &G,
@ -142,7 +160,6 @@ where
} }
} }
// TODO: builder pattern
/// Renderer which owns the OpenGL context. Useful for simple applications, but /// Renderer which owns the OpenGL context. Useful for simple applications, but
/// more complicated applications may prefer to keep control of their own /// more complicated applications may prefer to keep control of their own
/// OpenGL context, or even change that context at runtime. /// OpenGL context, or even change that context at runtime.