graw: fix logic error in pixel format selection
[mesa.git] / src / gallium / tests / graw / clear.c
index 1ff80cadeec3f534e571b143d49aa38127dfe542..55cc0087a09eee838e96c894f6fae23a62496a75 100644 (file)
@@ -2,6 +2,7 @@
  * any utility code, just the graw interface and gallium.
  */
 
+#include <stdio.h>
 #include "state_tracker/graw.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_context.h"
@@ -48,16 +49,17 @@ static void init( void )
     * Also, no easy way of querying supported formats if the screen
     * cannot be created first.
     */
-   for (i = 0; 
-        window == NULL && formats[i] != PIPE_FORMAT_NONE;
-        i++) {
-      
-      screen = graw_create_window_and_screen(0,0,300,300,
+   for (i = 0; formats[i] != PIPE_FORMAT_NONE; i++) {
+      screen = graw_create_window_and_screen(0, 0, 300, 300,
                                              formats[i],
                                              &window);
+      if (window && screen)
+         break;
+   }
+   if (!screen || !window) {
+      fprintf(stderr, "Unable to create window\n");
+      exit(1);
    }
-   if (window == NULL)
-      exit(2);
    
    ctx = screen->context_create(screen, NULL);
    if (ctx == NULL)