remove all async_start/end calls
This commit is contained in:
157
src/app.cpp
157
src/app.cpp
@@ -566,22 +566,87 @@ bool App::update_ui_observer(Node *n)
|
||||
return false;
|
||||
}
|
||||
|
||||
void App::update(float dt)
|
||||
void App::draw(float dt)
|
||||
{
|
||||
static std::mutex mutex;
|
||||
static float rec_timer = 0.f;
|
||||
static float reload_timer = 0.f;
|
||||
|
||||
// avoid multiple threads to update the scene
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
static std::mutex m;
|
||||
std::lock_guard<std::mutex> _lock(m);
|
||||
|
||||
// update offscreen stuff
|
||||
if (canvas && canvas->m_canvas)
|
||||
canvas->m_canvas->stroke_draw();
|
||||
|
||||
auto observer = std::bind(&App::update_ui_observer, this, std::placeholders::_1);
|
||||
|
||||
if (vr_active && ui_visible)
|
||||
{
|
||||
uirtt.bindFramebuffer();
|
||||
uirtt.clear();
|
||||
glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight());
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (int i = 1; i < layout[main_id]->m_children.size(); i++)
|
||||
layout[main_id]->m_children[i]->watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
uirtt.unbindFramebuffer();
|
||||
}
|
||||
|
||||
if (!vr_only)
|
||||
{
|
||||
#if __IOS__
|
||||
[ios_view->glview bindDrawable];
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
glViewport(off_x, off_y, (GLsizei)width, (GLsizei)height);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (int i = 0; i < layout[main_id]->m_children.size(); i++)
|
||||
layout[main_id]->m_children[i]->watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
if (rec_running)
|
||||
{
|
||||
static float rec_timer = 0.f;
|
||||
rec_timer += dt;
|
||||
if (rec_timer > 1.f && canvas->m_canvas->m_dirty_stroke)
|
||||
{
|
||||
canvas->m_canvas->m_dirty_stroke = false;
|
||||
|
||||
LOG("rec tick");
|
||||
rec_timer = 0.f;
|
||||
|
||||
auto data = new uint8_t[width * height * 4];
|
||||
#if __IOS__
|
||||
[ios_view->glview bindDrawable];
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
|
||||
GLint dfbo, rfbo;
|
||||
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &rfbo);
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &dfbo);
|
||||
if (dfbo != rfbo)
|
||||
LOG("DIFFERENT FB");
|
||||
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(rec_mutex);
|
||||
rec_frames.emplace_back(data);
|
||||
rec_cv.notify_all();
|
||||
}
|
||||
update_rec_frames();
|
||||
}
|
||||
}
|
||||
|
||||
redraw = false;
|
||||
}
|
||||
|
||||
void App::update(float dt)
|
||||
{
|
||||
static std::mutex mutex;
|
||||
static float reload_timer = 0.f;
|
||||
|
||||
// avoid multiple threads to update the scene
|
||||
//std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
if (!(redraw || animate))
|
||||
return;
|
||||
|
||||
@@ -620,71 +685,6 @@ void App::update(float dt)
|
||||
layout[main_id]->find<NodeButtonCustom>("btn-mask-line")->set_active(mode == kCanvasMode::MaskLine);
|
||||
layout[main_id]->find<NodeButtonCustom>("btn-bucket")->set_active(mode == kCanvasMode::FloodFill);
|
||||
}
|
||||
|
||||
auto observer = std::bind(&App::update_ui_observer, this, std::placeholders::_1);
|
||||
|
||||
if (vr_active && ui_visible)
|
||||
{
|
||||
uirtt.bindFramebuffer();
|
||||
uirtt.clear();
|
||||
glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight());
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (int i = 1; i < layout[main_id]->m_children.size(); i++)
|
||||
layout[main_id]->m_children[i]->watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
uirtt.unbindFramebuffer();
|
||||
}
|
||||
|
||||
if (!vr_only)
|
||||
{
|
||||
#if __IOS__
|
||||
[ios_view->glview bindDrawable];
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
glViewport(off_x, off_y, (GLsizei)width, (GLsizei)height);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
for (int i = 0; i < layout[main_id]->m_children.size(); i++)
|
||||
layout[main_id]->m_children[i]->watch(observer);
|
||||
//msgbox->watch(observer);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
if (rec_running)
|
||||
{
|
||||
rec_timer += dt;
|
||||
if (rec_timer > 1.f && canvas->m_canvas->m_dirty_stroke)
|
||||
{
|
||||
canvas->m_canvas->m_dirty_stroke = false;
|
||||
|
||||
LOG("rec tick");
|
||||
rec_timer = 0.f;
|
||||
|
||||
auto data = new uint8_t[width * height * 4];
|
||||
#if __IOS__
|
||||
[ios_view->glview bindDrawable];
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
|
||||
GLint dfbo, rfbo;
|
||||
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &rfbo);
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &dfbo);
|
||||
if (dfbo != rfbo)
|
||||
LOG("DIFFERENT FB");
|
||||
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(rec_mutex);
|
||||
rec_frames.emplace_back(data);
|
||||
rec_cv.notify_all();
|
||||
}
|
||||
update_rec_frames();
|
||||
}
|
||||
}
|
||||
|
||||
redraw = false;
|
||||
}
|
||||
|
||||
void App::terminate()
|
||||
@@ -803,9 +803,7 @@ void App::rec_stop()
|
||||
rec_cv.notify_all();
|
||||
if (rec_thread.joinable())
|
||||
rec_thread.join();
|
||||
async_start();
|
||||
update_rec_frames();
|
||||
async_end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,7 +819,6 @@ void App::rec_export(std::string path)
|
||||
auto pb = layout[main_id]->add_child<NodeProgressBar>();
|
||||
pb->m_progress->SetWidthP(0);
|
||||
pb->m_title->set_text("Exporting MP4 movie");
|
||||
async_update();
|
||||
|
||||
#if defined(__IOS__) || defined(__OSX__)
|
||||
NSString* mov_path = [NSString stringWithFormat:@"%s/out.mp4", rec_path.c_str()];
|
||||
@@ -978,8 +975,6 @@ void App::rec_export(std::string path)
|
||||
#endif
|
||||
|
||||
pb->destroy();
|
||||
async_update();
|
||||
|
||||
}
|
||||
|
||||
void App::rec_loop()
|
||||
|
||||
Reference in New Issue
Block a user