mixer brush partially working, still wip
This commit is contained in:
@@ -28,10 +28,12 @@ bool Shape::create_buffers(GLvoid* idx, GLvoid* vertices, int isize, int vsize)
|
||||
glBindVertexArray(arrays[i]);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs2));
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
@@ -62,9 +64,11 @@ bool Shape::create_buffers(GLvoid* vertices, int vsize)
|
||||
glBindVertexArray(arrays[i]);
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs2));
|
||||
}
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
@@ -209,7 +213,7 @@ void Plane::create_impl(float w, float h, int div, GLushort *idx, Shape::vertex_
|
||||
*idx++ = div; // D
|
||||
*idx++ = 0; // A
|
||||
}
|
||||
void ui::Plane::update_vertices(const glm::vec4* data)
|
||||
void ui::Plane::update_vertices(const glm::vec4* data, const glm::vec2* uvs, const glm::vec2* uvs2)
|
||||
{
|
||||
static vertex_t vertices[4];
|
||||
|
||||
@@ -219,14 +223,18 @@ void ui::Plane::update_vertices(const glm::vec4* data)
|
||||
for (int i = 0; i < 4; i++)
|
||||
d[i] = glm::distance(xy(data[i]), mid);
|
||||
|
||||
vertices[0] = { data[0],{ 0, 0 } }; // A
|
||||
vertices[1] = { data[1],{ 0, 1 } }; // B
|
||||
vertices[2] = { data[2],{ 1, 1 } }; // C
|
||||
vertices[3] = { data[3],{ 1, 0 } }; // D
|
||||
vertices[0] = { data[0], { 0, 0 }, { 0, 0 } }; // A
|
||||
vertices[1] = { data[1], { 0, 1 }, { 0, 1 } }; // B
|
||||
vertices[2] = { data[2], { 1, 1 }, { 1, 1 } }; // C
|
||||
vertices[3] = { data[3], { 1, 0 }, { 1, 0 } }; // D
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float q = (d[i] + d[(i + 2) % 4]) / d[(i + 2) % 4];
|
||||
if (uvs)
|
||||
vertices[i].uvs = uvs[i];
|
||||
if (uvs2)
|
||||
vertices[i].uvs2 = uvs2[i];
|
||||
vertices[i].uvs *= q;
|
||||
vertices[i].pos.z = q;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user