mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 10:44:56 +03:00
add z-buffering to glow/wasm backends. helps #21
This commit is contained in:
parent
0bcbac1fee
commit
ad4ebeeb61
@ -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!(),
|
||||
}
|
||||
|
@ -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!(),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user