3 #include "Indice2D.h"
\r
4 #include "IndiceTools.h"
\r
5 #include "DomaineMath.h"
\r
6 #include "cudaTools.h"
\r
9 #include "FractalMath.h"
\r
14 /*----------------------------------------------------------------------*\
\r
16 \*---------------------------------------------------------------------*/
\r
18 /*--------------------------------------*\
\r
20 \*-------------------------------------*/
\r
22 /*--------------------------------------*\
\r
24 \*-------------------------------------*/
\r
26 __global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n);
\r
27 __global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i);
\r
28 __device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath);
\r
30 /*--------------------------------------*\
\r
32 \*-------------------------------------*/
\r
34 /*----------------------------------------------------------------------*\
\r
35 |* Implementation *|
\r
36 \*---------------------------------------------------------------------*/
\r
38 /*--------------------------------------*\
\r
40 \*-------------------------------------*/
\r
42 /*--------------------------------------*\
\r
44 \*-------------------------------------*/
\r
47 __global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n)
\r
49 FractalMandelbrotMath fractalMath(n);
\r
50 fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath);
\r
53 __global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i)
\r
55 FractalJuliaMath fractalMath(n, c_r, c_i);
\r
56 fractal(ptrDevPixels, w, h, domaineMath, n, fractalMath);
\r
59 __device__ void fractal(uchar4* ptrDevPixels, int w, int h, const DomaineMath& domaineMath, int n, const FractalMath& fractalMath)
\r
61 const int TID = Indice2D::tid();
\r
62 const int NB_THREAD = Indice2D::nbThread();
\r
63 const int WH = w * h;
\r
66 color.z = 255; // Par défaut, l'image est opaque.
\r
74 IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)
\r
76 // (i,j) domaine ecran
\r
77 // (x,y) domaine math
\r
78 domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y)
\r
80 fractalMath.colorXY(&color, x, y);
\r
82 ptrDevPixels[s] = color;
\r
88 /*----------------------------------------------------------------------*\
\r
90 \*---------------------------------------------------------------------*/
\r