Skip to content

Commit

Permalink
less diff
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
  • Loading branch information
sagudev committed Sep 25, 2024
1 parent 948f76d commit a2b109f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::{ContextID, Error, SurfaceAccess, SurfaceInfo, SurfaceType};
use euclid::default::Size2D;
use fnv::{FnvHashMap, FnvHashSet};
use glow as gl;
use glow::Context as Gl;
use glow::HasContext;
use log::debug;
use std::collections::hash_map::Entry;
Expand All @@ -36,8 +37,8 @@ use std::mem;
use std::num::NonZero;
use std::sync::{Arc, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};

fn frame_buffer(frame_buffer: u32) -> Option<glow::NativeFramebuffer> {
NonZero::new(frame_buffer).map(glow::NativeFramebuffer)
fn framebuffer(framebuffer: u32) -> Option<gl::NativeFramebuffer> {
NonZero::new(framebuffer).map(gl::NativeFramebuffer)
}

// The data stored for each swap chain.
Expand All @@ -57,7 +58,7 @@ struct SwapChainData<Device: DeviceAPI> {
}

pub enum PreserveBuffer<'a> {
Yes(&'a glow::Context),
Yes(&'a Gl),
No,
}

Expand Down Expand Up @@ -199,15 +200,15 @@ impl<Device: DeviceAPI> SwapChainData<Device> {
let front_info = device.surface_info(&new_front_buffer);
unsafe {
gl.bind_framebuffer(
glow::READ_FRAMEBUFFER,
frame_buffer(front_info.framebuffer_object),
gl::READ_FRAMEBUFFER,
framebuffer(front_info.framebuffer_object),
);
debug_assert_eq!(gl.get_error(), glow::NO_ERROR);
debug_assert_eq!(gl.get_error(), gl::NO_ERROR);
gl.bind_framebuffer(
glow::DRAW_FRAMEBUFFER,
frame_buffer(back_info.framebuffer_object),
gl::DRAW_FRAMEBUFFER,
framebuffer(back_info.framebuffer_object),
);
debug_assert_eq!(gl.get_error(), glow::NO_ERROR);
debug_assert_eq!(gl.get_error(), gl::NO_ERROR);
gl.blit_framebuffer(
0,
0,
Expand Down Expand Up @@ -352,7 +353,7 @@ impl<Device: DeviceAPI> SwapChainData<Device> {
&mut self,
device: &mut Device,
context: &mut Device::Context,
gl: &glow::Context,
gl: &Gl,
color: [f32; 4],
) -> Result<(), Error> {
self.validate_context(device, context)?;
Expand Down Expand Up @@ -402,7 +403,7 @@ impl<Device: DeviceAPI> SwapChainData<Device> {
.unwrap()
.framebuffer_object;
unsafe {
gl.bind_framebuffer(gl::FRAMEBUFFER, frame_buffer(fbo));
gl.bind_framebuffer(gl::FRAMEBUFFER, framebuffer(fbo));
gl.clear_color(color[0], color[1], color[2], color[3]);
gl.clear_depth_f64(1.);
gl.clear_stencil(0);
Expand All @@ -428,8 +429,8 @@ impl<Device: DeviceAPI> SwapChainData<Device> {

// Restore the GL state
unsafe {
gl.bind_framebuffer(gl::DRAW_FRAMEBUFFER, frame_buffer(bound_fbos[0] as _));
gl.bind_framebuffer(gl::READ_FRAMEBUFFER, frame_buffer(bound_fbos[1] as _));
gl.bind_framebuffer(gl::DRAW_FRAMEBUFFER, framebuffer(bound_fbos[0] as _));
gl.bind_framebuffer(gl::READ_FRAMEBUFFER, framebuffer(bound_fbos[1] as _));
gl.clear_color(
clear_color[0],
clear_color[1],
Expand Down Expand Up @@ -581,7 +582,7 @@ impl<Device: DeviceAPI> SwapChain<Device> {
&self,
device: &mut Device,
context: &mut Device::Context,
gl: &glow::Context,
gl: &Gl,
color: [f32; 4],
) -> Result<(), Error> {
self.lock().clear_surface(device, context, gl, color)
Expand Down

0 comments on commit a2b109f

Please sign in to comment.