summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-05-06 02:27:08 +0200
committerJan Holesovsky <kendy@collabora.com>2014-05-06 03:09:39 +0200
commitf585323f89207b4ff93c6b0dbf1d80b0253bac02 (patch)
tree57667b4486a6c82edfb2190ce30149c4e8999be9 /vcl
parent18d4f6c9ee24dc080bc3b6fed7403f5d0c18f965 (diff)
OpenGLContext: More error handling.
Change-Id: Ib92adfc83c963ecfcfa7fdbc2ec71f363a181330
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx31
1 files changed, 23 insertions, 8 deletions
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 )