Skip to content

Commit

Permalink
Changed and to and , and deprecated both methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbox-irl committed Sep 30, 2024
1 parent bdc6b64 commit 852918c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

- Updated `glow` version to `0.14`.
- Fixed an incorrect feature name `bind_vertex_array_support` was called as `vertex_array_support`.
- Changed example image to sipi-4-2-07 (peppers).
- Changed example image to sipi-4-2-07 (peppers).
- Changed `AutoRenderer::initialize` and `Renderer::initialize` to `AutoRenderer::new`
and `Renderer::new`, and deprecated both `initialize` methods.
2 changes: 1 addition & 1 deletion examples/glow_01_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {
let gl = glow_context(&context);

// OpenGL renderer from this crate
let mut ig_renderer = imgui_glow_renderer::AutoRenderer::initialize(gl, &mut imgui_context)
let mut ig_renderer = imgui_glow_renderer::AutoRenderer::new(gl, &mut imgui_context)
.expect("failed to create renderer");

let mut last_frame = Instant::now();
Expand Down
2 changes: 1 addition & 1 deletion examples/glow_02_triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
let (mut winit_platform, mut imgui_context) = utils::imgui_init(&window);
let gl = utils::glow_context(&context);

let mut ig_renderer = imgui_glow_renderer::AutoRenderer::initialize(gl, &mut imgui_context)
let mut ig_renderer = imgui_glow_renderer::AutoRenderer::new(gl, &mut imgui_context)
.expect("failed to create renderer");
let tri_renderer = Triangler::new(ig_renderer.gl_context(), "#version 330");

Expand Down
2 changes: 1 addition & 1 deletion examples/glow_03_triangle_gles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
// Since we're drawing to screen and using OpenGL ES (which doesn't support
// `GL_FRAMEBUFFER_SRGB`) then we do need to convert to sRGB in the shader.
let mut ig_renderer =
imgui_glow_renderer::Renderer::initialize(&gl, &mut imgui_context, &mut texture_map, true)
imgui_glow_renderer::Renderer::new(&gl, &mut imgui_context, &mut texture_map, true)
.expect("failed to create renderer");
// Note the shader header now needs a precision specifier
let tri_renderer = Triangler::new(&gl, "#version 300 es\nprecision mediump float;");
Expand Down
2 changes: 1 addition & 1 deletion examples/glow_04_custom_textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() {
// Note that `output_srgb` is `false`. This is because we set
// `glow::FRAMEBUFFER_SRGB` so we don't have to manually do the conversion
// in the shader.
let mut ig_renderer = Renderer::initialize(&gl, &mut imgui_context, &mut textures, false)
let mut ig_renderer = Renderer::new(&gl, &mut imgui_context, &mut textures, false)
.expect("failed to create renderer");
let textures_ui = TexturesUi::new(&gl, &mut textures);

Expand Down
2 changes: 1 addition & 1 deletion examples/glow_05_framebufferobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
let (mut winit_platform, mut imgui_context) = utils::imgui_init(&window);
let gl = utils::glow_context(&context);

let mut ig_renderer = imgui_glow_renderer::AutoRenderer::initialize(gl, &mut imgui_context)
let mut ig_renderer = imgui_glow_renderer::AutoRenderer::new(gl, &mut imgui_context)
.expect("failed to create renderer");
let tri_renderer = Triangler::new(ig_renderer.gl_context(), "#version 330");

Expand Down
31 changes: 25 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,30 @@ pub struct AutoRenderer {
}

impl AutoRenderer {
/// Creates a new [`AutoRenderer`] for simple rendering.
///
/// # Errors
/// Any error initialising the OpenGL objects (including shaders) will
/// result in an error.
pub fn initialize(
gl: glow::Context,
imgui_context: &mut ImGuiContext,
) -> Result<Self, InitError> {
pub fn new(gl: glow::Context, imgui_context: &mut ImGuiContext) -> Result<Self, InitError> {
let mut texture_map = SimpleTextureMap::default();
let renderer = Renderer::initialize(&gl, imgui_context, &mut texture_map, true)?;
let renderer = Renderer::new(&gl, imgui_context, &mut texture_map, true)?;
Ok(Self {
gl: Rc::new(gl),
texture_map,
renderer,
})
}

/// Creates a new [`AutoRenderer`] for simple rendering.
#[deprecated(since = "0.13.0", note = "use `new` instead")]
pub fn initialize(
gl: glow::Context,
imgui_context: &mut ImGuiContext,
) -> Result<Self, InitError> {
Self::new(gl, imgui_context)
}

/// Note: no need to provide a `mut` version of this, as all methods on
/// [`glow::HasContext`] are immutable.
#[inline]
Expand Down Expand Up @@ -127,7 +135,7 @@ impl Renderer {
/// # Errors
/// Any error initialising the OpenGL objects (including shaders) will
/// result in an error.
pub fn initialize<T: TextureMap>(
pub fn new<T: TextureMap>(
gl: &Context,
imgui_context: &mut ImGuiContext,
texture_map: &mut T,
Expand Down Expand Up @@ -193,6 +201,17 @@ impl Renderer {
Ok(out)
}

/// Create the renderer, initialising OpenGL objects and shaders.
#[deprecated(since = "0.13.0", note = "use `new` instead")]
pub fn initialize<T: TextureMap>(
gl: &Context,
imgui_context: &mut ImGuiContext,
texture_map: &mut T,
output_srgb: bool,
) -> Result<Self, InitError> {
Self::new(gl, imgui_context, texture_map, output_srgb)
}

/// This must be called before being dropped to properly free OpenGL
/// resources.
pub fn destroy(&mut self, gl: &Context) {
Expand Down

0 comments on commit 852918c

Please sign in to comment.