wgl: Protect the framebuffer with a lock.
[mesa.git] / src / gallium / state_trackers / wgl / shared / stw_context.c
index f7098198c0ed4a7ac291bb14ba2e5dbb389a1536..f3c7af93f503aa99e97c33da1e99f04277b5828a 100644 (file)
@@ -109,21 +109,21 @@ stw_create_layer_context(
    /* Create visual based on flags
     */
    visual = _mesa_create_visual(
-      GL_TRUE,
-      (pf->flags & STW_PF_FLAG_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
-      GL_FALSE,
-      pf->color.redbits,
-      pf->color.greenbits,
-      pf->color.bluebits,
-      pf->color.alphabits,
-      0,
-      pf->depth.depthbits,
-      pf->depth.stencilbits,
-      0,
-      0,
-      0,
-      0,
-      (pf->flags & STW_PF_FLAG_MULTISAMPLED) ? stw_query_samples() : 0 );
+      (pf->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
+      (pf->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
+      (pf->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
+      pf->pfd.cRedBits,
+      pf->pfd.cGreenBits,
+      pf->pfd.cBlueBits,
+      pf->pfd.cAlphaBits,
+      (pf->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pf->pfd.cColorBits : 0,
+      pf->pfd.cDepthBits,
+      pf->pfd.cStencilBits,
+      pf->pfd.cAccumRedBits,
+      pf->pfd.cAccumGreenBits,
+      pf->pfd.cAccumBlueBits,
+      pf->pfd.cAccumAlphaBits,
+      pf->numSamples );
    if (visual == NULL) 
       goto fail;
 
@@ -153,6 +153,7 @@ stw_create_layer_context(
       goto fail;
 
    ctx->st->ctx->DriverCtx = ctx;
+   ctx->pfi = pf;
 
    pipe_mutex_lock( stw_dev->mutex );
    hglrc = handle_table_add(stw_dev->ctx_table, ctx);
@@ -330,14 +331,17 @@ stw_make_current(
    if (fb == NULL && ctx != NULL && hdc != NULL) {
       GLvisual *visual = &ctx->st->ctx->Visual;
 
-      fb = stw_framebuffer_create( hdc, visual, width, height );
+      fb = stw_framebuffer_create( hdc, visual, ctx->pfi, width, height );
       if (fb == NULL)
          return FALSE;
    }
 
    if (ctx && fb) {
+      pipe_mutex_lock( fb->mutex );
       st_make_current( ctx->st, fb->stfb, fb->stfb );
-      stw_framebuffer_resize( fb, width, height );
+      st_resize_framebuffer( fb->stfb, width, height );
+      pipe_mutex_unlock( fb->mutex );
+
       ctx->hdc = hdc;
       ctx->st->pipe->priv = hdc;
    }