X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F02_Mandelbrot_Julia%2Fmoo%2Fhost%2FFractal.cu;h=88a225bb88e15455987a509a8d9b30f487bc48f3;hb=bd178531f80f8bc41c998d1c4588f9e18cc29389;hp=a92b86b6320a2ada62b11756d9a71b37437d38ae;hpb=7798b7c27cf13aaeada22faae8648df8cb339f1b;p=GPU.git diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/host/Fractal.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/host/Fractal.cu index a92b86b..88a225b 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/host/Fractal.cu +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/02_Mandelbrot_Julia/moo/host/Fractal.cu @@ -7,47 +7,15 @@ using std::cout; using std::endl; -/*----------------------------------------------------------------------*\ - |* Declaration *| - \*---------------------------------------------------------------------*/ +extern __global__ void fractalMandelbrot(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n); +extern __global__ void fractalJulia(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float c_r, float c_i); -/*--------------------------------------*\ - |* Imported *| - \*-------------------------------------*/ - -extern __global__ void fractal(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, int n, float t); - -/*--------------------------------------*\ - |* Public *| - \*-------------------------------------*/ - -/*--------------------------------------*\ - |* Private *| - \*-------------------------------------*/ - -/*----------------------------------------------------------------------*\ - |* Implementation *| - \*---------------------------------------------------------------------*/ - -/*--------------------------------------*\ - |* Public *| - \*-------------------------------------*/ - -/*-------------------------*\ - |* Constructeur *| - \*-------------------------*/ - -Fractal::Fractal(int w, int h, float dt, int n) - : w(w), h(h), n(n), +Fractal::Fractal(int w, int h) + : w(w), h(h), dg(8, 8, 1), db(16, 16, 1), - t(0), - variateurAnimation(IntervalF(0, 2 * PI), dt), - ptrDomaineMathInit(new DomaineMath(-2, -1.3, 0.8, 1.3)), title("Fractal Cuda") { - assert(w == h); - //print(dg, db); Device::assertDim(dg, db); } @@ -57,73 +25,79 @@ Fractal::~Fractal() delete this->ptrDomaineMathInit; } -/*-------------------------*\ - |* Methode *| - \*-------------------------*/ - /** * Override */ -void Fractal::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) +int Fractal::getW() { - fractal<<>>(ptrDevPixels, this->w, this->h, domaineMath, this->n, this->t); + return this->w; } /** * Override */ -void Fractal::animationStep() +int Fractal::getH() { - this->t = this->variateurAnimation.varierAndGet(); + return this->h; } -/*--------------*\ - |* get *| - \*--------------*/ - +DomaineMath* Fractal::getDomaineMathInit() + { + return this->ptrDomaineMathInit; + } /** * Override */ -int Fractal::getW() +string Fractal::getTitle() { - return this->w; + return this->title; } -/** - * Override - */ -int Fractal::getH() +///// + +FractalMandelbrot::FractalMandelbrot(int w, int h, float dn) + : Fractal(w, h), variateurAnimationN(IntervalF(30, 100), dn) { - return this->h; + this->ptrDomaineMathInit = new DomaineMath(-2, -1.3, 0.8, 1.3); } -DomaineMath* Fractal::getDomaineMathInit() +void FractalMandelbrot::animationStep() { - return this->ptrDomaineMathInit; + this->n = this->variateurAnimationN.varierAndGet(); } -/** - * Override - */ -float Fractal::getT() +float FractalMandelbrot::getT() { - return this->t; + return this->n; } -/** - * Override - */ -string Fractal::getTitle() +void FractalMandelbrot::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) { - return this->title; + fractalMandelbrot<<>>(ptrDevPixels, this->w, this->h, domaineMath, static_cast(this->n)); + } + +///// + +FractalJulia::FractalJulia(int w, int h, float dn, float z_r_min, float z_r_max, float z_i_min, float z_i_max) + : Fractal(w, h), z_r(z_r_min), z_i(z_i_min), variateurAnimationR(IntervalF(-0.8, -0.7), 0.0005), variateurAnimationI(IntervalF(-0.3, 0.3/*0.15*/), 0.0004) + { + this->ptrDomaineMathInit = new DomaineMath(-1.7, -1.4, 1.7, 1.4); + } + +void FractalJulia::animationStep() + { + this->z_r = this->variateurAnimationR.varierAndGet(); + this->z_i = this->variateurAnimationI.varierAndGet(); } -/*--------------------------------------*\ - |* Private *| - \*-------------------------------------*/ +float FractalJulia::getT() + { + return this->z_r; + } -/*----------------------------------------------------------------------*\ - |* End *| - \*---------------------------------------------------------------------*/ +void FractalJulia::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) + { + fractalJulia<<>>(ptrDevPixels, this->w, this->h, domaineMath, 300, this->z_r, this->z_i); + }