summaryrefslogtreecommitdiff
path: root/cpp-timeplot/src/waterfall.h
blob: 4c5d813d57b7a6691093bbac1b9f8b6058f8b563 (plain)
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
#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;
};