From 91e5956932d17de17c0c75be20c834cf7a6c6ed9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 3 Feb 2017 13:06:26 -0800 Subject: rototiller: extricate draw_pixel() bounds checking If a z-buffer is added these checks will need to be done independent from and prior to drawing. Also it's silly to makergb() pixels which can't be drawn. --- src/modules/sparkler/simple.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/modules/sparkler/simple.c') diff --git a/src/modules/sparkler/simple.c b/src/modules/sparkler/simple.c index e453e46..74edc24 100644 --- a/src/modules/sparkler/simple.c +++ b/src/modules/sparkler/simple.c @@ -1,6 +1,7 @@ #include #include "draw.h" +#include "fb.h" #include "particle.h" #include "particles.h" @@ -97,10 +98,14 @@ static void simple_draw(particles_t *particles, particle_t *p, int x, int y, fb_ { simple_ctxt_t *ctxt = p->ctxt; - if (!draw_pixel(f, x, y, makergb(0xff, 0xff, 0xff, ((float)ctxt->longevity / ctxt->lifetime)))) { + if (!fb_fragment_contains(f, x, y)) { /* immediately kill off stars that wander off screen */ ctxt->longevity = 0; + + return; } + + draw_pixel(f, x, y, makergb(0xff, 0xff, 0xff, ((float)ctxt->longevity / ctxt->lifetime))); } -- cgit v1.2.1