Skip to content

Commit 4224677

Browse files
committed
WIP wireframe debug support
1 parent e89cdd4 commit 4224677

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

core/src/render.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ use crate::math::{
1616
Lerp,
1717
};
1818

19-
use crate::render::raster::line;
2019
use clip::{view_frustum, ClipVert};
2120
use ctx::{Context, DepthSort, FaceCull};
22-
use raster::{tri_fill, ScreenPt};
21+
use raster::{line, tri_fill, ScreenPt};
2322
use shader::{FragmentShader, VertexShader};
2423
use stats::Stats;
2524
use target::Target;
@@ -134,7 +133,6 @@ pub fn render<Vtx: Clone, Var: Lerp + Vary, Uni: Copy, Shd>(
134133
let vs = project(vs, to_screen);
135134

136135
// Back/frontface culling
137-
//
138136
// TODO This could also be done earlier, before or as part of clipping
139137
match ctx.face_cull {
140138
Some(FaceCull::Back) if is_backface(&vs) => continue,
@@ -147,10 +145,26 @@ pub fn render<Vtx: Clone, Var: Lerp + Vary, Uni: Copy, Shd>(
147145
stats.verts.o += 3;
148146

149147
// Fragment shader and rasterization
150-
tri_fill(vs, |scanline| {
148+
tri_fill(vs.clone(), |scanline| {
151149
// Convert to fragments and shade
152-
stats.frags += target.rasterize(scanline, uniform, shader, ctx);
150+
// stats.frags += target.rasterize(scanline, uniform, shader, ctx);
153151
});
152+
153+
/*let [a, b, c] = vs;
154+
//let mut ctx = ctx.clone();
155+
//ctx.depth_test = None;
156+
for [mut a, mut b] in [[a.clone(), b.clone()], [a, c.clone()], [b, c]] {
157+
a.pos.0[2] += 2e-3;
158+
b.pos.0[2] += 2e-3;
159+
line([a, b], |scanline| {
160+
target.rasterize(
161+
scanline,
162+
uniform,
163+
&|_, _| rgba(0x0, 0, 0, 0xff),
164+
&ctx,
165+
);
166+
});
167+
}*/
154168
}
155169
*ctx.stats.borrow_mut() += stats.finish();
156170
}
@@ -190,7 +204,7 @@ pub fn render_lines<Vtx: Clone, Var: Lerp + Vary, Uni: Copy, Shd>(
190204

191205
// Log output stats after culling
192206
stats.prims.o += 1;
193-
stats.verts.o += 3;
207+
stats.verts.o += 2;
194208

195209
// Fragment shader and rasterization
196210
line(vs, |scanline| {
@@ -201,12 +215,12 @@ pub fn render_lines<Vtx: Clone, Var: Lerp + Vary, Uni: Copy, Shd>(
201215
*ctx.stats.borrow_mut() += stats.finish();
202216
}
203217

204-
fn transform<'a, I, S, U, V, A>(verts: I, shd: &S, uni: U) -> Vec<ClipVert<A>>
218+
fn transform<'a, I, V, S, U, A>(verts: I, shd: &S, uni: U) -> Vec<ClipVert<A>>
205219
where
206220
I: IntoIterator<Item = &'a V>,
221+
V: Clone + 'a,
207222
S: VertexShader<V, U, Output = Vertex<ProjVec4, A>>,
208223
U: Copy,
209-
V: Clone + 'a,
210224
{
211225
verts
212226
.into_iter()

0 commit comments

Comments
 (0)