#include "SL_Generated.h" #include "../../../ThirdParty/CImg/CImg.h" using namespace std; using namespace cimg_library; int main(int argc, char ** argv) { int cores = 0; Sequence > computeResult; Sequence > colorResult; sl_init(cores); int maxIters = 1000; int imageWidth = 1920; int imageHeight = 1200; double maxMag = 256; double xmin = -2.5; double xmax = 1.0; double ymin = -1.0; double ymax = 1.0; CImg visu(imageWidth, imageHeight, 1, 3); CImgDisplay draw_disp(visu, "Mandelbrot Fractal in SequenceL"); bool redraw = true; SLTimer t; double computeTime; double colorTime; double renderTime; while(!draw_disp.is_closed()) { if(redraw) { redraw = false; t.start(); sl_zSquared(xmin, xmax, imageWidth, ymin, ymax, imageHeight, maxMag, maxIters, cores, computeResult); t.stop(); computeTime = t.getTime(); t.start(); sl_getSmoothColorings(computeResult, maxIters, cores, colorResult); t.stop(); colorTime = t.getTime(); t.start(); visu.fill(0); for(int i = 1; i <= colorResult.size(); i++) { for(int j = 1; j <= colorResult[i].size(); j++) { visu(j-1,i-1,0,0) = colorResult[i][j].R; visu(j-1,i-1,0,1) = colorResult[i][j].G; visu(j-1,i-1,0,2) = colorResult[i][j].B; } } visu.display(draw_disp); t.stop(); renderTime = t.getTime(); draw_disp.set_title("X:[%f, %f] Y:[%f, %f] | Mandelbrot Fractal in SequenceL | Compute Time: %f | Color Time: %f | Render Time: %f | Total FPS: %f", xmin, xmax, ymin, ymax, cores, computeTime, colorTime, renderTime, 1 / (computeTime + colorTime + renderTime)); } draw_disp.wait(); double xdiff = (xmax - xmin); double ydiff = (ymax - ymin); double xcenter = ((1.0 * draw_disp.mouse_x()) / imageWidth) * xdiff + xmin; double ycenter = ((1.0 * draw_disp.mouse_y()) / imageHeight) * ydiff + ymin; if(draw_disp.button()&1) { redraw = true; xmin = xcenter - (xdiff / 4); xmax = xcenter + (xdiff / 4); ymin = ycenter - (ydiff / 4); ymax = ycenter + (ydiff / 4); } else if(draw_disp.button()&2) { redraw = true; xmin = xcenter - xdiff; xmax = xcenter + xdiff; ymin = ycenter - ydiff; ymax = ycenter + ydiff; } } sl_done(); return 0; }