implement alpha locking per layer

This commit is contained in:
2017-05-02 03:43:16 +01:00
parent 182c0b1baf
commit 9f23021fb8
7 changed files with 77 additions and 11 deletions

View File

@@ -68,6 +68,7 @@ void ui::Canvas::stroke_draw()
tex.bind();
m_sampler.bind(0);
m_sampler_bg.bind(1);
m_sampler_mask.bind(2);
for (int i = 0; i < 6; i++)
{
@@ -92,6 +93,15 @@ void ui::Canvas::stroke_draw()
ShaderManager::use(ui::kShader::StrokeErase);
//ShaderManager::u_vec4(kShaderUniform::Col, m_brush.m_tip_color);
}
else if(m_layers[m_current_layer_idx].m_alpha_locked)
{
ShaderManager::use(kShader::StrokeLock);
ShaderManager::u_vec4(kShaderUniform::Col, m_brush.m_tip_color);
ShaderManager::u_int(kShaderUniform::TexMask, 2); // alpha mask
glActiveTexture(GL_TEXTURE2);
m_layers[m_current_layer_idx].m_rtt[i].bindTexture();
glActiveTexture(GL_TEXTURE1);
}
else
{
ShaderManager::use(ui::kShader::Stroke);
@@ -195,16 +205,25 @@ void ui::Canvas::stroke_draw()
m_plane_brush.draw_fill();
}
}
if (m_alpha_lock)
{
glActiveTexture(GL_TEXTURE2);
m_layers[m_current_layer_idx].m_rtt[i].unbindTexture();
}
glActiveTexture(GL_TEXTURE1);
m_tex[i].unbind();
m_tmp[i].unbindFramebuffer();
}
glDisable(GL_BLEND);
glActiveTexture(GL_TEXTURE0);
m_sampler.unbind();
m_sampler_bg.unbind();
m_sampler_mask.unbind();
tex.unbind();
glViewport(vp[0], vp[1], vp[2], vp[3]);
@@ -361,6 +380,7 @@ bool ui::Canvas::create(int width, int height)
}
m_sampler.create();
m_sampler_bg.create();
m_sampler_mask.create();
m_plane.create<1>(1, 1);
m_plane_brush.create<1>(1, 1);
m_mesh.create();