summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-07-16 08:02:32 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-07-16 14:58:39 +0200
commitcc1bea8692ad44dcc795766118b4b75c690e2655 (patch)
treeaad060f6793d001dd2b235c2ff6f764961e12968 /vcl
parent51ba2df1cb29d4343f92174da6dc8f36ba9152eb (diff)
first part of OpenGL context work for OSX
Context is correctly created and the OpenGL calls no longer crash but it seems that I still have a buffer problem so nothing is shown on the screen. Change-Id: Ia9cc585cd92c6049197dbfa47a41e30e130739ed
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx65
1 files changed, 57 insertions, 8 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index dedd5b4953ae..bf63d0968d69 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -42,7 +42,10 @@ OpenGLContext::~OpenGLContext()
wglDeleteContext( m_aGLWin.hRC );
ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC );
}
-#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID )
+#elif defined( MACOSX )
+ CGLSetCurrentContext(NULL);
+ CGLDestroyContext(m_aGLWin.context);
+#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
if(m_aGLWin.ctx)
@@ -392,9 +395,6 @@ bool OpenGLContext::ImplInit()
m_aGLWin.hDC = GetDC(m_aGLWin.hWnd);
#elif defined( MACOSX )
- SAL_INFO("vcl.opengl", "OpenGLContext not implemented yet for OS X");
- return false;
-
#elif defined( IOS )
SAL_INFO("vcl.opengl", "OpenGLContext not implemented yet for iOS");
@@ -474,6 +474,24 @@ bool OpenGLContext::ImplInit()
#elif defined( MACOSX )
+ CGLPixelFormatAttribute pixelFormatAttributes[] = {
+ kCGLPFAColorSize, (CGLPixelFormatAttribute) 24,
+ kCGLPFAAlphaSize, (CGLPixelFormatAttribute) 8,
+ kCGLPFADoubleBuffer,
+ kCGLPFASampleBuffers, (CGLPixelFormatAttribute) 1,
+ kCGLPFASampleBuffers, (CGLPixelFormatAttribute) 4,
+ (CGLPixelFormatAttribute) 0
+ };
+
+ CGLPixelFormatObj pixelFormat;
+ GLint numberOfPixels;
+ CGLChoosePixelFormat(pixelFormatAttributes, &pixelFormat, &numberOfPixels);
+
+ CGLCreateContext(pixelFormat, 0, &m_aGLWin.context);
+ CGLDestroyPixelFormat(pixelFormat);
+
+ CGLSetCurrentContext(m_aGLWin.context);
+
#elif defined( IOS )
#elif defined( ANDROID )
@@ -617,7 +635,32 @@ bool OpenGLContext::initWindow()
return true;
}
-#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID )
+#elif defined( MACOSX )
+
+bool OpenGLContext::initWindow()
+{
+ if( !m_pChildWindow )
+ {
+ SystemWindowData winData = generateWinData(mpWindow);
+ m_pChildWindow = new SystemChildWindow(mpWindow, 0, &winData, false);
+ m_pChildWindowGC.reset(m_pChildWindow);
+ }
+
+ if( m_pChildWindow )
+ {
+ m_pChildWindow->SetMouseTransparent( true );
+ m_pChildWindow->SetParentClipMode(PARENTCLIPMODE_CLIP);
+ m_pChildWindow->EnableEraseBackground( false );
+ m_pChildWindow->SetControlForeground();
+ m_pChildWindow->SetControlBackground();
+ //m_pChildWindow->EnablePaint(false);
+
+ }
+
+ return true;
+}
+
+#elif defined( IOS ) || defined( ANDROID )
bool OpenGLContext::initWindow()
{
@@ -793,7 +836,9 @@ void OpenGLContext::makeCurrent()
{
SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError());
}
-#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID )
+#elif defined( MACOSX )
+ CGLSetCurrentContext(m_aGLWin.context);
+#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
glXMakeCurrent( m_aGLWin.dpy, m_aGLWin.win, m_aGLWin.ctx );
@@ -804,7 +849,9 @@ void OpenGLContext::resetCurrent()
{
#if defined( WNT )
wglMakeCurrent( m_aGLWin.hDC, 0 );
-#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID )
+#elif defined( MACOSX )
+ CGLSetCurrentContext(NULL);
+#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
glXMakeCurrent(m_aGLWin.dpy, None, NULL);
@@ -815,7 +862,9 @@ void OpenGLContext::swapBuffers()
{
#if defined( WNT )
SwapBuffers(m_aGLWin.hDC);
-#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID )
+#elif defined( MACOSX )
+ CGLFlushDrawable(m_aGLWin.context);
+#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
glXSwapBuffers(m_aGLWin.dpy, m_aGLWin.win);