From f92e9c4beb5cb4c642bfc6586771ec12ad1dde47 Mon Sep 17 00:00:00 2001 From: John-Mark Allen Date: Wed, 9 Jun 2021 23:14:55 +0100 Subject: [PATCH] Add a few more docs --- imgui-glow-renderer/src/lib.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/imgui-glow-renderer/src/lib.rs b/imgui-glow-renderer/src/lib.rs index 6f8ef39..8beddae 100644 --- a/imgui-glow-renderer/src/lib.rs +++ b/imgui-glow-renderer/src/lib.rs @@ -42,6 +42,14 @@ impl< /// you probably want to take more control (including ownership of the GL /// context). In those cases, construct an appropriate renderer with /// `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( gl: G, imgui_context: &mut imgui::Context, @@ -117,7 +125,12 @@ where 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( self, gl: G, @@ -127,6 +140,11 @@ where Ok(OwningRenderer:: { 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( self, gl: &G, @@ -142,7 +160,6 @@ where } } -// TODO: builder pattern /// Renderer which owns the OpenGL context. Useful for simple applications, but /// more complicated applications may prefer to keep control of their own /// OpenGL context, or even change that context at runtime.