add support for high res brush textures, implement mipmaps on brush

This commit is contained in:
2017-09-30 16:35:12 +01:00
parent 763e446cc5
commit 964795b44d
17 changed files with 61 additions and 20 deletions

View File

@@ -30,6 +30,7 @@ void NodeStrokePreview::init_controls()
{
m_mesh.create();
m_sampler.create();
m_sampler_brush.create(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
TextureManager::load("data/Icons/Round-Hard.png");
m_brush.m_tex_id = const_hash("data/Icons/Round-Hard.png");
}
@@ -66,7 +67,7 @@ void NodeStrokePreview::draw_stroke()
glm::mat4 proj = glm::ortho<float>(0, (float)m_rtt.getWidth(), 0, (float)m_rtt.getHeight(), -1, 1);
auto b = m_brush;
b.m_tip_size *= .7f; // reduce the size in the preview
//b.m_tip_size *= .7f; // reduce the size in the preview
m_stroke.reset();
m_stroke.start(b);
if (!m_stroke.m_keypoints.empty())
@@ -74,7 +75,7 @@ void NodeStrokePreview::draw_stroke()
auto samples = m_stroke.compute_samples();
auto& tex = TextureManager::get(m_brush.m_tex_id);
tex.bind();
m_sampler.bind(0);
m_sampler_brush.bind(0);
if (true)
{
@@ -100,7 +101,7 @@ void NodeStrokePreview::draw_stroke()
// }
//}
m_sampler.unbind();
m_sampler_brush.unbind();
tex.unbind();
glDisable(GL_BLEND);
@@ -126,6 +127,7 @@ void NodeStrokePreview::draw()
void NodeStrokePreview::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
{
float pad = 30.f;
new_size *= root()->m_zoom;
float w = new_size.x;
float h = new_size.y;
std::vector<glm::vec2> kp = { { pad, pad },{ pad, h - pad },{ w - pad, pad },{ w - pad, h - pad } };