Skip to content

Commit 70e9d29

Browse files
committed
[render] fix flickering on double click with imgui
1 parent 04c5d60 commit 70e9d29

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

vclib/render/include/vclib/bgfx/canvas.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ class CanvasBGFX
179179
*/
180180
void onPaint()
181181
{
182+
bgfx::setViewFrameBuffer(mViewId, mFbh);
183+
bgfx::touch(mViewId);
184+
185+
// ask the derived frame to draw all the drawer objects:
186+
DerivedRenderApp::CNV::draw(derived());
187+
DerivedRenderApp::CNV::postDraw(derived());
188+
182189
const bool newReadRequested =
183190
(mReadRequest != std::nullopt && !mReadRequest->isSubmitted());
184191

@@ -193,20 +200,7 @@ class CanvasBGFX
193200
}
194201
}
195202
else {
196-
bgfx::setViewFrameBuffer(mViewId, mFbh);
197-
bgfx::touch(mViewId);
198-
199-
// ask the derived frame to draw all the drawer objects:
200-
DerivedRenderApp::CNV::draw(derived());
201-
202203
mCurrFrame = bgfx::frame();
203-
204-
// this is required only when using Qt in macOS
205-
#if defined(__APPLE__)
206-
bgfx::frame();
207-
#endif // __APPLE__
208-
209-
DerivedRenderApp::CNV::postDraw(derived());
210204
}
211205

212206
if (mReadRequest != std::nullopt) {
@@ -217,6 +211,11 @@ class CanvasBGFX
217211
// solicit new frame
218212
derived()->update();
219213
}
214+
215+
// this is required only when using Qt in macOS
216+
#if defined(__APPLE__)
217+
bgfx::frame();
218+
#endif // __APPLE__
220219
}
221220

222221
/**

vclib/render/include/vclib/bgfx/context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class Context
5555
bgfx::RendererType::Count;
5656

5757
// singleton
58-
static Context* sInstancePtr;
59-
static std::mutex sMutex;
58+
inline static Context* sInstancePtr = nullptr;
59+
inline static std::mutex sMutex;
6060

6161
public:
6262
// default values, used for optional parameters

vclib/render/include/vclib/render/drawers/abstract_viewer_drawer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ class AbstractViewerDrawer :
212212
// viewport
213213
auto size = DerivedRenderApp::DRW::canvasSize(derived());
214214

215-
const Point4f vp = {.0f, .0f, float(size.x()), float(size.y())};
216-
auto callback = [=, this](const ReadData& dt) {
215+
const Point4f vp = {.0f, .0f, float(size.x()), float(size.y())};
216+
217+
auto callback = [=, this](const ReadData& dt) {
217218
mReadRequested = false;
218219

219220
const auto& data = std::get<FloatData>(dt);

vclib/render/src/vclib/bgfx/context.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929

3030
namespace vcl {
3131

32-
Context* Context::sInstancePtr = nullptr;
33-
std::mutex Context::sMutex;
34-
3532
void Context::init(void* windowHandle, void* displayHandle)
3633
{
3734
std::lock_guard<std::mutex> lock(sMutex);

0 commit comments

Comments
 (0)