Found the problem with openmp.
X here need to be declared as private, else each thread are sharing the same variable which... well.... don't work well .. :/
This commit is contained in:
@@ -62,9 +62,11 @@ Canvas Camera::render(World world, uint32_t depth)
|
||||
uint32_t x, y;
|
||||
Canvas image = Canvas(this->horizontalSize, this->verticalSize);
|
||||
|
||||
#pragma omp parallel private(x, y) shared(image)
|
||||
{
|
||||
#pragma omp for
|
||||
for (y = 0 ; y < this->verticalSize ; y++)
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (x = 0 ; x < this->horizontalSize ; x++)
|
||||
{
|
||||
Ray r = this->rayForPixel(x, y);
|
||||
@@ -72,6 +74,7 @@ Canvas Camera::render(World world, uint32_t depth)
|
||||
image.putPixel(x, y, colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
Reference in New Issue
Block a user