From 8a2b77a41da57954666fa8fb75913e51851ad5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sat, 8 Jun 2019 11:37:23 +0200 Subject: [PATCH] Add noie --- programs/modelViewer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/programs/modelViewer.c b/programs/modelViewer.c index e6f3c5c..61354eb 100644 --- a/programs/modelViewer.c +++ b/programs/modelViewer.c @@ -9,6 +9,7 @@ #include #include #include +#include #define S3L_FLAT 0 #define S3L_STRICT_NEAR_CULLING 1 @@ -125,6 +126,7 @@ uint16_t l0, l1, l2; S3L_Vec4 toLight; int8_t light = 1; int8_t fog = 0; +int8_t noise = 0; int8_t mode = 0; S3L_Vec4 n0, n1, n2, nt; @@ -319,7 +321,10 @@ void drawPixel(S3L_PixelInfo *p) b = S3L_clamp(((int16_t) b) + f,0,255); } - setPixel(p->x,p->y,r,g,b); + if (noise) + setPixel(p->x + rand() % 8,p->y + rand() % 8,r,g,b); + else + setPixel(p->x,p->y,r,g,b); } void draw() @@ -430,6 +435,8 @@ int main() light = !light; else if (event.key.keysym.scancode == SDL_SCANCODE_F) fog = !fog; + else if (event.key.keysym.scancode == SDL_SCANCODE_N) + noise = !noise; else if (event.key.keysym.scancode == SDL_SCANCODE_SPACE) { modelIndex = (modelIndex + 1) % modelsTotal;