8 #include "RayTracing.h"
10 #include "RayTracingDevice.h"
12 RayTracing::RayTracing(int w, int h)
18 Device::assertDim(dg, db);
20 const int nbSpheres = 10;
21 Sphere* = this->createSpheres(10);
24 // Copie les spheres dans la constant memory.
27 RayTracing::~RayTracing()
29 delete this->ptrDomaineMathInit;
32 void RayTracing::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath)
34 rayTracing<<<dg,db>>>(ptrDevPixels, this->w, this->h, domaineMath, this->t);
36 HANDLE_ERROR(cudaDeviceSynchronize()); // Pour flusher les 'printf' (pour le DEBUG).
39 void RayTracing::animationStep()
41 this->t += 0.1; // TODO
44 int RayTracing::getW()
49 int RayTracing::getH()
54 float RayTracing::getT()
59 string RayTracing::getTitle()
64 Sphere* createSpheres(int n)
66 Sphere* spheres = new Sphere[n];
67 const float bord = 200;
69 for (int i = 0; i < n; ++i)
71 spheres[i].setR(float(AleaTools::uniformeAB(20, this->w / 10 - 1)));
72 spheres[i].setCentre(float3 {
73 float(AleaTools::uniformeAB(bord, this->w - bord)),
74 float(AleaTools::uniformeAB(bord, this->h - bord)),
75 float(AleaTools::uniformeAB(10, 2.0 * this->w))
77 spheres[i].setHue(float(AleaTools::uniformeAB(0, 1))