-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.h
68 lines (53 loc) · 1.68 KB
/
application.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
#include <webgpu/webgpu.h>
#include <array>
#include <vector>
struct GLFWwindow;
class Application
{
public:
Application();
enum class MouseState { Idle, Dragging };
bool isRunning() const;
void onFrame();
void onFinish();
void onResize();
void onMouseMove(double x, double y);
void onScroll(double x, double y);
void onMouseButton(int button, int action, int mods);
private:
void buildSwapchain();
bool initGui();
void terminateGui();
void updateGui(WGPURenderPassEncoder pass);
struct Uniform {
std::array<float, 2> offset = { 0.0F, 0.0F };
float scale = 1.0F;
int32_t windowWidth = 800;
int32_t windowHeight = 600;
float max_iter = 512.0;
};
static_assert(sizeof(Uniform) % sizeof(std::array<float, 2>) == 0);
Uniform m_uniforms;
WGPUInstance m_instance = nullptr;
WGPUAdapter m_adapter = nullptr;
WGPUDevice m_device = nullptr;
WGPUSurface m_surface = nullptr;
WGPUQueue m_queue = nullptr;
WGPURenderPipeline m_renderPipeline;
WGPUSwapChain m_swapChain = nullptr;
WGPUTextureFormat m_swapChainFormat = WGPUTextureFormat_Undefined;
WGPUBuffer m_indexBuffer = nullptr;
WGPUBuffer m_vertexBuffer = nullptr;
WGPUBuffer m_uniformBuffer = nullptr;
WGPUBindGroup m_bindGroup = nullptr;
WGPUShaderModule m_shaderModule = nullptr;
GLFWwindow *m_window = nullptr;
int m_vertexCount = 0;
int m_indexCount = 0;
std::vector<float> m_frameTimesList;
double m_previousFrameTime = 0.0;
MouseState m_mouseState = MouseState::Idle;
double m_previousMouseX = 0.0;
double m_previousMouseY = 0.0;
float m_monitorScale = 1.0F;
};