nuclear@0: #include nuclear@2: #include nuclear@2: #include nuclear@2: #include nuclear@0: #include nuclear@0: #include "ocl.h" nuclear@0: nuclear@2: struct RendInfo { nuclear@2: int xsz, ysz; nuclear@2: int num_sph; nuclear@2: int max_iter; nuclear@2: } __attribute__((packed)); nuclear@2: nuclear@1: struct Sphere { nuclear@1: cl_float4 pos; nuclear@1: cl_float radius; nuclear@1: nuclear@1: cl_float4 color; nuclear@1: } __attribute__((packed)); nuclear@1: nuclear@1: struct Ray { nuclear@1: cl_float4 origin, dir; nuclear@1: } __attribute__((packed)); nuclear@1: nuclear@1: nuclear@2: Ray get_primary_ray(int x, int y, int w, int h, float vfov_deg); nuclear@2: bool write_ppm(const char *fname, float *fb, int xsz, int ysz); nuclear@2: nuclear@0: int main() nuclear@0: { nuclear@2: const int xsz = 800; nuclear@2: const int ysz = 600; nuclear@0: nuclear@2: Sphere sphlist[] = { nuclear@2: {{0, 0, 10, 1}, 1.0, {1, 0, 0, 1}} nuclear@2: }; nuclear@2: RendInfo rinf = {xsz, ysz, sizeof sphlist / sizeof *sphlist, 6}; nuclear@2: Ray *prim_rays = new Ray[xsz * ysz]; nuclear@2: float *fb = new float[xsz * ysz * 4]; nuclear@2: nuclear@2: /* calculate primary rays */ nuclear@2: for(int i=0; i