add grids panel

This commit is contained in:
2018-08-07 00:26:20 +02:00
parent 698bd58b33
commit 0e0021b767
14 changed files with 192 additions and 17 deletions

View File

@@ -24,13 +24,19 @@ public:
bool create_buffers(GLvoid* vertices, int vsize);
void draw_fill() const;
void draw_stroke() const;
virtual bool create_attrib() { return true; };
~Shape()
void destroy()
{
glDeleteBuffers(2, buffers);
#if USE_VBO
glDeleteVertexArrays(2, arrays);
#endif // USE_VBO
buffers[0] = buffers[1] = 0;
arrays[0] = arrays[1] = 0;
}
virtual bool create_attrib() { return true; };
~Shape()
{
destroy();
}
protected:
glm::vec2 quad_mid_point(glm::vec2 a, glm::vec2 b, glm::vec2 c, glm::vec2 d)
@@ -95,11 +101,20 @@ public:
template<int div>
bool create(float w, float h)
{
static GLushort idx[div * div * 6 + 8];
static GLushort idx[div * div * 6 + (div + 1) * 4];
static vertex_t vertices[(div+1)*(div+1)];
create_impl(w, h, div, idx, vertices);
return create_buffers(idx, vertices, sizeof(idx), sizeof(vertices));
}
bool create(float w, float h, int div)
{
int idx_size = div * div * 6 + (div + 1) * 4;
int vertices_size = (div + 1)*(div + 1);
auto idx = std::make_unique<GLushort[]>(idx_size);
auto vertices = std::make_unique<vertex_t[]>(vertices_size);
create_impl(w, h, div, idx.get(), vertices.get());
return create_buffers(idx.get(), vertices.get(), sizeof(GLushort) * idx_size, sizeof(vertex_t) * vertices_size);
}
void update_vertices(const glm::vec4* data, const glm::vec2* uvs = nullptr, const glm::vec2* uvs2 = nullptr);
/*
bool create(att::Divisions divisions, att::Width w, att::Height h)