add support for high res brush textures, implement mipmaps on brush
This commit is contained in:
@@ -196,7 +196,7 @@ void ui::Canvas::stroke_draw()
|
||||
auto samples = m_current_stroke->compute_samples();
|
||||
auto& tex = TextureManager::get(m_brush.m_tex_id);
|
||||
tex.bind();
|
||||
m_sampler.bind(0);
|
||||
m_sampler_brush.bind(0);
|
||||
m_sampler_bg.bind(1);
|
||||
m_sampler_mask.bind(2);
|
||||
|
||||
@@ -233,7 +233,7 @@ void ui::Canvas::stroke_draw()
|
||||
ShaderManager::u_vec2(kShaderUniform::Resolution, { m_width, m_height });
|
||||
for (const auto& s : samples)
|
||||
{
|
||||
glm::vec2 dx(s.size, 0), dy(0, s.size);
|
||||
glm::vec2 dx(s.size * 0.5f, 0), dy(0, s.size * 0.5f);
|
||||
glm::vec2 off[4] = {
|
||||
- dx - dy, // A - bottom-left
|
||||
- dx + dy, // B - top-left
|
||||
@@ -317,7 +317,7 @@ void ui::Canvas::stroke_draw()
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
m_sampler.unbind();
|
||||
m_sampler_brush.unbind();
|
||||
m_sampler_bg.unbind();
|
||||
m_sampler_mask.unbind();
|
||||
tex.unbind();
|
||||
@@ -695,6 +695,8 @@ bool ui::Canvas::create(int width, int height)
|
||||
m_tex2[i].create(width, height); // TODO: destroy before recreating
|
||||
}
|
||||
m_sampler.create(GL_NEAREST);
|
||||
m_sampler_brush.create();
|
||||
m_sampler_brush.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
m_sampler_bg.create(GL_NEAREST);
|
||||
m_sampler_mask.create(GL_NEAREST);
|
||||
m_plane.create<1>(1, 1);
|
||||
|
||||
Reference in New Issue
Block a user