implement brush presets save and restore from file, fix stencil nullptr, limit preview stroke max size

This commit is contained in:
2019-01-23 16:53:58 +01:00
parent e26fcf1163
commit 879be9d4fe
17 changed files with 282 additions and 65 deletions

View File

@@ -304,7 +304,6 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz)
m_sampler.bind(0);
m_sampler.bind(1);
m_sampler.bind(2);
auto& paper = *m_current_stroke->m_brush->m_stencil_texture;
ShaderManager::use(kShader::CompDraw);
ShaderManager::u_int(kShaderUniform::Tex, 0);
//ShaderManager::u_int(kShaderUniform::TexA, 0);
@@ -326,9 +325,13 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz)
glActiveTexture(GL_TEXTURE2);
m_smask.m_rtt[plane_index].bindTexture();
glActiveTexture(GL_TEXTURE3);
paper.bind();
if (m_current_stroke->m_brush->m_stencil_texture)
m_current_stroke->m_brush->m_stencil_texture->bind();
else
glBindTexture(GL_TEXTURE_2D, 0);
m_node->m_face_plane.draw_fill();
paper.unbind();
if (m_current_stroke->m_brush->m_stencil_texture)
m_current_stroke->m_brush->m_stencil_texture->unbind();
glActiveTexture(GL_TEXTURE2);
m_smask.m_rtt[plane_index].unbindTexture();
glActiveTexture(GL_TEXTURE1);
@@ -360,7 +363,6 @@ void Canvas::stroke_draw()
const auto& m_brush = m_current_stroke->m_brush;
auto samples = m_current_stroke->compute_samples();
auto& tex = *m_brush->m_tip_texture;
auto& stencil = *m_brush->m_stencil_texture;
auto ortho_proj = glm::ortho(0.f, (float)m_width, 0.f, (float)m_height, -1.f, 1.f);
std::vector<vertex_t> B{
@@ -381,7 +383,11 @@ void Canvas::stroke_draw()
//m_sampler_linear.bind(5);
glActiveTexture(GL_TEXTURE2);
stencil.bind();
if (m_brush->m_stencil_texture)
m_brush->m_stencil_texture->bind();
else
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE3);
m_mixer.bindTexture();
@@ -458,7 +464,10 @@ void Canvas::stroke_draw()
//m_sampler_linear.bind(5);
glActiveTexture(GL_TEXTURE2);
stencil.bind();
if (m_brush->m_stencil_texture)
m_brush->m_stencil_texture->bind();
else
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE3);
m_mixer.bindTexture();
glDisable(GL_BLEND);
@@ -633,7 +642,8 @@ void Canvas::stroke_draw()
glDisable(GL_BLEND);
glActiveTexture(GL_TEXTURE2);
stencil.unbind();
if (m_brush->m_stencil_texture)
m_brush->m_stencil_texture->unbind();
glActiveTexture(GL_TEXTURE3);
m_mixer.unbindTexture();
@@ -846,8 +856,6 @@ void Canvas::stroke_commit()
}
else
{
auto& paper = *m_current_stroke->m_brush->m_stencil_texture;
ShaderManager::use(kShader::CompDraw);
ShaderManager::u_int(kShaderUniform::Tex, 0);
ShaderManager::u_int(kShaderUniform::TexStroke, 1);
@@ -867,9 +875,13 @@ void Canvas::stroke_commit()
glActiveTexture(GL_TEXTURE2);
m_smask.m_rtt[i].bindTexture();
glActiveTexture(GL_TEXTURE3);
paper.bind();
if (m_current_stroke->m_brush->m_stencil_texture)
m_current_stroke->m_brush->m_stencil_texture->bind();
else
glBindTexture(GL_TEXTURE_2D, 0);
m_plane.draw_fill();
paper.unbind();
if (m_current_stroke->m_brush->m_stencil_texture)
m_current_stroke->m_brush->m_stencil_texture->unbind();
glActiveTexture(GL_TEXTURE2);
m_smask.m_rtt[i].unbindTexture();
glActiveTexture(GL_TEXTURE1);