Fix event pumping with non-owned platforms.
Tested with WebGL and macOS.
This commit is contained in:
+3
-10
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user