started implementing dynamic widget allocation by xml tag

This commit is contained in:
2017-01-29 17:42:23 +00:00
parent 7436706b37
commit 16c1b6481e
10 changed files with 94 additions and 46 deletions

View File

@@ -109,8 +109,6 @@ void App::init()
void App::update(float dt)
{
glm::mat4 proj = glm::ortho(0.f, width, height, 0.f, -1.f, 1.f);
glClearColor(.1f, .1f, .1f, 1.f);
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glClear(GL_COLOR_BUFFER_BIT);
@@ -129,23 +127,21 @@ void App::update(float dt)
glEnable(GL_SCISSOR_TEST);
for (auto& n : layout)
{
glm::mat4 pivot = glm::translate(glm::vec3(.5f, .5f, 0.f));
glm::mat4 scale = glm::scale(glm::vec3(n.m_size, 1.f));
glm::mat4 pos = glm::translate(glm::vec3(n.m_pos, 0));
auto mvp = proj * pos * scale * pivot;
auto box = n.m_clip;
glScissor(box.x, height - box.y - box.w, box.z, box.w);
shader_color.u_vec4("col", n.color);
shader_color.use();
shader_color.u_mat4("mvp", mvp);
plane.draw_fill();
shader_color.u_vec4("col", { 1, 1, 1, 1 });
shader_color.use();
shader_color.u_mat4("mvp", mvp);
plane.draw_stroke();
if (n.m_widget)
{
shader_color.u_vec4("col", n.color);
shader_color.use();
shader_color.u_mat4("mvp", n.m_widget->mvp);
plane.draw_fill();
shader_color.u_vec4("col", { 1, 1, 1, 1 });
shader_color.use();
shader_color.u_mat4("mvp", n.m_widget->mvp);
plane.draw_stroke();
}
}
glDisable(GL_SCISSOR_TEST);
tex.unbind();