X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F02_Mandelbrot_Julia%2Fmoo%2Fhost%2FFractal.cu;h=bfaff4bd9f6fc9080e8266c349b8a4bfe7e59707;hb=2fd5d915e8a9de4d957d6031d2d68088784eac3c;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..bfaff4b 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 @@ -1,53 +1,18 @@ +#include "Fractal.h" + #include #include +using namespace std; -#include "Fractal.h" +#include "FractalDevice.h" #include "Device.h" -using std::cout; -using std::endl; - -/*----------------------------------------------------------------------*\ - |* Declaration *| - \*---------------------------------------------------------------------*/ - -/*--------------------------------------*\ - |* 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), - 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") +Fractal::Fractal(int w, int h) : + w(w), h(h), + dg(8, 8, 1), + db(16, 16, 1), + title("Fractal Cuda") { - assert(w == h); - //print(dg, db); Device::assertDim(dg, db); } @@ -57,73 +22,102 @@ 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, int dn) : + Fractal(w, h), + variateurAnimationN(IntervalI(10, 100), dn), + n(0) { - 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() +vector FractalMandelbrot::getNames() { - return this->t; + vector name; + name.push_back("n = "); + return name; } -/** - * Override - */ -string Fractal::getTitle() +void FractalMandelbrot::getValues(float* values) { - return this->title; + values[0] = float(this->n); + } + +void FractalMandelbrot::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) + { + fractalMandelbrot<<>>(ptrDevPixels, this->w, this->h, domaineMath, static_cast(this->n)); + } + +///// + +FractalJulia::FractalJulia(int w, int h, int n, float z_r_min, float z_r_max, float z_i_min, float z_i_max) : + Fractal(w, h), + n(n), + 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.0004) + { + this->ptrDomaineMathInit = new DomaineMath(-1.7, -1.4, 1.7, 1.4); } -/*--------------------------------------*\ - |* Private *| - \*-------------------------------------*/ +void FractalJulia::animationStep() + { + this->z_r = this->variateurAnimationR.varierAndGet(); + this->z_i = this->variateurAnimationI.varierAndGet(); + } -/*----------------------------------------------------------------------*\ - |* End *| - \*---------------------------------------------------------------------*/ +vector FractalJulia::getNames() + { + vector name; + name.push_back("z_r = "); + name.push_back("z_i = "); + return name; + } + +void FractalJulia::getValues(float* values) + { + values[0] = this->z_r; + values[1] = this->z_i; + } + +void FractalJulia::runGPU(uchar4* ptrDevPixels, const DomaineMath& domaineMath) + { + fractalJulia<<>>(ptrDevPixels, this->w, this->h, domaineMath, this->n, this->z_r, this->z_i); + }