fix mixer on iOS, work with RGBA16F buffers on iOS instead of fallback to RGBA8
This commit is contained in:
@@ -200,9 +200,9 @@ std::set<UITouch*> ignored_touch;
|
||||
if (source == kEventSource::Stylus)
|
||||
pen_down = true;
|
||||
|
||||
if (touch.majorRadius > 25.f)
|
||||
ignored_touch.insert(touch);
|
||||
NSLog(@"touch down size %f", touch.majorRadius);
|
||||
// if (touch.majorRadius > 25.f)
|
||||
// ignored_touch.insert(touch);
|
||||
// NSLog(@"touch down size %f", touch.majorRadius);
|
||||
[self async_lock];
|
||||
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, touch.force, source);
|
||||
[self async_unlock];
|
||||
|
||||
@@ -42,7 +42,7 @@ bool App::request_close()
|
||||
m->m_title->set_text("Unsaved document");
|
||||
m->m_message->set_text("Do you want to close without saving?");
|
||||
m->btn_ok->m_text->set_text("Yes");
|
||||
m->btn_ok->on_click = [](Node*) {
|
||||
m->btn_ok->on_click = [this](Node*) {
|
||||
#ifdef _WIN32
|
||||
destroy_window();
|
||||
PostQuitMessage(0);
|
||||
|
||||
@@ -223,6 +223,7 @@ void ui::Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz
|
||||
{
|
||||
m_mixer.bindFramebuffer();
|
||||
|
||||
float zoom = m_node->root()->m_zoom;
|
||||
glViewport(0, 0, m_mixer.getWidth(), m_mixer.getHeight());
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
@@ -326,6 +327,8 @@ void ui::Canvas::stroke_draw()
|
||||
glGetIntegerv(GL_VIEWPORT, vp);
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, cc);
|
||||
|
||||
float zoom = m_node->root()->m_zoom;
|
||||
|
||||
auto m_brush = m_current_stroke->m_brush;
|
||||
auto samples = m_current_stroke->compute_samples();
|
||||
auto& tex = TextureManager::get(m_brush.m_tex_id);
|
||||
@@ -354,9 +357,8 @@ void ui::Canvas::stroke_draw()
|
||||
glm::vec2 bb_max(0, 0);
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
auto p = (m_mixer_sample.pos + off[j] + glm::vec2(0, 1));
|
||||
auto p = (m_mixer_sample.pos + off[j] * glm::orientate2(-s.angle) + glm::vec2(0, 1)) / zoom;
|
||||
UV2[j] = p / sz;
|
||||
//UV2[j].y = 1.f - UV2[j].y;
|
||||
bb_min = glm::max({ 0, 0 }, glm::min(bb_min, p));
|
||||
bb_max = glm::min(sz, glm::max(bb_max, p));
|
||||
}
|
||||
@@ -897,8 +899,8 @@ void ui::Canvas::resize(int width, int height)
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
#if __IOS__
|
||||
m_tmp[i].create(width, height, -1, GL_RGBA8);
|
||||
m_tex[i].create(width, height, GL_RGBA8);
|
||||
m_tmp[i].create(width, height, -1, GL_RGBA16F);
|
||||
m_tex[i].create(width, height, GL_RGBA16F);
|
||||
#else
|
||||
m_tmp[i].create(width, height, -1, GL_RGBA32F);
|
||||
m_tex[i].create(width, height, GL_RGBA32F);
|
||||
@@ -917,8 +919,8 @@ bool ui::Canvas::create(int width, int height)
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
#if __IOS__
|
||||
m_tmp[i].create(width, height, -1, GL_RGBA8);
|
||||
m_tex[i].create(width, height, GL_RGBA8);
|
||||
m_tmp[i].create(width, height, -1, GL_RGBA16F);
|
||||
m_tex[i].create(width, height, GL_RGBA16F);
|
||||
#else
|
||||
m_tmp[i].create(width, height, -1, GL_RGBA32F);
|
||||
m_tex[i].create(width, height, GL_RGBA32F);
|
||||
|
||||
@@ -280,8 +280,13 @@ void NodeCanvas::handle_resize(glm::vec2 old_size, glm::vec2 new_size)
|
||||
{
|
||||
if (new_size.x > m_canvas->m_width)
|
||||
{
|
||||
#if __IOS__
|
||||
m_canvas->m_mixer.create((int)new_size.x * m_canvas->m_mixer_scale,
|
||||
(int)new_size.y * m_canvas->m_mixer_scale, -1, GL_RGBA16F);
|
||||
#else
|
||||
m_canvas->m_mixer.create((int)new_size.x * m_canvas->m_mixer_scale,
|
||||
(int)new_size.y * m_canvas->m_mixer_scale, -1, GL_RGBA32F);
|
||||
#endif
|
||||
if (auto img = root()->find<NodeImageTexture>("tex-debug"))
|
||||
img->tex.assign(m_canvas->m_mixer.getTextureID());
|
||||
// m_canvas->resize((int)new_size.x, (int)new_size.y);
|
||||
|
||||
@@ -58,10 +58,13 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format)
|
||||
texID = tex;
|
||||
}
|
||||
|
||||
auto ifmt = GL_UNSIGNED_BYTE;
|
||||
if (internal_format == GL_RGBA32F) ifmt = GL_FLOAT;
|
||||
if (internal_format == GL_RGBA16F) ifmt = GL_HALF_FLOAT;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texID);
|
||||
if (tex == -1)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, GL_RGBA,
|
||||
internal_format == GL_RGBA32F ? GL_FLOAT : GL_UNSIGNED_BYTE, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, GL_RGBA, ifmt, 0);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
||||
@@ -46,8 +46,10 @@ bool Texture2D::create(int width, int height, GLint internal_format, GLint forma
|
||||
glGenTextures(1, &m_tex);
|
||||
//LOG("TEX create %d", m_tex);
|
||||
bind();
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format,
|
||||
internal_format == GL_RGBA32F ? GL_FLOAT : GL_UNSIGNED_BYTE, data);
|
||||
auto ifmt = GL_UNSIGNED_BYTE;
|
||||
if (internal_format == GL_RGBA32F) ifmt = GL_FLOAT;
|
||||
if (internal_format == GL_RGBA16F) ifmt = GL_HALF_FLOAT;
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, ifmt, data);
|
||||
unbind();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user