Fix incorrect usage of GetLastError in LLW_Win32
GetLastError must be called before any other function which could possibly change it, otherwise we will lose the error code. (backport from master)
This commit is contained in:
@@ -214,10 +214,11 @@ RString LowLevelWindow_Win32::TryVideoMode( const VideoModeParams &p, bool &bNew
|
|||||||
/* Set the pixel format. */
|
/* Set the pixel format. */
|
||||||
if( !SetPixelFormat(GraphicsWindow::GetHDC(), iPixelFormat, &pixfmt) )
|
if( !SetPixelFormat(GraphicsWindow::GetHDC(), iPixelFormat, &pixfmt) )
|
||||||
{
|
{
|
||||||
|
DWORD err = GetLastError();
|
||||||
/* Destroy the window. */
|
/* Destroy the window. */
|
||||||
DestroyGraphicsWindowAndOpenGLContext();
|
DestroyGraphicsWindowAndOpenGLContext();
|
||||||
|
|
||||||
return werr_ssprintf( GetLastError(), "Pixel format failed" );
|
return werr_ssprintf( err, "Pixel format failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
DescribePixelFormat( GraphicsWindow::GetHDC(), iPixelFormat, sizeof(g_CurrentPixelFormat), &g_CurrentPixelFormat );
|
DescribePixelFormat( GraphicsWindow::GetHDC(), iPixelFormat, sizeof(g_CurrentPixelFormat), &g_CurrentPixelFormat );
|
||||||
@@ -232,15 +233,17 @@ RString LowLevelWindow_Win32::TryVideoMode( const VideoModeParams &p, bool &bNew
|
|||||||
g_HGLRC = wglCreateContext( GraphicsWindow::GetHDC() );
|
g_HGLRC = wglCreateContext( GraphicsWindow::GetHDC() );
|
||||||
if ( g_HGLRC == nullptr )
|
if ( g_HGLRC == nullptr )
|
||||||
{
|
{
|
||||||
|
DWORD err = GetLastError();
|
||||||
DestroyGraphicsWindowAndOpenGLContext();
|
DestroyGraphicsWindowAndOpenGLContext();
|
||||||
return hr_ssprintf( GetLastError(), "wglCreateContext" );
|
return hr_ssprintf( err, "wglCreateContext" );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_HGLRC_Background = wglCreateContext( GraphicsWindow::GetHDC() );
|
g_HGLRC_Background = wglCreateContext( GraphicsWindow::GetHDC() );
|
||||||
if( g_HGLRC_Background == nullptr )
|
if( g_HGLRC_Background == nullptr )
|
||||||
{
|
{
|
||||||
|
DWORD err = GetLastError();
|
||||||
DestroyGraphicsWindowAndOpenGLContext();
|
DestroyGraphicsWindowAndOpenGLContext();
|
||||||
return hr_ssprintf( GetLastError(), "wglCreateContext" );
|
return hr_ssprintf( err, "wglCreateContext" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !wglShareLists(g_HGLRC, g_HGLRC_Background) )
|
if( !wglShareLists(g_HGLRC, g_HGLRC_Background) )
|
||||||
@@ -252,8 +255,9 @@ RString LowLevelWindow_Win32::TryVideoMode( const VideoModeParams &p, bool &bNew
|
|||||||
|
|
||||||
if( !wglMakeCurrent( GraphicsWindow::GetHDC(), g_HGLRC ) )
|
if( !wglMakeCurrent( GraphicsWindow::GetHDC(), g_HGLRC ) )
|
||||||
{
|
{
|
||||||
|
DWORD err = GetLastError();
|
||||||
DestroyGraphicsWindowAndOpenGLContext();
|
DestroyGraphicsWindowAndOpenGLContext();
|
||||||
return hr_ssprintf( GetLastError(), "wglCreateContext" );
|
return hr_ssprintf( err, "wglCreateContext" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RString(); // we set the video mode successfully
|
return RString(); // we set the video mode successfully
|
||||||
@@ -268,8 +272,9 @@ void LowLevelWindow_Win32::BeginConcurrentRendering()
|
|||||||
{
|
{
|
||||||
if( !wglMakeCurrent( GraphicsWindow::GetHDC(), g_HGLRC_Background ) )
|
if( !wglMakeCurrent( GraphicsWindow::GetHDC(), g_HGLRC_Background ) )
|
||||||
{
|
{
|
||||||
LOG->Warn( hr_ssprintf(GetLastError(), "wglMakeCurrent") );
|
DWORD err = GetLastError();
|
||||||
FAIL_M( hr_ssprintf(GetLastError(), "wglMakeCurrent") );
|
LOG->Warn( hr_ssprintf(err, "wglMakeCurrent") );
|
||||||
|
FAIL_M( hr_ssprintf(err, "wglMakeCurrent") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user