| 60 | vec2i imgSize); |
| 61 | |
| 62 | int main(int argc, const char **argv) |
| 63 | { |
| 64 | #ifdef _WIN32 |
| 65 | int waitForKey = 0; |
| 66 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 67 | if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) { |
| 68 | // detect standalone console: cursor at (0,0)? |
| 69 | waitForKey = csbi.dwCursorPosition.X == 0 && csbi.dwCursorPosition.Y == 0; |
| 70 | } |
| 71 | #endif |
| 72 | |
| 73 | // initialize OSPRay; OSPRay parses (and removes) its commandline parameters, |
| 74 | // e.g. "--osp:debug" |
| 75 | OSPError init_error = ospInit(&argc, argv); |
| 76 | if (init_error != OSP_NO_ERROR) |
| 77 | return init_error; |
| 78 | |
| 79 | vec2i imgSizes[2] = {0}; |
| 80 | imgSizes[0].x = 1024; // width |
| 81 | imgSizes[0].y = 768; // height |
| 82 | |
| 83 | imgSizes[1].x = 800; |
| 84 | imgSizes[1].y = 600; |
| 85 | |
| 86 | OSPCamera cameras[2] = {0}; |
| 87 | OSPWorld worlds[2] = {0}; |
| 88 | OSPRenderer renderers[2] = {0}; |
| 89 | OSPFrameBuffer framebuffers[2] = {0}; |
| 90 | buildScene1( |
| 91 | &cameras[0], &worlds[0], &renderers[0], &framebuffers[0], imgSizes[0]); |
| 92 | buildScene2( |
| 93 | &cameras[1], &worlds[1], &renderers[1], &framebuffers[1], imgSizes[1]); |
| 94 | |
| 95 | printf("starting renders...\n"); |
| 96 | OSPFuture futures[2] = {0}; |
| 97 | // render one frame for each scene |
| 98 | for (int i = 0; i < 2; ++i) { |
| 99 | futures[i] = |
| 100 | ospRenderFrame(framebuffers[i], renderers[i], cameras[i], worlds[i]); |
| 101 | } |
| 102 | |
| 103 | for (int i = 0; i < 2; ++i) { |
| 104 | int isFinished = ospIsReady(futures[i], OSP_TASK_FINISHED); |
| 105 | printf("status of 'futures[%i]' is %i\n", i, isFinished); |
| 106 | } |
| 107 | |
| 108 | // We don't need to wait for them in the order they were started |
| 109 | for (int i = 1; i >= 0; --i) { |
| 110 | ospWait(futures[i], OSP_FRAME_FINISHED); |
| 111 | printf("...done, variance of render %i was %f\n", |
| 112 | i, |
| 113 | ospGetVariance(framebuffers[i])); |
| 114 | ospRelease(futures[i]); |
| 115 | } |
| 116 | |
| 117 | // access framebuffer and write its content as PPM file |
| 118 | const uint32_t *fb = |
| 119 | (uint32_t *)ospMapFrameBuffer(framebuffers[0], OSP_FB_COLOR); |
nothing calls this directly
no test coverage detected