forked from KhronosGroup/ANARI-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.h
95 lines (70 loc) · 2.1 KB
/
MainWindow.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright 2021 The Khronos Group
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "OrbitManipulator.h"
#include "glm_box3.h"
// glad header
#include "glad/glad.h"
// glfw header
#include "GLFW/glfw3.h"
// ANARI headers
#include "anari/anari_cpp.hpp"
#include "anari/anari_cpp/ext/glm.h"
// ANARI sample scenes
#include "anari_test_scenes.h"
// C++ std
#include <memory>
#include <string>
#include <vector>
class MainWindow
{
public:
MainWindow(const glm::uvec2 &windowSize);
~MainWindow();
void setDevice(ANARIDevice device);
void setScene(
std::string sceneName, std::string paramName = "", anari::Any param = {});
void mainLoop();
private:
void addObjectToCommit(ANARIObject obj);
void updateCamera();
void resetCamera();
void reshape(const glm::uvec2 &newWindowSize);
void motion(const glm::vec2 &position);
void display();
void buildUI();
void commitOutstandingHandles();
void cleanup();
friend void frame_continuation_callback(void *, ANARIDevice, ANARIFrame);
friend void frame_show(ANARIDevice, ANARIFrame, MainWindow*);
static MainWindow *activeWindow;
glm::vec2 previousMouse{-1.f, -1.f};
bool mouseRotating{false};
glm_box3 bounds;
float zoomSpeed{1.f};
glm::vec4 bgColor{0.2f, 0.2f, 0.2f, 1.f};
bool showUI{true};
manipulators::Orbit arcball;
// ANARI objects not managed by this class
ANARIDevice device{nullptr};
bool useContinuation = false;
// ANARI objects managed by this class
ANARIRenderer renderer{nullptr};
ANARICamera camera{nullptr};
ANARIFrame frame{nullptr};
anari::scenes::SceneHandle scene;
std::vector<anari::scenes::ParameterInfo> sceneParams;
// Collection of ANARI handles to commit before the next frame
std::vector<ANARIObject> objectsToCommit;
bool commitScene{true};
bool resetCameraPosition{true};
std::vector<unsigned char> pixelBuffer;
glm::ivec2 prevFrameSize{0};
glm::ivec2 currentFrameSize{0};
glm::ivec2 nextFrameSize{0};
// OpenGL framebuffer texture
GLuint framebufferTexture = 0;
GLuint framebufferObject = 0;
// FPS measurement of last frame
float latestFPS{0.f};
};