wgl: Enforce a minimum 1x1 framebuffer size.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 6 May 2009 18:58:08 +0000 (19:58 +0100)
committerKeith Whitwell <keithw@vmware.com>
Fri, 8 May 2009 13:57:29 +0000 (14:57 +0100)
src/gallium/state_trackers/wgl/shared/stw_context.c

index d532b1563b871ae22804101326df77ffe276287a..b61f74f69b6b61eae19afc856cc30149f61f7af2 100644 (file)
@@ -278,19 +278,30 @@ stw_release_context(
 /* Find the width and height of the window named by hdc.
  */
 static void
-stw_get_window_size( HDC hdc, GLuint *width, GLuint *height )
+stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight )
 {
-   if (WindowFromDC( hdc )) {
-      RECT rect;
+   GLuint width, height;
+   HWND hwnd;
 
-      GetClientRect( WindowFromDC( hdc ), &rect );
-      *width = rect.right - rect.left;
-      *height = rect.bottom - rect.top;
+   hwnd = WindowFromDC( hdc );
+   if (hwnd) {
+      RECT rect;
+      GetClientRect( hwnd, &rect );
+      width = rect.right - rect.left;
+      height = rect.bottom - rect.top;
    }
    else {
-      *width = GetDeviceCaps( hdc, HORZRES );
-      *height = GetDeviceCaps( hdc, VERTRES );
+      width = GetDeviceCaps( hdc, HORZRES );
+      height = GetDeviceCaps( hdc, VERTRES );
    }
+
+   if(width < 1)
+      width = 1;
+   if(height < 1)
+      height = 1;
+
+   *pwidth = width; 
+   *pheight = height; 
 }
 
 UINT_PTR