message: Use GetLastError for additional error reporting
diff: #include <utils/Log.h>
  #include <utils/Panic.h>
  +namespace {
  +
  +void reportLastWindowsError() {
  + LPSTR lpMessageBuffer;
  + DWORD dwError = GetLastError();
  +
  + if (dwError == 0) {
  + return;
  + }
  +
  + FormatMessage(
  + FORMAT_MESSAGE_ALLOCATE_BUFFER |
  + FORMAT_MESSAGE_FROM_SYSTEM |
  + FORMAT_MESSAGE_IGNORE_INSERTS,
  + nullptr,
  + dwError,
  + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  + lpMessageBuffer,
  + 0, nullptr
  + );
  +
  + utils::slog.e << "Windows error code: " << dwError << ". " << lpMessageBuffer
  + << utils::io::endl;
  +
  + LocalFree(lpMessageBuffer);
  +}
  +
  +} // namespace
  +
  namespace filament {
  using namespace driver;
  @@ -101,6 +130,7 @@ error:
  if (tempContext) {
  wglDeleteContext(tempContext);
  }
  + reportLastWindowsError();
  terminate();
  return NULL;
  }
  @@ -126,8 +156,10 @@ void ContextManagerWGL::terminate() noexcept {
  ExternalContext::SwapChain* ContextManagerWGL::createSwapChain(void* nativeWindow, uint64_t& flags) noexcept {
  // on Windows, the nativeWindow maps directly to a HDC
  HDC hdc = (HDC) nativeWindow;
  - ASSERT_POSTCONDITION_NON_FATAL(hdc,
  - "Unable to create the SwapChain (nativeWindow = %p)", nativeWindow);
  + if (!ASSERT_POSTCONDITION_NON_FATAL(hdc,
  + "Unable to create the SwapChain (nativeWindow = %p)", nativeWindow)) {
  + reportLastWindowsError();
  + }
  // We have to match pixel formats across the HDC and HGLRC (mContext)
  int pixelFormat = ChoosePixelFormat(hdc, &mPfd);
  @@ -147,6 +179,7 @@ void ContextManagerWGL::makeCurrent(ExternalContext::SwapChain* swapChain) noexc
  if (hdc != NULL) {
  BOOL success = wglMakeCurrent(hdc, mContext);
  if (!ASSERT_POSTCONDITION_NON_FATAL(success, "wglMakeCurrent() failed. hdc = %p", hdc)) {
  + reportLastWindowsError();
  wglMakeCurrent(0, NULL);
  }
  }
  