diff --git a/PanoPainter/GameViewController.m b/PanoPainter/GameViewController.m index d969d94..9c2ba66 100644 --- a/PanoPainter/GameViewController.m +++ b/PanoPainter/GameViewController.m @@ -200,9 +200,9 @@ std::set 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]; diff --git a/engine/app.cpp b/engine/app.cpp index 158d83c..f01802e 100644 --- a/engine/app.cpp +++ b/engine/app.cpp @@ -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); diff --git a/engine/canvas.cpp b/engine/canvas.cpp index 6d6095e..7441c22 100644 --- a/engine/canvas.cpp +++ b/engine/canvas.cpp @@ -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); @@ -325,6 +326,8 @@ void ui::Canvas::stroke_draw() GLfloat cc[4]; 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(); @@ -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); diff --git a/engine/node_canvas.cpp b/engine/node_canvas.cpp index 39ad660..9108e5e 100644 --- a/engine/node_canvas.cpp +++ b/engine/node_canvas.cpp @@ -280,8 +280,13 @@ void NodeCanvas::handle_resize(glm::vec2 old_size, glm::vec2 new_size) { if (new_size.x > m_canvas->m_width) { - m_canvas->m_mixer.create((int)new_size.x * m_canvas->m_mixer_scale, +#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("tex-debug")) img->tex.assign(m_canvas->m_mixer.getTextureID()); // m_canvas->resize((int)new_size.x, (int)new_size.y); diff --git a/engine/rtt.cpp b/engine/rtt.cpp index c53e807..0acac00 100644 --- a/engine/rtt.cpp +++ b/engine/rtt.cpp @@ -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); diff --git a/engine/texture.cpp b/engine/texture.cpp index 031fbe2..312282c 100644 --- a/engine/texture.cpp +++ b/engine/texture.cpp @@ -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; }