summaryrefslogtreecommitdiff
path: root/cpp-timeplot/src/waterfall.h
blob: 454caf840f9003b2671dc4089bd063e00389e1ec (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.h>
#include <vector>
#include <string>

struct Vertex {
    float position[2];
    float color[3];
};

class Waterfall {
public:
    Waterfall(WGPUDevice device, float x, float y, float width, float height, const std::string& title);
    ~Waterfall();

    bool initialize();
    void update(float time);
    void render(WGPURenderPassEncoder pass,
                WGPURenderPipeline linePipeline,
                WGPURenderPipeline lineListPipeline,
                int windowWidth, int windowHeight);
    void toggleGrid();

private:
    std::vector<Vertex> generateGridLines();
    std::vector<Vertex> generateBorder();

    WGPUDevice device_;
    WGPUBuffer 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;
};