forked from msu-graphics-group/scenes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (28 loc) · 926 Bytes
/
main.cpp
File metadata and controls
37 lines (28 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <vector>
#include "render/raytracing.h"
#include "render/image_save.h"
std::vector<uint32_t> rayTraceCPU(std::shared_ptr<RayTracer> pRayTracer, int width, int height)
{
std::vector<uint32_t> raytracedImageData(width * height, 0u);
#pragma omp parallel for default(none) shared(height, width, raytracedImageData, pRayTracer)
for (int j = 0; j < height; ++j)
{
for (int i = 0; i < width; ++i)
{
pRayTracer->CastSingleRay(i, j, raytracedImageData.data());
}
}
return raytracedImageData;
}
int main()
{
constexpr uint32_t WIDTH = 1024;
constexpr uint32_t HEIGHT = 1024;
auto pRayTracerCPU = std::make_shared<RayTracer>(WIDTH, HEIGHT);
auto loaded = pRayTracerCPU->LoadScene("../01_simple_scenes/instanced_objects.xml");
if(!loaded)
return -1;
auto image = rayTraceCPU(pRayTracerCPU, WIDTH, HEIGHT);
saveImageLDR("output.png", image, WIDTH, HEIGHT, 4);
return 0;
}