X-Git-Url: http://git.itanic.dy.fi/?p=mandelbrot;a=blobdiff_plain;f=mandelbrot.c;fp=mandelbrot.c;h=624fcf2ebda615e2275021d1d50aa59b91624a30;hp=be706ebc1d15a01002c41f1943185afafabdd172;hb=ba47e789a437c348b1d0a1a3cfa2c91e517762c7;hpb=67d26aaed387f95b62a74ce80d2b0c43e7212c3d diff --git a/mandelbrot.c b/mandelbrot.c index be706eb..624fcf2 100644 --- a/mandelbrot.c +++ b/mandelbrot.c @@ -45,8 +45,12 @@ int draw_mandelbrot(struct SDL_Surface *screen, double x1, double x2, xstep = xlen / (double)screen->w; ystep = ylen / (double)screen->h; - for (ys = 0, y0 = y1; ys < screen->h; y0 += ystep, ys++) { - for (xs = 0, x0 = x1; xs < screen->w; x0 += xstep, xs++) { + y0 = y1; +#pragma omp parallel for private(xs, ys, x0, y0) + for (ys = 0; ys < screen->h; ys++) { + y0 = y1 + ystep * ys; + x0 = x1; + for (xs = 0; xs < screen->w; xs++) { iteration = get_mandelbrot_iterations(x0, y0); if (iteration == MAX_ITERATION) @@ -55,11 +59,11 @@ int draw_mandelbrot(struct SDL_Surface *screen, double x1, double x2, putpixel(screen, xs, ys, iteration * 8, iteration, iteration / 4); + x0 += xstep; } - - SDL_Flip(screen); } + SDL_Flip(screen); return 0; }