ImageRef Scene::parallelRaytrace(CameraRef camera, RenderOption option) { Rect leftRect(0.0f, 0.0f, camera->width(), floor(camera->height() / 2.0f)); Rect rightRect(0.0f, leftRect.maxY(), camera->width(), camera->height() - leftRect.size.height); p1.scene = this; p1.camera = camera; p1.rect = leftRect; p1.option = option; p1.image = new Image(leftRect.size.width, leftRect.size.height); p2.scene = this; p2.camera = camera; p2.rect = rightRect; p2.option = option; p2.image = new Image(rightRect.size.width, rightRect.size.height); pthread_t thread1, thread2; int iret1, iret2; std::cout << this; iret1 = pthread_create(&thread1, NULL, raytraceThread, &p1); iret2 = pthread_create(&thread2, NULL, raytraceThread, &p2); pthread_join(thread1, NULL); pthread_join(thread2, NULL); ImageRef image = new Image(camera->width(), camera->height()); image->drawImageAtPoint(p1.image, p1.rect.origin); image->drawImageAtPoint(p2.image, p2.rect.origin); delete p1.image; delete p2.image; return image; }