clray

diff rt.cl @ 3:88ac4eb2d18a

added OpenGL display of the framebuffer
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 13 Jul 2010 03:38:29 +0300
parents 41d6253492ad
children 3c95d568d3c7
line diff
     1.1 --- a/rt.cl	Mon Jul 12 10:38:07 2010 +0300
     1.2 +++ b/rt.cl	Tue Jul 13 03:38:29 2010 +0300
     1.3 @@ -1,6 +1,6 @@
     1.4  struct RendInfo {
     1.5  	int xsz, ysz;
     1.6 -	int num_sph;
     1.7 +	int num_sph, num_lights;
     1.8  	int max_iter;
     1.9  };
    1.10  
    1.11 @@ -10,6 +10,10 @@
    1.12  	float4 color;
    1.13  };
    1.14  
    1.15 +struct Light {
    1.16 +	float4 pos, color;
    1.17 +};
    1.18 +
    1.19  struct Ray {
    1.20  	float4 origin, dir;
    1.21  };
    1.22 @@ -26,6 +30,7 @@
    1.23  __kernel void render(__global float4 *fb,
    1.24  		__global const struct RendInfo *rinf,
    1.25  		__global const struct Sphere *sphlist,
    1.26 +		__global const struct Light *lights,
    1.27  		__global const struct Ray *primrays)
    1.28  {
    1.29  	int idx = get_global_id(0);
    1.30 @@ -38,6 +43,8 @@
    1.31  	} else {
    1.32  		fb[idx] = (float4)(0, 0, 0, 1);
    1.33  	}
    1.34 +
    1.35 +	fb[idx] = primrays[idx].dir * 0.5 + 0.5;
    1.36  }
    1.37  
    1.38  bool intersect(struct Ray ray,