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

@@ -8,6 +8,8 @@ bool Shape::create_buffers(GLvoid* idx, GLvoid* vertices, int isize, int vsize)
{
use_idx = true;
destroy();
glGenBuffers(2, buffers);
if (!(buffers[0] && buffers[1]))
return false;
@@ -43,6 +45,8 @@ bool Shape::create_buffers(GLvoid* vertices, int vsize)
{
use_idx = false;
destroy();
glGenBuffers(1, buffers);
if (!buffers[0])
return false;
@@ -166,7 +170,7 @@ bool RectShape::create(float w, float h)
void Plane::create_impl(float w, float h, int div, GLushort *idx, Shape::vertex_t *vertices)
{
count[0] = div * div * 6;
count[1] = 8;
count[1] = (div + 1) * 4;
ioff[0] = (GLvoid*)0;
ioff[1] = (GLvoid*)(count[0] * sizeof(GLushort));
@@ -203,15 +207,28 @@ void Plane::create_impl(float w, float h, int div, GLushort *idx, Shape::vertex_
i++;
}
}
// outline indices
*idx++ = 0; // A
*idx++ = (div+1)*(div); // B
*idx++ = (div+1)*(div); // B
*idx++ = (div+1)*(div+1)-1; // C
*idx++ = (div+1)*(div+1)-1; // C
*idx++ = div; // D
*idx++ = div; // D
*idx++ = 0; // A
// generate indices
for (int y = 0; y <= div; y++)
{
int i = y * (div + 1);
*idx++ = i;
*idx++ = i + div;
*idx++ = y;
*idx++ = y + div * (div + 1);
}
//
// // outline indices
// *idx++ = 0; // A
// *idx++ = (div+1)*(div); // B
// *idx++ = (div+1)*(div); // B
// *idx++ = (div+1)*(div+1)-1; // C
// *idx++ = (div+1)*(div+1)-1; // C
// *idx++ = div; // D
// *idx++ = div; // D
// *idx++ = 0; // A
}
void ui::Plane::update_vertices(const glm::vec4* data, const glm::vec2* uvs, const glm::vec2* uvs2)
{