opacity control

This commit is contained in:
2017-04-07 12:57:21 +01:00
parent d340324c3d
commit 2b4915154e
5 changed files with 17 additions and 5 deletions

View File

@@ -24,8 +24,8 @@ void ui::Canvas::clear()
}
void ui::Canvas::stroke_end()
{
m_current_stroke = nullptr;
stroke_commit();
m_current_stroke = nullptr;
m_show_tmp = false;
}
void ui::Canvas::stroke_draw()
@@ -33,6 +33,8 @@ void ui::Canvas::stroke_draw()
if (!(m_current_stroke && m_current_stroke->has_sample()))
return;
m_dirty = true;
m_tmp.bindFramebuffer();
GLint vp[4];
@@ -134,6 +136,10 @@ void ui::Canvas::stroke_draw()
}
void ui::Canvas::stroke_commit()
{
if (!m_dirty)
return;
m_dirty = false;
m_fb.bindFramebuffer();
// copy to tmp2 for layer blending
@@ -158,7 +164,7 @@ void ui::Canvas::stroke_commit()
ShaderManager::use(ui::kShader::StrokeLayer);
ShaderManager::u_int(kShaderUniform::Tex, 0);
ShaderManager::u_int(kShaderUniform::TexBG, 1);
ShaderManager::u_float(kShaderUniform::Alpha, .5); // TODO: if using opacity in commit, update blending to match the preview when rendering m_tmp in NodeCanvas
ShaderManager::u_float(kShaderUniform::Alpha, m_current_stroke->m_brush.m_tip_opacity); // TODO: if using opacity in commit, update blending to match the preview when rendering m_tmp in NodeCanvas
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
m_plane.draw_fill();
m_sampler.unbind();