Fix event pumping with non-owned platforms.

Tested with WebGL and macOS.
This commit is contained in:
Philip Rideout
2020-01-28 13:39:58 -08:00
parent 1452ce62f4
commit 6fbf8a8be0
2 changed files with 7 additions and 10 deletions
+3 -10
View File
@@ -109,8 +109,6 @@ FEngine* FEngine::create(Backend backend, Platform* platform, void* sharedGLCont
// Normally we launch a thread and create the context and Driver from there (see FEngine::loop).
// In the single-threaded case, we do so in the here and now.
if (!UTILS_HAS_THREADING) {
// we don't own the external context at that point, set it to null
instance->mPlatform = nullptr;
if (platform == nullptr) {
platform = DefaultPlatform::create(&instance->mBackend);
instance->mPlatform = platform;
@@ -406,13 +404,8 @@ void FEngine::flushAndWait() {
// -----------------------------------------------------------------------------------------------
int FEngine::loop() {
// we don't own the external context at that point, set it to null
Platform* platform = mPlatform;
mPlatform = nullptr;
if (platform == nullptr) {
platform = DefaultPlatform::create(&mBackend);
mPlatform = platform;
if (mPlatform == nullptr) {
mPlatform = DefaultPlatform::create(&mBackend);
mOwnPlatform = true;
slog.d << "FEngine resolved backend: ";
switch (mBackend) {
@@ -460,7 +453,7 @@ int FEngine::loop() {
JobSystem::setThreadName("FEngine::loop");
JobSystem::setThreadPriority(JobSystem::Priority::DISPLAY);
mDriver = platform->createDriver(mSharedGLContext);
mDriver = mPlatform->createDriver(mSharedGLContext);
mDriverBarrier.latch();
if (UTILS_UNLIKELY(!mDriver)) {
// if we get here, it's because the driver couldn't be initialized and the problem has
+4
View File
@@ -268,6 +268,10 @@ public:
// flush the current buffer
void flush();
/**
* Processes the platform's event queue when called from the platform's event-handling thread.
* Returns false when called from any other thread.
*/
bool pumpPlatformEvents() {
return mPlatform->pumpEvents();
}