refactor to have a single global current brush on Canvas::m_current_brush and make panels read from it for drawing instead of relying on their own copy
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "texture.h"
|
||||
#include "shader.h"
|
||||
#include "bezier.h"
|
||||
#include "canvas.h"
|
||||
|
||||
Node* NodeStrokePreview::clone_instantiate() const
|
||||
{
|
||||
@@ -32,8 +33,8 @@ void NodeStrokePreview::init_controls()
|
||||
m_sampler.create(GL_LINEAR, GL_REPEAT);
|
||||
m_sampler_brush.create();
|
||||
m_sampler_brush.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
TextureManager::load("data/thumbs/Round-Hard.png");
|
||||
m_brush.m_tex_id = const_hash("data/thumbs/Round-Hard.png");
|
||||
// TextureManager::load("data/thumbs/Round-Hard.png");
|
||||
// ui::Canvas::I->m_current_brush.m_tex_id = const_hash("data/thumbs/Round-Hard.png");
|
||||
}
|
||||
|
||||
void NodeStrokePreview::restore_context()
|
||||
@@ -73,7 +74,7 @@ void NodeStrokePreview::draw_stroke()
|
||||
if (!m_stroke.m_keypoints.empty())
|
||||
m_stroke.m_prev_sample.origin = m_stroke.m_keypoints[0].pos;
|
||||
auto samples = m_stroke.compute_samples();
|
||||
auto& tex = TextureManager::get(m_brush.m_tex_id);
|
||||
auto& tex = TextureManager::get(b.m_tex_id);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
m_sampler_brush.bind(0);
|
||||
@@ -91,7 +92,7 @@ void NodeStrokePreview::draw_stroke()
|
||||
m_mesh.shader.u_int(kShaderUniform::TexStencil, 1); // stencil
|
||||
m_mesh.shader.u_vec2(kShaderUniform::Resolution, { m_rtt.getWidth(), m_rtt.getHeight() });
|
||||
m_mesh.shader.u_vec2(kShaderUniform::StencilOffset, glm::vec2(0));
|
||||
m_mesh.shader.u_float(kShaderUniform::StencilAlpha, m_brush.m_tip_stencil);
|
||||
m_mesh.shader.u_float(kShaderUniform::StencilAlpha, b.m_tip_stencil);
|
||||
m_mesh.draw(samples, proj);
|
||||
}
|
||||
//else
|
||||
|
||||
Reference in New Issue
Block a user