Index: trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h	(revision 40690)
+++ trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h	(revision 40691)
@@ -207,4 +207,5 @@
 DECLEXPORT(CRContext *) crStateGetCurrent(void);
 DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
+DECLEXPORT(GLboolean) crStateEnableDiffOnMakeCurrent(GLboolean fEnable);
 
 CRContext * crStateSwichPrepare(CRContext *toCtx);
@@ -227,5 +228,7 @@
 #ifndef IN_GUEST
 DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
-DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM);
+typedef DECLCALLBACK(CRContext*) FNCRSTATE_CONTEXT_GET(void*);
+typedef FNCRSTATE_CONTEXT_GET *PFNCRSTATE_CONTEXT_GET;
+DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM);
 DECLEXPORT(void)    crStateFreeShared(CRSharedState *s);
 #endif
Index: trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h	(revision 40690)
+++ trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h	(revision 40691)
@@ -104,4 +104,16 @@
 } CRMuralInfo;
 
+typedef struct {
+    char   *pszDpyName;
+    GLint   visualBits;
+    int32_t internalID;
+} CRCreateInfo_t;
+
+typedef struct {
+    CRContext *pContext;
+    int SpuContext;
+    CRCreateInfo_t CreateInfo;
+} CRContextInfo;
+
 /**
  * A client is basically an upstream Cr Node (connected via mothership)
@@ -113,5 +125,5 @@
     uint64_t pid;      /*guest pid*/
     GLint currentContextNumber;
-    CRContext *currentCtx;
+    CRContextInfo *currentCtxInfo;
     GLint currentWindow;
     CRMuralInfo *currentMural;
@@ -173,4 +185,5 @@
     GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
     GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
+    CRContextInfo *currentCtxInfo;
     GLint currentWindow;
     GLint currentNativeWindow;
@@ -195,11 +208,7 @@
     CRLimitsState limits; /**< GL limits for any contexts we create */
 
-    int SpuContext; /**< Rendering context for the head SPU */
-    int SpuContextVisBits; /**< Context's visual attributes */
-    char *SpuContextDpyName; /**< Context's dpyName */
+    CRContextInfo MainContextInfo;
 
     CRHashTable *contextTable;  /**< hash table for rendering contexts */
-    CRHashTable *pContextCreateInfoTable; /**< hash table with contexts creation info */
-    CRContext *DummyContext;    /**< used when no other bound context */
 
     CRHashTable *programTable;  /**< for vertex programs */
@@ -267,4 +276,6 @@
     GLboolean             bUseOutputRedirect;       /* Whether the output redirect was set. */
     CROutputRedirect      outputRedirect;
+
+    GLboolean             bUseMultipleContexts;
 } CRServer;
 
Index: trunk/src/VBox/GuestHost/OpenGL/include/cr_spu.h
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/include/cr_spu.h	(revision 40690)
+++ trunk/src/VBox/GuestHost/OpenGL/include/cr_spu.h	(revision 40691)
@@ -137,4 +137,5 @@
 typedef HGLRC (WGL_APIENTRY *wglCreateContextFunc_t)(HDC);
 typedef void (WGL_APIENTRY *wglDeleteContextFunc_t)(HGLRC);
+typedef BOOL (WGL_APIENTRY *wglShareListsFunc_t)(HGLRC,HGLRC);
 typedef BOOL (WGL_APIENTRY *wglMakeCurrentFunc_t)(HDC,HGLRC);
 typedef BOOL (WGL_APIENTRY *wglSwapBuffersFunc_t)(HDC);
@@ -315,4 +316,5 @@
     wglCreateContextFunc_t wglCreateContext;
     wglDeleteContextFunc_t wglDeleteContext;
+    wglShareListsFunc_t wglShareLists;
     wglMakeCurrentFunc_t wglMakeCurrent;
     wglSwapBuffersFunc_t wglSwapBuffers;
Index: trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py	(revision 40690)
+++ trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py	(revision 40691)
@@ -346,4 +346,5 @@
 	"wglCreateContext",
 	"wglDeleteContext",
+	"wglShareLists",
 	"wglGetCurrentContext",
 	"wglChoosePixelFormat",
Index: trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c	(revision 40690)
+++ trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c	(revision 40691)
@@ -24,4 +24,5 @@
 static CRContext *defaultContext = NULL;
 
+static GLboolean g_bVBoxEnableDiffOnMakeCurrent = GL_TRUE;
 
 
@@ -488,4 +489,10 @@
 }
 
+GLboolean crStateEnableDiffOnMakeCurrent(GLboolean fEnable)
+{
+    GLboolean bOld = g_bVBoxEnableDiffOnMakeCurrent;
+    g_bVBoxEnableDiffOnMakeCurrent = fEnable;
+    return bOld;
+}
 
 void crStateMakeCurrent( CRContext *ctx )
@@ -501,5 +508,5 @@
     CRASSERT(ctx);
 
-    if (current) {
+    if (g_bVBoxEnableDiffOnMakeCurrent && current) {
         /* Check to see if the differencer exists first,
            we may not have one, aka the packspu */
Index: trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c	(revision 40690)
+++ trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c	(revision 40691)
@@ -1381,4 +1381,5 @@
 
 typedef struct _crFindSharedCtxParms {
+    PFNCRSTATE_CONTEXT_GET pfnCtxGet;
     CRContext *pSrcCtx, *pDstCtx;
 } crFindSharedCtxParms_t;
@@ -1386,6 +1387,6 @@
 static void crStateFindSharedCB(unsigned long key, void *data1, void *data2)
 {
-    CRContext *pContext = (CRContext *) data1;
     crFindSharedCtxParms_t *pParms = (crFindSharedCtxParms_t *) data2;
+    CRContext *pContext = pParms->pfnCtxGet(data1);
     (void) key;
 
@@ -1403,5 +1404,5 @@
 AssertCompile(RT_OFFSETOF(CRContext, shared) >= VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + RT_SIZEOFMEMB(CRContext, bitid) + RT_SIZEOFMEMB(CRContext, neg_bitid));
 
-int32_t crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM)
+int32_t crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM)
 {
     CRContext* pTmpContext;
@@ -1488,4 +1489,5 @@
 
         pTmpContext->shared = NULL;
+        parms.pfnCtxGet = pfnCtxGet;
         parms.pSrcCtx = pContext;
         parms.pDstCtx = pTmpContext;
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h	(revision 40691)
@@ -82,10 +82,4 @@
 } CRServerProgram;
 
-typedef struct {
-    char   *pszDpyName;
-    GLint   visualBits; 
-    int32_t internalID;
-} CRCreateInfo_t;
-
 void crServerSetVBoxConfiguration();
 void crServerSetVBoxConfigurationHGCM();
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.c	(revision 40691)
@@ -265,5 +265,5 @@
 
 	if (!mural->viewportValidated) {
-		crServerComputeViewportBounds(&(cr_server.curClient->currentCtx->viewport),
+		crServerComputeViewportBounds(&(cr_server.curClient->currentCtxInfo->pContext->viewport),
 																	mural);
 	}
@@ -292,5 +292,5 @@
 				{
 					mural->curExtent = p->id;
-					if (cr_server.run_queue->client->currentCtx) {
+					if (cr_server.run_queue->client->currentCtxInfo && cr_server.run_queue->client->currentCtxInfo->pContext) {
 						crServerSetOutputBounds( mural, mural->curExtent );
 					}
@@ -315,5 +315,5 @@
 			{
 				mural->curExtent = i;
-				if (cr_server.run_queue->client->currentCtx) {
+				if (cr_server.run_queue->client->currentCtxInfo && cr_server.run_queue->client->currentCtxInfo->pContext) {
 					crServerSetOutputBounds( mural, i );
 				}
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c	(revision 40691)
@@ -41,5 +41,5 @@
     cr_server.num_overlap_intens = 0;
     cr_server.overlap_intens = 0;
-    cr_server.SpuContext = 0;
+    crMemset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
 
     crMatrixInit(&cr_server.viewMatrix[0]);
@@ -219,5 +219,5 @@
                                             cr_server.tcpip_port,
                                             cr_server.mtu, 0);
-        newClient->currentCtx = cr_server.DummyContext;
+        newClient->currentCtxInfo = &cr_server.MainContextInfo;
         crServerAddToRunQueue(newClient);
 
@@ -293,5 +293,5 @@
                                             cr_server.tcpip_port,
                                             cr_server.mtu, 0);
-        newClient->currentCtx = cr_server.DummyContext;
+        newClient->currentCtxInfo = &cr_server.MainContextInfo;
         crServerAddToRunQueue(newClient);
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c	(revision 40691)
@@ -80,5 +80,5 @@
     list = TranslateListID( list );
 
-    if (cr_server.curClient->currentCtx->lists.mode == 0) {
+    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
         /* we're not compiling, so execute the list now */
         /* Issue the list as-is */
@@ -208,5 +208,5 @@
     }
 
-    if (cr_server.curClient->currentCtx->lists.mode == 0) {
+    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
         /* we're not compiling, so execute the list now */
         /* Issue the list as-is */
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c	(revision 40691)
@@ -109,8 +109,11 @@
 
 
-static void deleteContextCallback( void *data )
-{
-    CRContext *c = (CRContext *) data;
-    crStateDestroyContext(c);
+static void deleteContextInfoCallback( void *data )
+{
+    CRContextInfo *c = (CRContextInfo *) data;
+    crStateDestroyContext(c->pContext);
+    if (c->CreateInfo.pszDpyName)
+        crFree(c->CreateInfo.pszDpyName);
+    crFree(c);
 }
 
@@ -144,8 +147,7 @@
 
     /* Free all context info */
-    crFreeHashtable(cr_server.contextTable, deleteContextCallback);
+    crFreeHashtable(cr_server.contextTable, deleteContextInfoCallback);
 
     /* Free context/window creation info */
-    crFreeHashtable(cr_server.pContextCreateInfoTable, crServerCreateInfoDeleteCB);
     crFreeHashtable(cr_server.pWindowCreateInfoTable, crServerCreateInfoDeleteCB);
 
@@ -275,4 +277,16 @@
 #endif
 
+#ifndef DEBUG_misha
+    cr_server.bUseMultipleContexts = GL_FALSE;
+#else
+    cr_server.bUseMultipleContexts = GL_FALSE;
+#endif
+
+    if (cr_server.bUseMultipleContexts)
+    {
+        crInfo("Info: using multiple contexts!");
+        crDebug("Debug: using multiple contexts!");
+    }
+
     cr_server.firstCallCreateContext = GL_TRUE;
     cr_server.firstCallMakeCurrent = GL_TRUE;
@@ -298,7 +312,7 @@
      */
     cr_server.contextTable = crAllocHashtable();
-    cr_server.DummyContext = crStateCreateContext( &cr_server.limits,
+    cr_server.MainContextInfo.pContext = crStateCreateContext( &cr_server.limits,
                                                    CR_RGB_BIT | CR_DEPTH_BIT, NULL );
-    cr_server.curClient->currentCtx = cr_server.DummyContext;
+    cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
 
     crServerInitDispatch();
@@ -334,4 +348,16 @@
 #endif
 
+#ifndef DEBUG_misha
+    cr_server.bUseMultipleContexts = GL_FALSE;
+#else
+    cr_server.bUseMultipleContexts = GL_FALSE;
+#endif
+
+    if (cr_server.bUseMultipleContexts)
+    {
+        crInfo("Info: using multiple contexts!");
+        crDebug("Debug: using multiple contexts!");
+    }
+
     crNetInit(crServerRecv, crServerClose);
 
@@ -341,4 +367,5 @@
     cr_server.bIsInLoadingState = GL_FALSE;
     cr_server.bIsInSavingState  = GL_FALSE;
+
 
     cr_server.pCleanupClient = NULL;
@@ -367,7 +394,7 @@
      */
     cr_server.contextTable = crAllocHashtable();
-    cr_server.DummyContext = crStateCreateContext( &cr_server.limits,
+    cr_server.MainContextInfo.pContext = crStateCreateContext( &cr_server.limits,
                                                    CR_RGB_BIT | CR_DEPTH_BIT, NULL );
-    cr_server.pContextCreateInfoTable = crAllocHashtable();
+//    cr_server.pContextCreateInfoTable = crAllocHashtable();
     cr_server.pWindowCreateInfoTable = crAllocHashtable();
 
@@ -402,5 +429,5 @@
 
     newClient->spu_id = 0;
-    newClient->currentCtx = cr_server.DummyContext;
+    newClient->currentCtxInfo = &cr_server.MainContextInfo;
     newClient->currentContextNumber = -1;
     newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
@@ -686,5 +713,5 @@
 static void crVBoxServerSaveCreateInfoCB(unsigned long key, void *data1, void *data2)
 {
-    CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *) data1;
+    CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *)data1;
     PSSMHANDLE pSSM = (PSSMHANDLE) data2;
     int32_t rc;
@@ -705,4 +732,11 @@
 }
 
+static void crVBoxServerSaveCreateInfoFromCtxInfoCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
+    CRCreateInfo_t *pCreateInfo = &pContextInfo->CreateInfo;
+    crVBoxServerSaveCreateInfoCB(key, pCreateInfo, data2);
+}
+
 static void crVBoxServerSyncTextureCB(unsigned long key, void *data1, void *data2)
 {
@@ -716,5 +750,6 @@
 static void crVBoxServerSaveContextStateCB(unsigned long key, void *data1, void *data2)
 {
-    CRContext *pContext = (CRContext *) data1;
+    CRContextInfo *pContextInfo = (CRContextInfo *) data1;
+    CRContext *pContext = pContextInfo->pContext;
     PSSMHANDLE pSSM = (PSSMHANDLE) data2;
     int32_t rc;
@@ -732,5 +767,5 @@
     {
         unsigned long id;
-        if (!crHashtableGetDataKey(cr_server.contextTable, pContext, &id))
+        if (!crHashtableGetDataKey(cr_server.contextTable, pContextInfo, &id))
         {
             crWarning("No client id for server ctx %d", pContext->id);
@@ -786,8 +821,8 @@
 
     /* Save rendering contexts creation info */
-    ui32 = crHashtableNumElements(cr_server.pContextCreateInfoTable);
+    ui32 = crHashtableNumElements(cr_server.contextTable);
     rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
     AssertRCReturn(rc, rc);
-    crHashtableWalk(cr_server.pContextCreateInfoTable, crVBoxServerSaveCreateInfoCB, pSSM);
+    crHashtableWalk(cr_server.contextTable, crVBoxServerSaveCreateInfoFromCtxInfoCB, pSSM);
 
 #ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
@@ -855,7 +890,7 @@
             AssertRCReturn(rc, rc);
 
-            if (pClient->currentCtx && pClient->currentContextNumber>=0)
+            if (pClient->currentCtxInfo && pClient->currentCtxInfo->pContext && pClient->currentContextNumber>=0)
             {
-                b = crHashtableGetDataKey(cr_server.contextTable, pClient->currentCtx, &key);
+                b = crHashtableGetDataKey(cr_server.contextTable, pClient->currentCtxInfo, &key);
                 CRASSERT(b);
                 rc = SSMR3PutMem(pSSM, &key, sizeof(key));
@@ -878,4 +913,12 @@
 }
 
+static DECLCALLBACK(CRContext*) crVBoxServerGetContextCB(void* pvData)
+{
+    CRContextInfo* pContextInfo = (CRContextInfo*)pvData;
+    CRASSERT(pContextInfo);
+    CRASSERT(pContextInfo->pContext);
+    return pContextInfo->pContext;
+}
+
 DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version)
 {
@@ -915,4 +958,5 @@
         char psz[200];
         GLint ctxID;
+        CRContextInfo* pContextInfo;
         CRContext* pContext;
 
@@ -932,6 +976,8 @@
         CRASSERT((int64_t)ctxID == (int64_t)key);
 
-        pContext = (CRContext*) crHashtableSearch(cr_server.contextTable, key);
-        CRASSERT(pContext);
+        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
+        CRASSERT(pContextInfo);
+        CRASSERT(pContextInfo->pContext);
+        pContext = pContextInfo->pContext;
         pContext->shared->id=-1;
     }
@@ -940,4 +986,5 @@
     for (ui=0; ui<uiNumElems; ++ui)
     {
+        CRContextInfo* pContextInfo;
         CRContext *pContext;
 
@@ -945,8 +992,10 @@
         AssertRCReturn(rc, rc);
 
-        pContext = (CRContext*) crHashtableSearch(cr_server.contextTable, key);
-        CRASSERT(pContext);
-
-        rc = crStateLoadContext(pContext, cr_server.contextTable, pSSM);
+        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
+        CRASSERT(pContextInfo);
+        CRASSERT(pContextInfo->pContext);
+        pContext = pContextInfo->pContext;
+
+        rc = crStateLoadContext(pContext, cr_server.contextTable, crVBoxServerGetContextCB, pSSM);
         AssertRCReturn(rc, rc);
     }
@@ -1056,5 +1105,5 @@
 
             pClient->currentContextNumber = -1;
-            pClient->currentCtx = cr_server.DummyContext;
+            pClient->currentCtxInfo = &cr_server.MainContextInfo;
             pClient->currentMural = NULL;
             pClient->currentWindow = -1;
@@ -1062,10 +1111,11 @@
             cr_server.curClient = pClient;
 
-            if (client.currentCtx && client.currentContextNumber>=0)
+            if (client.currentCtxInfo && client.currentContextNumber>=0)
             {
                 rc = SSMR3GetMem(pSSM, &ctxID, sizeof(ctxID));
                 AssertRCReturn(rc, rc);
-                client.currentCtx = (CRContext*) crHashtableSearch(cr_server.contextTable, ctxID);
-                CRASSERT(client.currentCtx);
+                client.currentCtxInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, ctxID);
+                CRASSERT(client.currentCtxInfo);
+                CRASSERT(client.currentCtxInfo->pContext);
                 //pClient->currentCtx = client.currentCtx;
                 //pClient->currentContextNumber = ctxID;
@@ -1094,15 +1144,15 @@
             crServerDispatchMakeCurrent(winID, 0, ctxID);
 
-            crHashtableWalk(client.currentCtx->shared->textureTable, crVBoxServerSyncTextureCB, client.currentCtx);
-
-            crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.base1D, GL_TRUE);
-            crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.base2D, GL_TRUE);
-            crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.base3D, GL_TRUE);
+            crHashtableWalk(client.currentCtxInfo->pContext->shared->textureTable, crVBoxServerSyncTextureCB, client.currentCtxInfo->pContext);
+
+            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.base1D, GL_TRUE);
+            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.base2D, GL_TRUE);
+            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.base3D, GL_TRUE);
 #ifdef CR_ARB_texture_cube_map
-            crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.baseCubeMap, GL_TRUE);
+            crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.baseCubeMap, GL_TRUE);
 #endif
 #ifdef CR_NV_texture_rectangle
             //@todo this doesn't work as expected
-            //crStateTextureObjectDiff(client.currentCtx, NULL, NULL, &client.currentCtx->texture.baseRect, GL_TRUE);
+            //crStateTextureObjectDiff(client.currentCtxInfo->pContext, NULL, NULL, &client.currentCtxInfo->pContext->texture.baseRect, GL_TRUE);
 #endif
             /*cr_server.head_spu->dispatch_table.Materialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb);
@@ -1141,5 +1191,5 @@
                 tmpCtx = crStateCreateContext(NULL, createInfo->visualBits, NULL);
                 CRASSERT(tmpCtx);
-                crStateDiffContext(tmpCtx, client.currentCtx);
+                crStateDiffContext(tmpCtx, client.currentCtxInfo->pContext);
                 crStateDestroyContext(tmpCtx);*/
             }
@@ -1264,10 +1314,11 @@
         {
             cr_server.curClient = cr_server.clients[i];
-            if (cr_server.curClient->currentCtx
-                && (cr_server.curClient->currentCtx->buffer.pFrontImg || cr_server.curClient->currentCtx->buffer.pBackImg)
+            if (cr_server.curClient->currentCtxInfo
+                && cr_server.curClient->currentCtxInfo->pContext
+                && (cr_server.curClient->currentCtxInfo->pContext->buffer.pFrontImg || cr_server.curClient->currentCtxInfo->pContext->buffer.pBackImg)
                 && cr_server.curClient->currentMural
                 && cr_server.curClient->currentMural->screenId == sIndex
-                && cr_server.curClient->currentCtx->buffer.storedHeight == h
-                && cr_server.curClient->currentCtx->buffer.storedWidth == w)
+                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedHeight == h
+                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedWidth == w)
             {
                 int clientWindow = cr_server.curClient->currentWindow;
@@ -1279,5 +1330,5 @@
                 }
 
-                crStateApplyFBImage(cr_server.curClient->currentCtx);
+                crStateApplyFBImage(cr_server.curClient->currentCtxInfo->pContext);
             }
         }
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c	(revision 40691)
@@ -263,4 +263,5 @@
     if (pCreateInfo->pszDpyName)
         crFree(pCreateInfo->pszDpyName);
+    crFree(pCreateInfo);
 }
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.c	(revision 40691)
@@ -32,5 +32,5 @@
     else {
         /* we have a quad-buffered window and we're watching glDrawBuffer */
-        GLenum drawBuffer = cr_server.curClient->currentCtx->buffer.drawBuffer;
+        GLenum drawBuffer = cr_server.curClient->currentCtxInfo->pContext->buffer.drawBuffer;
         int eye = drawBuffer == GL_BACK_RIGHT || drawBuffer == GL_FRONT_RIGHT
             || drawBuffer == GL_RIGHT;
@@ -42,5 +42,5 @@
 void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixf( const GLfloat *m )
 {
-    const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
     const CRMuralInfo *mural = cr_server.curClient->currentMural;
 
@@ -59,5 +59,5 @@
 void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixd( const GLdouble *m )
 {
-    const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
     const CRMuralInfo *mural = cr_server.curClient->currentMural;
 
@@ -76,5 +76,5 @@
 void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixf( const GLfloat *m )
 {
-    const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
 
     if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
@@ -93,5 +93,5 @@
 void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixd( const GLdouble *m )
 {
-    const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
 
     if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
@@ -111,5 +111,5 @@
 void SERVER_DISPATCH_APIENTRY crServerDispatchLoadIdentity( void )
 {
-    const GLenum matMode = cr_server.curClient->currentCtx->transform.matrixMode;
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
     const CRMuralInfo *mural = cr_server.curClient->currentMural;
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c	(revision 40691)
@@ -26,5 +26,5 @@
                                                                                  cr_server.mtu, 1 );
 
-        newClient->currentCtx = cr_server.DummyContext;
+        newClient->currentCtxInfo = &cr_server.MainContextInfo;
 
         /* add to array */
@@ -293,8 +293,9 @@
 crServerClientInBeginEnd(const CRClient *client)
 {
-    if (client->currentCtx &&
-            (client->currentCtx->lists.currentIndex != 0 ||
-             client->currentCtx->current.inBeginEnd ||
-             client->currentCtx->occlusion.currentQueryObject)) {
+    if (client->currentCtxInfo
+            && client->currentCtxInfo->pContext
+            && (client->currentCtxInfo->pContext->lists.currentIndex != 0 ||
+             client->currentCtxInfo->pContext->current.inBeginEnd ||
+             client->currentCtxInfo->pContext->occlusion.currentQueryObject)) {
         return GL_TRUE;
     }
@@ -543,5 +544,6 @@
              int clientWindow = cr_server.curClient->currentWindow;
              int clientContext = cr_server.curClient->currentContextNumber;
-             if (clientWindow && clientWindow != cr_server.currentWindow) {
+             CRContextInfo *clientCtxInfo = cr_server.curClient->currentCtxInfo;
+             if (clientCtxInfo != cr_server.currentCtxInfo) {
                  crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
                  /*
@@ -550,6 +552,4 @@
              }
         }
-
-        crStateMakeCurrent( cr_server.curClient->currentCtx );
 #endif
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.c	(revision 40691)
@@ -240,5 +240,5 @@
 	}
 	else
-		projMatrix = cr_server.curClient->currentCtx->transform.projectionStack.top;
+		projMatrix = cr_server.curClient->currentCtxInfo->pContext->transform.projectionStack.top;
 
 	cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
@@ -254,5 +254,5 @@
 crServerApplyViewMatrix(const CRmatrix *view)
 {
-	const CRmatrix *modelview = cr_server.curClient->currentCtx->transform.modelViewStack.top;
+	const CRmatrix *modelview = cr_server.curClient->currentCtxInfo->pContext->transform.modelViewStack.top;
 
 	cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 40691)
@@ -350,5 +350,5 @@
 }
 
-static void
+void
 RENDER_APIENTRY renderspuWindowDestroy( GLint win )
 {
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 40691)
@@ -60,5 +60,5 @@
     const char *displayName;
 #if defined(WINDOWS)
-    HDC device_context;
+//    HDC device_context;
 #elif defined(DARWIN)
 # ifndef VBOX_WITH_COCOA_QT
@@ -317,4 +317,5 @@
 
 extern GLint RENDER_APIENTRY renderspuWindowCreate( const char *dpyName, GLint visBits );
+void RENDER_APIENTRY renderspuWindowDestroy( GLint win );
 extern GLint RENDER_APIENTRY renderspuCreateContext( const char *dpyname, GLint visBits, GLint shareCtx );
 extern void RENDER_APIENTRY renderspuMakeCurrent(GLint crWindow, GLint nativeWindow, GLint ctx);
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c	(revision 40690)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c	(revision 40691)
@@ -387,5 +387,4 @@
     /* In the windows world, we need a window before a context.
      * Use the device_context as a marker to do just that */
-    visual->device_context = 0;
 
     return TRUE;
@@ -1163,4 +1162,49 @@
 }
 
+static GLboolean renderspuChkActivateSharedContext(ContextInfo *sharedContext)
+{
+    GLint crWindow;
+    WindowInfo *window;
+
+    if (sharedContext->hRC)
+        return GL_TRUE;
+
+    CRASSERT(sharedContext->id);
+
+    if (sharedContext->shared)
+        renderspuChkActivateSharedContext(sharedContext->shared);
+
+    crWindow = renderspuWindowCreate(sharedContext->visual->displayName, sharedContext->visual->visAttribs);
+    if (!crWindow)
+    {
+        crError("renderspuChkActivateSharedContext: renderspuWindowCreate failed!");
+        return GL_FALSE;
+    }
+
+    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, crWindow);
+    if (!window)
+    {
+        crError("renderspuChkActivateSharedContext: crHashtableSearch failed!");
+        renderspuWindowDestroy(crWindow);
+        return GL_FALSE;
+    }
+
+    CRASSERT(window->device_context);
+
+    crDebug( "Render SPU: renderspuChkActivateSharedContext: made the DC: 0x%x", window->device_context );
+
+    sharedContext->hRC = render_spu.ws.wglCreateContext(window->device_context);
+    if (!sharedContext->hRC)
+    {
+        crError( "Render SPU: (renderspuChkActivateSharedContext) Couldn't create the context for the window (error 0x%x)", GetLastError() );
+        renderspuWindowDestroy(crWindow);
+        return GL_FALSE;
+    }
+
+    sharedContext->currentWindow = window;
+
+    return GL_TRUE;
+}
+
 void renderspu_SystemMakeCurrent( WindowInfo *window, GLint nativeWindow, ContextInfo *context )
 {
@@ -1197,4 +1241,10 @@
              * the HDC values between processes.. FIXME!
              */
+            if (context->shared)
+            {
+                /* first make sure we have shared context created */
+                renderspuChkActivateSharedContext(context->shared);
+            }
+
             window->nativeWindow = (HDC) nativeWindow;
             if (context->hRC == 0) {
@@ -1205,24 +1255,36 @@
                 }
             }
+
+            if (context->shared
+                    && context->shared->hRC
+                    && context->hRC)
+            {
+                /* share lists */
+                render_spu.ws.wglShareLists(context->shared->hRC, context->hRC);
+            }
+
             render_spu.ws.wglMakeCurrent( window->nativeWindow, context->hRC );
         }
         else
         {
-            if (!context->visual->device_context) {
-                context->visual->device_context = GetDC( window->hWnd );
-
-                crDebug( "Render SPU: MakeCurrent made the DC: 0x%x", context->visual->device_context );
-
-                if ( !bSetupPixelFormat( context->visual->device_context, context->visual->visAttribs ) )
+            if (!context->hRC) {
+                if (context->shared)
                 {
-                    crError( "Render SPU: (MakeCurrent) Couldn't set up the device context!  Yikes!" );
+                    /* first make sure we have shared context created */
+                    renderspuChkActivateSharedContext(context->shared);
                 }
-            }
-
-            if (!context->hRC) {
-                context->hRC = render_spu.ws.wglCreateContext(context->visual->device_context);
+
+                context->hRC = render_spu.ws.wglCreateContext(window->device_context);
                 if (!context->hRC)
                 {
                     crError( "Render SPU: (MakeCurrent) Couldn't create the context for the window (error 0x%x)", GetLastError() );
+                }
+
+                if (context->shared
+                        && context->shared->hRC
+                        && context->hRC)
+                {
+                    /* share lists */
+                    render_spu.ws.wglShareLists(context->shared->hRC, context->hRC);
                 }
 
