diff options
Diffstat (limited to 'cpp-timeplot/src/waterfall.h')
| -rw-r--r-- | cpp-timeplot/src/waterfall.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cpp-timeplot/src/waterfall.h b/cpp-timeplot/src/waterfall.h new file mode 100644 index 0000000..4c5d813 --- /dev/null +++ b/cpp-timeplot/src/waterfall.h @@ -0,0 +1,39 @@ +#pragma once + +#include <webgpu/webgpu.hpp> +#include <vector> +#include <string> + +struct Vertex { + float position[2]; + float color[3]; +}; + +class Waterfall { +public: + Waterfall(wgpu::Device device, float x, float y, float width, float height, const std::string& title); + ~Waterfall(); + + bool initialize(); + void update(float time); + void render(wgpu::RenderPassEncoder& pass, + wgpu::RenderPipeline linePipeline, + wgpu::RenderPipeline lineListPipeline, + int windowWidth, int windowHeight); + void toggleGrid(); + +private: + std::vector<Vertex> generateGridLines(); + std::vector<Vertex> generateBorder(); + + wgpu::Device device_; + wgpu::Buffer vertexBuffer_; + + float x_, y_, width_, height_; + std::string title_; + bool showGrid_; + + std::vector<std::vector<Vertex>> lines_; + static constexpr int MAX_LINES = 50; + static constexpr int POINTS_PER_LINE = 100; +}; |
