Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp	(revision 53749)
@@ -2577,5 +2577,5 @@
                         SVGA3dCmdDefineContext *pCmd = (SVGA3dCmdDefineContext *)(pHdr + 1);
 
-                        rc = vmsvga3dContextDefine(pThis, pCmd->cid);
+                        rc = vmsvga3dContextDefine(pThis, pCmd->cid, false /*fLegacy*/);
                         break;
                     }
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.h	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.h	(revision 53749)
@@ -35,5 +35,5 @@
 #endif
 
-VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx);
+VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx, bool fLegacy);
 VMSVGA3D_DECL(void) vmsvga3dCocoaDestroyContext(NativeNSOpenGLContextRef pCtx);
 VMSVGA3D_DECL(void) vmsvga3dCocoaCreateView(NativeNSViewRef *ppView, NativeNSViewRef pParentView);
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.m
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.m	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.m	(revision 53749)
@@ -623,5 +623,5 @@
 
 
-void vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pShareCtx)
+void vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pShareCtx, bool fLegacy)
 {
     DEBUG_FUNC_ENTER();
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp	(revision 53749)
@@ -406,4 +406,5 @@
     NativeNSOpenGLContextRef cocoaContext;
     NativeNSViewRef          cocoaView;
+    bool                    fLegacy;
 #else
     /** XGL rendering context handle */
@@ -504,5 +505,10 @@
 };
 
-typedef struct
+/**
+ * VMSVGA3d state data.
+ *
+ * Allocated on the heap and pointed to by VMSVGAState::p3dState.
+ */
+typedef struct VMSVGA3DSTATE
 {
 #ifdef RT_OS_WINDOWS
@@ -598,5 +604,14 @@
     uint32_t                idTestContext;
 #endif
-} VMSVGA3DSTATE, *PVMSVGA3DSTATE;
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+    /** Legacy OpenGL profile GL_EXTENSIONS result (RTStrDup).
+     * This is used to detect shader model version since some implementations
+     * (darwin) hides extensions that have made it into core and probably a
+     * bunch of others when using a OpenGL core profile instead of a legacy one */
+    R3PTRTYPE(char *)       pszLegacyExtensions;
+#endif
+} VMSVGA3DSTATE;
+/** Pointer to the VMSVGA3d state. */
+typedef VMSVGA3DSTATE *PVMSVGA3DSTATE;
 
 /**
@@ -904,4 +919,7 @@
     AssertReturn(pThis->svga.p3dState, VERR_NO_MEMORY);
     PVMSVGA3DCONTEXT pContext;
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+    PVMSVGA3DCONTEXT pLegacyContext;
+#endif
     int              rc;
 
@@ -909,6 +927,23 @@
         return VINF_SUCCESS;    /* already initialized (load state) */
 
-    /* OpenGL function calls aren't possible without a valid current context, so create a fake one here. */
-    rc = vmsvga3dContextDefine(pThis, 1);
+    /*
+     * Initialize the capabilities with sensible defaults.
+     */
+    pState->caps.maxActiveLights               = 1;
+    pState->caps.maxTextureBufferSize          = 65536;
+    pState->caps.maxTextures                   = 1;
+    pState->caps.maxClipDistances              = 4;
+    pState->caps.maxColorAttachments           = 1;
+    pState->caps.maxRectangleTextureSize       = 2048;
+    pState->caps.maxTextureAnisotropy          = 2;
+    pState->caps.maxVertexShaderInstructions   = 1024;
+    pState->caps.maxFragmentShaderInstructions = 1024;
+    pState->caps.vertexShaderVersion           = SVGA3DVSVERSION_NONE;
+    pState->caps.fragmentShaderVersion         = SVGA3DPSVERSION_NONE;
+
+    /*
+     * OpenGL function calls aren't possible without a valid current context, so create a fake one here.
+     */
+    rc = vmsvga3dContextDefine(pThis, 1, false /*fLegacy*/);
     AssertRCReturn(rc, rc);
 
@@ -921,4 +956,32 @@
 
     pState->fGLVersion = atof((const char *)glGetString(GL_VERSION));
+
+
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+    /*
+     * Get the legacy extension list so we can better figure out the shader model.
+     * We add space before and after the list, so we can use strstr for locating extensions.
+     */
+    rc = vmsvga3dContextDefine(pThis, 2, true /*fLegacy*/);
+    AssertLogRelRCReturn(rc, rc);
+    pContext = &pState->paContext[1]; /* Array may have been reallocated. */
+
+    pLegacyContext = &pState->paContext[2];
+    VMSVGA3D_SET_CURRENT_CONTEXT(pState, pLegacyContext);
+
+    pState->pszLegacyExtensions = NULL;
+    rc = RTStrAAppendExN(&pState->pszLegacyExtensions, 3,
+                         " ", (size_t)1, (const char *)glGetString(GL_EXTENSIONS), RTSTR_MAX, " ", (size_t)1);
+    AssertLogRelRCReturn(rc, rc);
+
+    LogRel(("VMSVGA3d: Legacy OpenGL version: %s\nOpenGL Vendor: %s\nOpenGL Renderer: %s\n", glGetString(GL_VERSION), glGetString(GL_VENDOR), glGetString(GL_RENDERER)));
+    LogRel(("VMSVGA3d: Legacy OpenGL shader language version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)));
+    LogRel(("VMSVGA3d: Legacy OpenGL extenions: %s\n", glGetString(GL_EXTENSIONS)));
+
+    VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
+#else
+    pState->pszLegacyExtensions = "";
+#endif
+
 
     if (vmsvga3dCheckGLExtension(pState->fGLVersion, 3.0, "GL_ARB_framebuffer_object"))
@@ -1011,22 +1074,15 @@
 #endif
 
-    /* First set sensible defaults. */
-    pState->caps.maxActiveLights               = 1;
-    pState->caps.maxTextureBufferSize          = 65536;
-    pState->caps.maxTextures                   = 1;
-    pState->caps.maxClipDistances              = 4;
-    pState->caps.maxColorAttachments           = 1;
-    pState->caps.maxRectangleTextureSize       = 2048;
-    pState->caps.maxTextureAnisotropy          = 2;
-    pState->caps.maxVertexShaderInstructions   = 1024;
-    pState->caps.maxFragmentShaderInstructions = 1024;
-    pState->caps.vertexShaderVersion           = SVGA3DVSVERSION_NONE;
-    pState->caps.fragmentShaderVersion         = SVGA3DPSVERSION_NONE;
-
     /* Query capabilities */
 #ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
     glGetIntegerv(GL_MAX_LIGHTS, &pState->caps.maxActiveLights);
     if (glGetError() != GL_NO_ERROR)
-        pState->caps.maxActiveLights = 1;
+    {
+        VMSVGA3D_SET_CURRENT_CONTEXT(pState, pLegacyContext);
+        VMSVGA3D_INIT_CHECKED_GL_GET_INTEGER_VALUE(GL_MAX_LIGHTS, &pState->caps.maxActiveLights);
+        if (glGetError() != GL_NO_ERROR)
+            pState->caps.maxActiveLights = 1;
+        VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
+    }
 #else
     VMSVGA3D_INIT_CHECKED_GL_GET_INTEGER_VALUE(GL_MAX_LIGHTS, &pState->caps.maxActiveLights);
@@ -1048,6 +1104,12 @@
     if (glGetError() != GL_NO_ERROR)
     {
-        pState->caps.flPointSize[0] = 1;
-        pState->caps.flPointSize[1] = 1;
+        VMSVGA3D_SET_CURRENT_CONTEXT(pState, pLegacyContext);
+        VMSVGA3D_INIT_CHECKED(glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, pState->caps.flPointSize));
+        if (glGetError() != GL_NO_ERROR)
+        {
+            pState->caps.flPointSize[0] = 1;
+            pState->caps.flPointSize[1] = 1;
+        }
+        VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
     }
 #else
@@ -1057,24 +1119,7 @@
     if (pState->ext.glGetProgramivARB)
     {
-#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
-        pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB,
-                                      &pState->caps.maxFragmentShaderTemps);
-        if (glGetError() != GL_NO_ERROR)
-            pState->caps.maxFragmentShaderTemps = D3DVS20_MAX_NUMTEMPS;
-        pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB,
-                                      &pState->caps.maxFragmentShaderInstructions);
-        if (glGetError() != GL_NO_ERROR)
-            pState->caps.maxFragmentShaderInstructions = 0;
-
-        pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB,
-                                      &pState->caps.maxVertexShaderTemps);
-        if (glGetError() != GL_NO_ERROR)
-            pState->caps.maxVertexShaderTemps = D3DVS20_MAX_NUMTEMPS;
-        pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB,
-                                      &pState->caps.maxVertexShaderInstructions);
-        if (glGetError() != GL_NO_ERROR)
-            pState->caps.maxVertexShaderInstructions = 0;
-
-#else
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE /* None of these queries works with the OpenGL 3.2 Core context on darwin. */
+        VMSVGA3D_SET_CURRENT_CONTEXT(pState, pLegacyContext);
+#endif
         VMSVGA3D_INIT_CHECKED(pState->ext.glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB,
                                                             &pState->caps.maxFragmentShaderTemps));
@@ -1085,4 +1130,6 @@
         VMSVGA3D_INIT_CHECKED(pState->ext.glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB,
                                                             &pState->caps.maxVertexShaderInstructions));
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+        VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
 #endif
     }
@@ -1099,5 +1146,6 @@
      */
     /** @todo: distinguish between vertex and pixel shaders??? */
-    if (vmsvga3dCheckGLExtension(pState->fGLVersion, 0.0, "GL_NV_gpu_program4"))
+    if (   vmsvga3dCheckGLExtension(pState->fGLVersion, 0.0, "GL_NV_gpu_program4")
+        || strstr(pState->pszLegacyExtensions, " GL_NV_gpu_program4 "))
     {
         pState->caps.vertexShaderVersion   = SVGA3DVSVERSION_40;
@@ -1106,6 +1154,8 @@
     else
     if (    vmsvga3dCheckGLExtension(pState->fGLVersion, 0.0, "GL_NV_vertex_program3")
+        || strstr(pState->pszLegacyExtensions, " GL_NV_vertex_program3 ")
 #if 0 /** @todo this is contrary to the ATI <= SM2.0. */
         ||  vmsvga3dCheckGLExtension(pState->fGLVersion, 0.0, "GL_ARB_shader_texture_lod")  /* Wine claims this suggests SM 3.0 support */
+        || strstr(pState->pszLegacyExtensions, " GL_ARB_shader_texture_lod ")
 #endif
         )
@@ -1115,5 +1165,6 @@
     }
     else
-    if (vmsvga3dCheckGLExtension(pState->fGLVersion, 0.0, "GL_ARB_fragment_program"))
+    if (   vmsvga3dCheckGLExtension(pState->fGLVersion, 0.0, "GL_ARB_fragment_program")
+        || strstr(pState->pszLegacyExtensions, " GL_ARB_fragment_program "))
     {
         pState->caps.vertexShaderVersion   = SVGA3DVSVERSION_20;
@@ -1199,17 +1250,17 @@
 
     LogRel(("VMSVGA3d: Capabilities:\n"));
-    LogRel(("VMSVGA3d:   maxActiveLights=%d  maxTextureBufferSize=%d  maxTextures=%d\n",
-            pState->caps.maxActiveLights, pState->caps.maxTextureBufferSize, pState->caps.maxTextures));
-    LogRel(("VMSVGA3d:   maxClipDistances=%d  maxColorAttachments=%d  maxClipDistances=%d\n",
+    LogRel(("VMSVGA3d:   maxActiveLights=%-2d       maxTextures=%-2d           maxTextureBufferSize=%d\n",
+            pState->caps.maxActiveLights, pState->caps.maxTextures, pState->caps.maxTextureBufferSize));
+    LogRel(("VMSVGA3d:   maxClipDistances=%-2d      maxColorAttachments=%-2d   maxClipDistances=%d\n",
             pState->caps.maxClipDistances, pState->caps.maxColorAttachments, pState->caps.maxClipDistances));
-    LogRel(("VMSVGA3d:   maxColorAttachments=%d  maxRectangleTextureSize=%d  maxTextureAnisotropy=%d\n",
-            pState->caps.maxColorAttachments, pState->caps.maxRectangleTextureSize, pState->caps.maxTextureAnisotropy));
-    LogRel(("VMSVGA3d:   maxVertexShaderInstructions=%d  maxFragmentShaderInstructions=%d  maxVertexShaderTemps=%d\n",
-            pState->caps.maxVertexShaderInstructions, pState->caps.maxFragmentShaderInstructions, pState->caps.maxVertexShaderTemps));
-    LogRel(("VMSVGA3d:   maxFragmentShaderTemps=%d  flPointSize={%d.%02u, %d.%02u}\n",
+    LogRel(("VMSVGA3d:   maxColorAttachments=%-2d   maxTextureAnisotropy=%-2d  maxRectangleTextureSize=%d\n",
+            pState->caps.maxColorAttachments, pState->caps.maxTextureAnisotropy, pState->caps.maxRectangleTextureSize));
+    LogRel(("VMSVGA3d:   maxVertexShaderTemps=%-2d  maxVertexShaderInstructions=%d maxFragmentShaderInstructions=%d\n",
+            pState->caps.maxVertexShaderTemps, pState->caps.maxVertexShaderInstructions, pState->caps.maxFragmentShaderInstructions));
+    LogRel(("VMSVGA3d:   maxFragmentShaderTemps=%d flPointSize={%d.%02u, %d.%02u}\n",
             pState->caps.maxFragmentShaderTemps,
             (int)pState->caps.flPointSize[0], (int)(pState->caps.flPointSize[0] * 100) % 100,
             (int)pState->caps.flPointSize[1], (int)(pState->caps.flPointSize[1] * 100) % 100));
-    LogRel(("VMSVGA3d: fragmentShaderVersion=%d  vertexShaderVersion=%d  fS3TCSupported=%d\n",
+    LogRel(("VMSVGA3d:   fragmentShaderVersion=%-2d vertexShaderVersion=%-2d   fS3TCSupported=%d\n",
             pState->caps.fragmentShaderVersion, pState->caps.vertexShaderVersion, pState->caps.fS3TCSupported));
 
@@ -1222,4 +1273,8 @@
     rc = vmsvga3dContextDestroy(pThis, 1);
     AssertRC(rc);
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+    rc = vmsvga3dContextDestroy(pThis, 2);
+    AssertRC(rc);
+#endif
 
 #if !defined(RT_OS_DARWIN) || defined(VBOX_VMSVGA3D_USE_OPENGL_CORE)
@@ -1286,5 +1341,5 @@
 {
     PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
-    AssertReturn(pThis->svga.p3dState, VERR_NO_MEMORY);
+    AssertReturn(pState, VERR_WRONG_ORDER);
     int            rc;
 
@@ -1312,4 +1367,9 @@
     XCloseDisplay(pState->display);
 #endif
+
+#ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+    RTStrFree(pState->pszLegacyExtensions);
+#endif
+    pState->pszLegacyExtensions = NULL;
 
     return VINF_SUCCESS;
@@ -3188,6 +3248,8 @@
  * @param   pThis           VGA device instance data.
  * @param   cid             Context id
+ * @param   fLegacy         Whether to create a legacy context instead of
+ *                          whatever is default.  Only used at init time.
  */
-int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid)
+int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid, bool fLegacy)
 {
     int                     rc;
@@ -3197,4 +3259,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(cid < SVGA3D_MAX_CONTEXT_IDS, VERR_INVALID_PARAMETER);
+#if !defined(VBOX_VMSVGA3D_USE_OPENGL_CORE) || !(defined(RT_OS_DARWIN))
+    AssertReturn(!fLegacy, VERR_INTERNAL_ERROR_3);
+#endif
 
     Log(("vmsvga3dContextDefine id %x\n", cid));
@@ -3203,5 +3268,5 @@
     {
         pState->idTestContext = 207;
-        rc = vmsvga3dContextDefine(pThis, pState->idTestContext);
+        rc = vmsvga3dContextDefine(pThis, pState->idTestContext, false /*fLegacy*/);
         AssertRCReturn(rc, rc);
     }
@@ -3323,4 +3388,6 @@
 
 #elif defined(RT_OS_DARWIN)
+    pContext->fLegacy = fLegacy;
+
     /* Find the first active context to share the display list with (necessary for sharing e.g. textures between contexts). */
     NativeNSOpenGLContextRef shareContext = NULL;
@@ -3328,5 +3395,6 @@
     {
         if (    pState->paContext[i].id != SVGA3D_INVALID_ID
-            &&  i != pContext->id)
+            &&  i != pContext->id
+            &&  pState->paContext[i].fLegacy == fLegacy)
         {
             Log(("Sharing display lists between cid=%d and cid=%d\n", pContext->id, i));
@@ -3335,5 +3403,5 @@
         }
     }
-    vmsvga3dCocoaCreateContext(&pContext->cocoaContext, shareContext);
+    vmsvga3dCocoaCreateContext(&pContext->cocoaContext, shareContext, fLegacy);
     NativeNSViewRef pHostView = (NativeNSViewRef)pThis->svga.u64HostWindowId;
     vmsvga3dCocoaCreateView(&pContext->cocoaView, pHostView);
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h	(revision 53749)
@@ -49,5 +49,5 @@
             uint32_t cPixelShaderConst, cVertexShaderConst, cPixelShaders, cVertexShaders;
 
-            rc = vmsvga3dContextDefine(pThis, cid);
+            rc = vmsvga3dContextDefine(pThis, cid, false /*fLegacy*/);
             AssertRCReturn(rc, rc);
 
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp	(revision 53749)
@@ -2902,6 +2902,7 @@
  * @param   pThis           VGA device instance data.
  * @param   cid             Context id
+ * @param   fLegacy         OpenGL(+darwin) specific argument, ignored.
  */
-int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid)
+int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid, bool fLegacy)
 {
     int                     rc;
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h	(revision 53748)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h	(revision 53749)
@@ -61,5 +61,5 @@
 int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect);
 
-int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid);
+int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid, bool fLegacy);
 int vmsvga3dContextDestroy(PVGASTATE pThis, uint32_t cid);
 
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 53748)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 53749)
@@ -223,5 +223,5 @@
 
 /* 
- * VMSVGA3D compatability glue.
+ * VMSVGA3D compatibility glue.
  */
 
@@ -238,5 +238,6 @@
 # define CR_OVERLAY_BIT         RT_BIT_32(8)
 # define CR_PBUFFER_BIT         RT_BIT_32(9)
-# define CR_ALL_BITS            UINT32_C(0x000003ff)
+# define VMSVGA3D_LEGACY_PROFILE_BIT RT_BIT_32(31)
+# define CR_ALL_BITS            UINT32_C(0x800003ff)
 
 typedef struct WindowInfo
@@ -1132,4 +1133,5 @@
 
     self = [super initWithFormat:format shareContext:share];
+    Assert(self != nil);
     if (self)
         m_pPixelFormat = format;
@@ -2575,4 +2577,15 @@
     int i = 3;
 
+#ifdef IN_VMSVGA3D
+    if (fVisParams & VMSVGA3D_LEGACY_PROFILE_BIT)
+    {
+# ifdef VBOX_VMSVGA3D_USE_OPENGL_CORE
+        attribs[1] = NSOpenGLProfileVersionLegacy;
+# else
+        AssertFailed();
+# endif
+    }
+#endif
+
     if (fVisParams & CR_ALPHA_BIT)
     {
@@ -2638,4 +2651,5 @@
     {
         *ppCtx = [[OverlayOpenGLContext alloc] initWithFormat:pFmt shareContext:pSharedCtx];
+        Assert(*ppCtx);
 
         /* Enable multi threaded OpenGL engine */
@@ -2648,5 +2662,8 @@
     }
     else
+    {
+        AssertFailed();
         *ppCtx = NULL;
+    }
 
     [pPool release];
@@ -2967,7 +2984,8 @@
  */
 
-VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx)
-{
-    cocoaGLCtxCreate(ppCtx, CR_ALPHA_BIT | CR_DEPTH_BIT | CR_DOUBLE_BIT, pSharedCtx);
+VMSVGA3D_DECL(void) vmsvga3dCocoaCreateContext(NativeNSOpenGLContextRef *ppCtx, NativeNSOpenGLContextRef pSharedCtx, bool fLegacy)
+{
+    cocoaGLCtxCreate(ppCtx, CR_ALPHA_BIT | CR_DEPTH_BIT | CR_DOUBLE_BIT | (fLegacy ? VMSVGA3D_LEGACY_PROFILE_BIT : 0), 
+                     pSharedCtx);
 }
 
