From ff22cb87581101ee44eee93d8c45594d5b9ba486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 9 Jun 2020 21:21:17 +0200 Subject: [PATCH] Platform: print EGL device count before overwriting the count variable. Otherwise it would report a wrong count. --- src/Magnum/Platform/WindowlessEglApplication.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index bb42c0bfe..b514e2b06 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -201,14 +201,17 @@ WindowlessEglContext::WindowlessEglContext(const Configuration& configuration, G /* Otherwise just a normal EGL device */ } else { + /* Print the log *before* calling eglQueryDevices() again, as + the `count` gets overwritten by it */ + if(magnumContext && (magnumContext->internalFlags() >= GL::Context::InternalFlag::DisplayVerboseInitializationLog)) { + Debug{} << "Platform::WindowlessEglApplication: found" << count << "EGL devices, choosing device" << configuration.device(); + } + + selectedDevice = configuration.device(); devices = Containers::Array{configuration.device() + 1}; /* Assuming the same thing won't suddenly start failing when called the second time */ CORRADE_INTERNAL_ASSERT_OUTPUT(eglQueryDevices(configuration.device() + 1, devices, &count)); - selectedDevice = configuration.device(); - if(magnumContext && (magnumContext->internalFlags() >= GL::Context::InternalFlag::DisplayVerboseInitializationLog)) { - Debug{} << "Platform::WindowlessEglApplication: found" << count << "EGL devices, choosing device" << selectedDevice; - } } if(!(_display = reinterpret_cast(eglGetProcAddress("eglGetPlatformDisplayEXT"))(EGL_PLATFORM_DEVICE_EXT, devices[selectedDevice], nullptr))) {