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
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 94c70f3..0dc0fa5 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 dedd5b4..bf63d09 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);