diff --git a/ezgui/src/backend_glow.rs b/ezgui/src/backend_glow.rs index 54ac71d71f..41f9f248e4 100644 --- a/ezgui/src/backend_glow.rs +++ b/ezgui/src/backend_glow.rs @@ -1,9 +1,8 @@ use crate::drawing::Uniforms; use crate::{Canvas, Color, ScreenDims, ScreenRectangle}; -use geom::{Angle, Polygon, Pt2D}; +use geom::Polygon; use glow::HasContext; -use std::cell::{Cell, RefCell}; -use std::collections::{BTreeMap, HashMap}; +use std::cell::Cell; pub fn setup( window_title: &str, @@ -60,6 +59,17 @@ pub fn setup( gl.use_program(Some(program)); gl.enable(glow::SCISSOR_TEST); + + gl.enable(glow::DEPTH_TEST); + gl.depth_func(glow::LEQUAL); + + gl.enable(glow::BLEND); + gl.blend_func_separate( + glow::SRC_ALPHA, + glow::ONE_MINUS_SRC_ALPHA, + glow::SRC_ALPHA, + glow::ONE_MINUS_SRC_ALPHA, + ); } let window_size = event_loop.primary_monitor().size(); @@ -90,6 +100,9 @@ impl<'a> GfxCtxInnards<'a> { Color::RGBA(r, g, b, a) => unsafe { self.gl.clear_color(r, g, b, a); self.gl.clear(glow::COLOR_BUFFER_BIT); + + self.gl.clear_depth_f32(1.0); + self.gl.clear(glow::DEPTH_BUFFER_BIT); }, _ => unreachable!(), } diff --git a/ezgui/src/backend_wasm.rs b/ezgui/src/backend_wasm.rs index 4f06227d1e..ba5f1292b1 100644 --- a/ezgui/src/backend_wasm.rs +++ b/ezgui/src/backend_wasm.rs @@ -81,6 +81,17 @@ pub fn setup( gl.use_program(Some(program)); gl.enable(glow::SCISSOR_TEST); + + gl.enable(glow::DEPTH_TEST); + gl.depth_func(glow::LEQUAL); + + gl.enable(glow::BLEND); + gl.blend_func_separate( + glow::SRC_ALPHA, + glow::ONE_MINUS_SRC_ALPHA, + glow::SRC_ALPHA, + glow::ONE_MINUS_SRC_ALPHA, + ); } ( @@ -109,6 +120,9 @@ impl<'a> GfxCtxInnards<'a> { Color::RGBA(r, g, b, a) => unsafe { self.gl.clear_color(r, g, b, a); self.gl.clear(glow::COLOR_BUFFER_BIT); + + self.gl.clear_depth_f32(1.0); + self.gl.clear(glow::DEPTH_BUFFER_BIT); }, _ => unreachable!(), }