fix window visibility for WASM builds

pull/3471/head
kallaballa 2 years ago
parent f9daae386b
commit 2d55d08724
  1. 4
      modules/v4d/src/detail/framebuffercontext.cpp
  2. 15
      modules/v4d/src/v4d.cpp

@ -78,7 +78,7 @@ void FrameBufferContext::init() {
glfwWindowHint(GLFW_STENCIL_BITS, 8); glfwWindowHint(GLFW_STENCIL_BITS, 8);
glfwWindowHint(GLFW_DEPTH_BITS, 24); glfwWindowHint(GLFW_DEPTH_BITS, 24);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, offscreen_ ? GLFW_FALSE : GLFW_TRUE);
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE); glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
glfwWindow_ = glfwCreateWindow(frameBufferSize_.width, frameBufferSize_.height, title_.c_str(), nullptr, glfwWindow_ = glfwCreateWindow(frameBufferSize_.width, frameBufferSize_.height, title_.c_str(), nullptr,
@ -89,8 +89,6 @@ void FrameBufferContext::init() {
} }
this->makeCurrent(); this->makeCurrent();
glfwSwapInterval(0); glfwSwapInterval(0);
if(!offscreen_)
this->setVisible(true);
#ifndef OPENCV_V4D_USE_ES3 #ifndef OPENCV_V4D_USE_ES3
if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress))
throw std::runtime_error("Could not initialize GLAD!"); throw std::runtime_error("Could not initialize GLAD!");

@ -48,7 +48,7 @@ cv::Scalar colorConvert(const cv::Scalar& src, cv::ColorConversionCodes code) {
cv::Ptr<V4D> V4D::make(const cv::Size& size, const cv::Size& fbsize, const string& title, bool offscreen, bool debug, int major, cv::Ptr<V4D> V4D::make(const cv::Size& size, const cv::Size& fbsize, const string& title, bool offscreen, bool debug, int major,
int minor, bool compat, int samples) { int minor, bool compat, int samples) {
cv::Ptr<V4D> v4d = new V4D(size, fbsize, title, offscreen, debug, major, minor, compat, samples); cv::Ptr<V4D> v4d = new V4D(size, fbsize, title, offscreen, debug, major, minor, compat, samples);
v4d->setVisible(true); v4d->setVisible(!offscreen);
return v4d; return v4d;
} }
@ -524,7 +524,11 @@ void V4D::swapContextBuffers() {
bool V4D::display() { bool V4D::display() {
bool result = true; bool result = true;
#ifndef __EMSCRIPTEN__
if (isVisible()) { if (isVisible()) {
#else
if (true) {
#endif
nguiCtx().render(); nguiCtx().render();
run_sync_on_main<6>([&, this](){ run_sync_on_main<6>([&, this](){
@ -538,16 +542,7 @@ bool V4D::display() {
glfwPollEvents(); glfwPollEvents();
result = !glfwWindowShouldClose(getGLFWWindow()); result = !glfwWindowShouldClose(getGLFWWindow());
}); });
//FIXME
#ifdef __EMSCRIPTEN__
run_sync_on_main<7>([this](){
cv::UMat tmp;
cv::v4d::detail::FrameBufferContext::GLScope glScope(fbCtx());
cv::v4d::detail::FrameBufferContext::FrameBufferScope fbScope(fbCtx(), tmp);
});
#endif
} }
if(frameCnt_ == (std::numeric_limits<uint64_t>().max() - 1)) if(frameCnt_ == (std::numeric_limits<uint64_t>().max() - 1))
frameCnt_ = 0; frameCnt_ = 0;
else else

Loading…
Cancel
Save