From f585323f89207b4ff93c6b0dbf1d80b0253bac02 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Tue, 6 May 2014 02:27:08 +0200 Subject: OpenGLContext: More error handling. Change-Id: Ib92adfc83c963ecfcfa7fdbc2ec71f363a181330 --- vcl/source/opengl/OpenGLContext.cxx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'vcl') diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 3e838eacf2d7..8faa4d941416 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -423,22 +423,34 @@ bool OpenGLContext::ImplInit() }; // we must check whether can set the MSAA - int WindowPix; + int WindowPix = 0; bool bMultiSampleSupport = InitMultisample(PixelFormatFront, WindowPix); - if (bMultiSampleSupport) + if (bMultiSampleSupport && WindowPix != 0) { m_aGLWin.bMultiSampleSupported = true; } else { - WindowPix = ChoosePixelFormat(m_aGLWin.hDC,&PixelFormatFront); + WindowPix = ChoosePixelFormat(m_aGLWin.hDC, &PixelFormatFront); } - SetPixelFormat(m_aGLWin.hDC,WindowPix,&PixelFormatFront); - m_aGLWin.hRC = wglCreateContext(m_aGLWin.hDC); - if (!wglMakeCurrent(m_aGLWin.hDC,m_aGLWin.hRC)) + if (WindowPix == 0) { - SAL_WARN("vcl.opengl", "Failed wglMakeCurrent: " << GetLastError()); + SAL_WARN("vcl.opengl", "Invalid pixelformat"); + return false; + } + + SetPixelFormat(m_aGLWin.hDC, WindowPix, &PixelFormatFront); + m_aGLWin.hRC = wglCreateContext(m_aGLWin.hDC); + if (m_aGLWin.hRC == NULL) + { + SAL_WARN("vcl.opengl", "wglCreateContext failed"); + return false; + } + + if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC)) + { + SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << GetLastError()); return false; } @@ -757,7 +769,10 @@ SystemWindowData OpenGLContext::generateWinData(Window* pParent) void OpenGLContext::makeCurrent() { #if defined( WNT ) - wglMakeCurrent(m_aGLWin.hDC,m_aGLWin.hRC); + if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC)) + { + SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError()); + } #elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID ) // nothing #elif defined( UNX ) -- cgit