Ajout du squelette de Newton.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 03_Newton / moo / device / NewtonDevice.cu
diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/03_Newton/moo/device/NewtonDevice.cu
new file mode 100755 (executable)
index 0000000..536b75b
--- /dev/null
@@ -0,0 +1,43 @@
+#include <iostream>\r
+\r
+#include "Indice2D.h"\r
+#include "IndiceTools.h"\r
+#include "DomaineMath.h"\r
+#include "cudaTools.h"\r
+#include "Device.h"\r
+\r
+#include "NewtonMath.h"\r
+\r
+using std::cout;\r
+using std::endl;\r
+\r
+__global__ void newton(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath)\r
+    {\r
+    const int TID = Indice2D::tid();\r
+    const int NB_THREAD = Indice2D::nbThread();\r
+    const int WH = w * h;\r
+\r
+    NewtonMath newtonMath;\r
+\r
+    uchar4 color;\r
+    color.z = 255; // Par défaut, l'image est opaque.\r
+\r
+    double x, y;\r
+    int pixelI, pixelJ;\r
+\r
+    int s = TID;\r
+    while (s < WH)\r
+        {\r
+        IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)\r
+\r
+        // (i,j) domaine ecran\r
+        // (x,y) domaine math\r
+        domaineMath.toXY(pixelI, pixelJ, &x, &y); //  (i,j) -> (x,y)\r
+\r
+        newtonMath.colorXY(&color, x, y);\r
+\r
+        ptrDevPixels[s] = color;\r
+\r
+        s += NB_THREAD;\r
+        }\r
+    }\r