wgl: Ensure we only create framebuffers for HDC associated with a window.
authorJosé Fonseca <jfonseca@vmware.com>
Sun, 31 May 2009 18:10:22 +0000 (11:10 -0700)
committerJosé Fonseca <jfonseca@vmware.com>
Sun, 31 May 2009 18:10:22 +0000 (11:10 -0700)
src/gallium/state_trackers/wgl/shared/stw_framebuffer.c

index 45ac3477e82d9521597582bd6fb24a2b856ca15f..030a155f54a4ce10776bff9ff4f580ec7ab47980 100644 (file)
@@ -102,15 +102,21 @@ stw_framebuffer_create_locked(
    HDC hdc,
    int iPixelFormat )
 {
+   HWND hWnd;
    struct stw_framebuffer *fb;
    const struct stw_pixelformat_info *pfi;
 
+   /* We only support drawing to a window. */
+   hWnd = WindowFromDC( hdc );
+   if(!hWnd)
+      return NULL;
+   
    fb = CALLOC_STRUCT( stw_framebuffer );
    if (fb == NULL)
       return NULL;
 
    fb->hDC = hdc;
-   fb->hWnd = WindowFromDC( hdc );
+   fb->hWnd = hWnd;
    fb->iPixelFormat = iPixelFormat;
 
    fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );