8 #include "RayTracing.h"
10 #include "RayTracingDevice.h"
13 RayTracing::RayTracing(int w, int h)
19 Device::assertDim(dg, db);
21 const int nbSpheres = 10;
22 Sphere* shperes = this->createSpheres(10);
24 // Copie les spheres dans la constant memory.
27 RayTracing::~RayTracing()
31 void RayTracing::runGPU(uchar4* ptrDevPixels)
33 rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, this->t);
35 HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).
38 void RayTracing::animationStep()
40 this->t += 0.1; // TODO
43 int RayTracing::getW()
48 int RayTracing::getH()
53 float RayTracing::getT()
58 string RayTracing::getTitle()
63 Sphere* RayTracing::createSpheres(int n)
65 Sphere* spheres = new Sphere[n];
66 const float bord = 200;
68 for (int i = 0; i < n; ++i)
70 spheres[i].setR(float(this->alea.uniformeAB(20, this->w / 10 - 1)));
74 float(this->alea.uniformeAB(double(bord), double(this->w - bord))),
75 float(this->alea.uniformeAB(double(bord), double(this->h - bord))),
76 float(this->alea.uniformeAB(10.0, 2.0 * this->w))
79 spheres[i].setCentre(centre);
80 spheres[i].setHueInitial(float(this->alea.uniformeAB(0.0, 1.0)));