[haiku-commits] BRANCH waddlesplash-github.mandelbrot_new [a60b0085b81d] src/apps/mandelbrot

  • From: waddlesplash-github.mandelbrot_new <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 18 Jun 2016 05:00:37 +0200 (CEST)

added 3 changesets to branch 'refs/remotes/waddlesplash-github/mandelbrot_new'
old head: 45477f7a0f75897d95fe588885eb697f75c8c230
new head: a60b0085b81dca25a902807f2c5830d39d2b20c5
overview: 
https://github.com/waddlesplash/haiku/compare/45477f7a0f75...a60b0085b81d

----------------------------------------------------------------------------

a33a774f114d: Mandelbrot: Get rid of RenderPixelSmooth.

5cb3e7cf14ac: Mandelbrot: Style fixes.

a60b0085b81d: Mandelbrot: Fix the last warnings, enable -Werror.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 24 insertions(+), 76 deletions(-)
src/apps/mandelbrot/FractalEngine.cpp | 94 ++++++++-----------------------
src/apps/mandelbrot/FractalEngine.h   |  4 +-
src/apps/mandelbrot/Jamfile           |  2 -

############################################################################

Commit:      a33a774f114d169aea48528b6939c319ab7a8db0
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Jun 18 02:36:09 2016 UTC

Mandelbrot: Get rid of RenderPixelSmooth.

----------------------------------------------------------------------------

diff --git a/src/apps/mandelbrot/FractalEngine.cpp 
b/src/apps/mandelbrot/FractalEngine.cpp
index d26620d..7c1eebf 100644
--- a/src/apps/mandelbrot/FractalEngine.cpp
+++ b/src/apps/mandelbrot/FractalEngine.cpp
@@ -27,7 +27,6 @@ FractalEngine::FractalEngine(BHandler* parent, BLooper* 
looper)
        fRenderBufferLen(0),
        fColorset(Colorset_Royal)
 {
-       fRenderPixel = &FractalEngine::RenderPixelDefault;
        fDoSet = &FractalEngine::DoSet_Mandelbrot;
 }
 
@@ -108,12 +107,7 @@ int32 gIterations = 1024;
 double gPower = 0;
 
 
-#define RenderBuffer_SetPixel(x, y, r, g, b) \
-       uint32 _BUF_BASE = fWidth * y * 3 + x * 3; \
-       fRenderBuffer[_BUF_BASE + 0] = r; \
-       fRenderBuffer[_BUF_BASE + 1] = g; \
-       fRenderBuffer[_BUF_BASE + 2] = b
-void FractalEngine::RenderPixelDefault(uint32 x, uint32 y, double real,
+void FractalEngine::RenderPixel(uint32 x, uint32 y, double real,
        double imaginary)
 {
        int32 iterToEscape = (this->*fDoSet)(real, imaginary);
@@ -125,50 +119,13 @@ void FractalEngine::RenderPixelDefault(uint32 x, uint32 
y, double real,
                loc = 998 - (iterToEscape % 999);
        }
 
-       RenderBuffer_SetPixel(x, y, fColorset[loc * 3 + 0], fColorset[loc * 3 + 
1],
-               fColorset[loc * 3 + 2]);
+       uint32 offsetBase = fWidth * y * 3 + x * 3;
+       fRenderBuffer[offsetBase + 0] = fColorset[loc * 3 + 0];
+       fRenderBuffer[offsetBase + 1] = fColorset[loc * 3 + 1];
+       fRenderBuffer[offsetBase + 2] = fColorset[loc * 3 + 2];
 }
 
 
-void FractalEngine::RenderPixelSmooth(uint32 x, uint32 y, double real,
-       double imaginary)
-{
-       int32 outColor = (this->*fDoSet)(real, imaginary);
-       int8 mapperDiff_r = 0;
-       int8 mapperDiff_g = 0;
-       int8 mapperDiff_b = 0;
-
-       int16 mapperLoc = 0;
-
-       double dist = sqrt(zReal_end * zReal_end + zImaginary_end * 
zImaginary_end);
-
-       double ratio = (1 - (log(log(dist))) / log(2));
-       if (sqrt(real * real + imaginary * imaginary) > 8) {
-                // Make the colors >8 be flat.
-               ratio = -1.0821509904820257;
-               outColor = 1;
-       }
-
-       if (outColor == -1) {
-               RenderBuffer_SetPixel(x, y, fColorset[999 * 3], fColorset[999 * 
3 + 1],
-                       fColorset[999 * 3 + 2]);
-               return;
-       }
-       outColor = 998 - (outColor % 999);
-
-       mapperLoc = outColor * 3;
-
-       mapperDiff_r = fColorset[mapperLoc + 0] - fColorset[mapperLoc + 0 + 3];
-       mapperDiff_g = fColorset[mapperLoc + 1] - fColorset[mapperLoc + 1 + 3];
-       mapperDiff_b = fColorset[mapperLoc + 2] - fColorset[mapperLoc + 2 + 3];
-
-       RenderBuffer_SetPixel(x, y, mapperDiff_r * ratio + fColorset[mapperLoc 
+ 0],
-               mapperDiff_g * ratio + fColorset[mapperLoc + 1],
-               mapperDiff_b * ratio + fColorset[mapperLoc + 2]);
-}
-#undef RenderBuffer_SetPixel
-
-
 int32 FractalEngine::DoSet_Mandelbrot(double real, double imaginary)
 {
        double zReal = 0;
@@ -390,8 +347,7 @@ void FractalEngine::Render(double locationX, double 
locationY, double size)
 
        for (uint32 x = 0; x < fWidth; x++) {
                for (uint32 y = 0; y < fHeight; y++) {
-                       (this->*fRenderPixel)(x, y,
-                               (x * size + locationX) - (halfWidth * size),
+                       RenderPixel(x, y, (x * size + locationX) - (halfWidth * 
size),
                                (y * -size + locationY) - (halfHeight * -size));
                }
        }
diff --git a/src/apps/mandelbrot/FractalEngine.h 
b/src/apps/mandelbrot/FractalEngine.h
index a1a5ea0..fce2384 100644
--- a/src/apps/mandelbrot/FractalEngine.h
+++ b/src/apps/mandelbrot/FractalEngine.h
@@ -43,11 +43,9 @@ private:
        const uint8* fColorset;
 
        int32 (FractalEngine::*fDoSet)(double real, double imaginary);
-       void (FractalEngine::*fRenderPixel)(uint32 x, uint32 y, double real, 
double imaginary);
 
        void Render(double locationX, double locationY, double size);
-       void RenderPixelDefault(uint32 x, uint32 y, double real, double 
imaginary);
-       void RenderPixelSmooth(uint32 x, uint32 y, double real, double 
imaginary);
+       void RenderPixel(uint32 x, uint32 y, double real, double imaginary);
        int32 DoSet_Mandelbrot(double real, double imaginary);
        int32 DoSet_BurningShip(double real, double imaginary);
        int32 DoSet_Tricorn(double real, double imaginary);

############################################################################

Commit:      5cb3e7cf14acfd1b1c7c796f4cf2e28b46b3561d
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Jun 18 02:37:15 2016 UTC

Mandelbrot: Style fixes.

----------------------------------------------------------------------------

diff --git a/src/apps/mandelbrot/FractalEngine.cpp 
b/src/apps/mandelbrot/FractalEngine.cpp
index 7c1eebf..9b6c5de 100644
--- a/src/apps/mandelbrot/FractalEngine.cpp
+++ b/src/apps/mandelbrot/FractalEngine.cpp
@@ -134,8 +134,7 @@ int32 FractalEngine::DoSet_Mandelbrot(double real, double 
imaginary)
        int32 iterations = gIterations;
        uint8 escapeHorizon = gEscapeHorizon;
 
-       int32 i = 0;
-       for (i = 0; i < iterations; i++) {
+       for (int32 i = 0; i < iterations; i++) {
                double zRealSq = zReal * zReal;
                double zImaginarySq = zImaginary * zImaginary;
                double nzReal = (zRealSq + (-1 * (zImaginarySq)));
@@ -146,8 +145,8 @@ int32 FractalEngine::DoSet_Mandelbrot(double real, double 
imaginary)
                zReal += real;
                zImaginary += imaginary;
 
-               if ((zRealSq) + (zImaginarySq) >
-                       escapeHorizon) { // If it is outside the 2 unit 
circle...
+               // If it is outside the 2 unit circle...
+               if ((zRealSq) + (zImaginarySq) > escapeHorizon) {
                        zReal_end = zReal;
                        zImaginary_end = zImaginary;
 
@@ -169,8 +168,7 @@ int32 FractalEngine::DoSet_BurningShip(double real, double 
imaginary)
        int32 iterations = gIterations;
        uint8 escapeHorizon = gEscapeHorizon;
 
-       int32 i = 0;
-       for (i = 0; i < iterations; i++) {
+       for (int32 i = 0; i < iterations; i++) {
                zReal = fabs(zReal);
                zImaginary = fabs(zImaginary);
 
@@ -206,8 +204,7 @@ int32 FractalEngine::DoSet_Tricorn(double real, double 
imaginary)
        int32 iterations = gIterations;
        uint8 escapeHorizon = gEscapeHorizon;
 
-       int32 i = 0;
-       for (i = 0; i < iterations; i++) {
+       for (int32 i = 0; i < iterations; i++) {
                double znRe = zImaginary * -1;
                zImaginary = zReal * -1;
                zReal = znRe; // Swap the real and complex parts each time.
@@ -245,8 +242,7 @@ int32 FractalEngine::DoSet_Julia(double real, double 
imaginary)
        int32 iterations = gIterations;
        uint8 escapeHorizon = gEscapeHorizon;
 
-       int32 i = 0;
-       for (i = 0; i < iterations; i++) {
+       for (int32 i = 0; i < iterations; i++) {
                double zRealSq = zReal * zReal;
                double zImaginarySq = zImaginary * zImaginary;
                double nzReal = (zRealSq + (-1 * (zImaginarySq)));
@@ -280,8 +276,7 @@ int32 FractalEngine::DoSet_OrbitTrap(double real, double 
imaginary)
        int32 iterations = gIterations;
        uint8 escapeHorizon = gEscapeHorizon;
 
-       int32 i = 0;
-       for (i = 0; i < iterations; i++) {
+       for (int32 i = 0; i < iterations; i++) {
                double zRealSq = zReal * zReal;
                double zImaginarySq = zImaginary * zImaginary;
                double nzReal = (zRealSq + (-1 * (zImaginarySq)));
@@ -316,8 +311,7 @@ int32 FractalEngine::DoSet_Multibrot(double real, double 
imaginary)
        int32 iterations = gIterations;
        uint8 escapeHorizon = gEscapeHorizon;
 
-       int32 i = 0;
-       for (i = 0; i < iterations; i++) {
+       for (int32 i = 0; i < iterations; i++) {
                double zRealSq = zReal * zReal;
                double zImaginarySq = zImaginary * zImaginary;
                double nzReal = (zRealSq * zReal - 3 * zReal * (zImaginarySq));

############################################################################

Commit:      a60b0085b81dca25a902807f2c5830d39d2b20c5
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Jun 18 02:42:31 2016 UTC

Mandelbrot: Fix the last warnings, enable -Werror.

----------------------------------------------------------------------------

diff --git a/src/apps/mandelbrot/FractalEngine.cpp 
b/src/apps/mandelbrot/FractalEngine.cpp
index 9b6c5de..77a2141 100644
--- a/src/apps/mandelbrot/FractalEngine.cpp
+++ b/src/apps/mandelbrot/FractalEngine.cpp
@@ -97,14 +97,14 @@ void FractalEngine::MessageReceived(BMessage* msg)
 double zReal_end = 0;
 double zImaginary_end = 0;
 
-double juliaC_a = 0;
-double juliaC_b = 1;
+const double juliaC_a = 0;
+const double juliaC_b = 1;
 
-uint8 gEscapeHorizon = 4; // set to 64 when doing smooth colors
+const uint8 gEscapeHorizon = 4;
 
-int32 gIterations = 1024;
+const int32 gIterations = 1024;
 
-double gPower = 0;
+const double gPower = 0;
 
 
 void FractalEngine::RenderPixel(uint32 x, uint32 y, double real,
@@ -264,6 +264,7 @@ int32 FractalEngine::DoSet_Julia(double real, double 
imaginary)
        return -1;
 }
 
+
 int32 FractalEngine::DoSet_OrbitTrap(double real, double imaginary)
 {
        double zReal = 0;
@@ -297,12 +298,13 @@ int32 FractalEngine::DoSet_OrbitTrap(double real, double 
imaginary)
                if (distance > escapeHorizon) {
                        zReal_end = zReal;
                        zImaginary_end = zImaginary;
-                       return floor(4 * log(4 / closest));
+                       return static_cast<int32>(floor(4 * log(4 / closest)));
                }
        }
-       return floor(4 * log(4 / closest));
+       return static_cast<int32>(floor(4 * log(4 / closest)));
 }
 
+
 int32 FractalEngine::DoSet_Multibrot(double real, double imaginary)
 {
        double zReal = 0;
diff --git a/src/apps/mandelbrot/Jamfile b/src/apps/mandelbrot/Jamfile
index e257efe..c8ea3de 100644
--- a/src/apps/mandelbrot/Jamfile
+++ b/src/apps/mandelbrot/Jamfile
@@ -2,8 +2,6 @@ SubDir HAIKU_TOP src apps mandelbrot ;
 
 AddSubDirSupportedPlatforms libbe_test ;
 
-SubDirC++Flags -Wno-error ;
-
 Application Mandelbrot :
        Mandelbrot.cpp
        FractalEngine.cpp


Other related posts:

  • » [haiku-commits] BRANCH waddlesplash-github.mandelbrot_new [a60b0085b81d] src/apps/mandelbrot - waddlesplash-github . mandelbrot_new