diff options
-rw-r--r-- | include/vcl/opengl/OpenGLContext.hxx | 2 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 65 |
2 files changed, 59 insertions, 8 deletions
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx index 94c70f30c2e1..0dc0fa5d987b 100644 --- a/include/vcl/opengl/OpenGLContext.hxx +++ b/include/vcl/opengl/OpenGLContext.hxx @@ -30,6 +30,7 @@ #include <GL/glext.h> #include <GL/wglext.h> #elif defined( MACOSX ) +#include <OpenGL/OpenGL.h> #elif defined( IOS ) #elif defined( ANDROID ) #elif defined( UNX ) @@ -90,6 +91,7 @@ struct GLWindow HDC hDC; HGLRC hRC; #elif defined( MACOSX ) + CGLContextObj context; #elif defined( IOS ) #elif defined( ANDROID ) #elif defined( UNX ) 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); |