erebus
diff liberebus/src/erebus.cc @ 5:9621beb22694
huh?
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 24 May 2014 02:20:44 +0300 |
parents | 93894c232d65 |
children | e2d9bf168a41 |
line diff
1.1 --- a/liberebus/src/erebus.cc Tue Apr 29 07:38:40 2014 +0300 1.2 +++ b/liberebus/src/erebus.cc Sat May 24 02:20:44 2014 +0300 1.3 @@ -7,6 +7,7 @@ 1.4 #include "image.h" 1.5 #include "scene.h" 1.6 #include "geomobj.h" 1.7 +#include "rt.h" 1.8 1.9 using namespace std::chrono; 1.10 1.11 @@ -175,7 +176,18 @@ 1.12 1.13 static void render_pixel(struct erebus *ctx, int x, int y) 1.14 { 1.15 - float *pix = ctx->fbimg.get_pixels() + (y * ctx->fbimg.get_width() + x) * 4; 1.16 - pix[0] = pix[1] = pix[2] = 0.0f; 1.17 - pix[3] = 1.0f; 1.18 + Camera *cam = ctx->scn->get_active_camera(); 1.19 + if(!cam) return; 1.20 + 1.21 + int xsz = ctx->fbimg.get_width(); 1.22 + int ysz = ctx->fbimg.get_height(); 1.23 + float *pix = ctx->fbimg.get_pixels() + (y * xsz + x) * 4; 1.24 + 1.25 + Ray ray = cam->get_primary_ray(x, y, xsz, ysz, 0); 1.26 + //Color c = ray_trace(ray, ctx->scn, 0); 1.27 + Color c = ray.dir.normalized() * 0.5 + Vector3(0.5, 0.5, 0.5); 1.28 + pix[0] = 1.0;//c.x; 1.29 + pix[1] = c.y; 1.30 + pix[2] = c.z; 1.31 + pix[3] = c.w; 1.32 }