-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrid2D.h
49 lines (37 loc) · 895 Bytes
/
Grid2D.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
//
// Created by luc on 18/01/23.
//
#ifndef GRID2D_H
#define GRID2D_H
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
#else
#include "external/glad.h"
#endif
#include <GLFW/glfw3.h>
#include <vector>
#include <array>
class Grid2D {
public:
struct Vertex {
GLfloat pos[3];
GLfloat col[3];
};
Grid2D() = default;
Grid2D(const Grid2D &) = delete;
Grid2D &operator=(const Grid2D &) = delete;
~Grid2D() = default;
void createGrid(uint32_t width, uint32_t height, uint32_t size);
void deleteBuffers();
void updateColor(uint32_t idx, float color);
void updateBuffer();
void render();
size_t size() { return m_vertices.size(); }
private:
std::vector<Vertex> m_vertices;
std::vector<unsigned short> m_indices;
GLuint VBO{}, VAO{}, IBO{};
};
#endif //GRID2D_H