graw: fix logic error in pixel format selection
[mesa.git] / src / gallium / tests / graw / gs-test.c
index 812666a8c84a09cca0efe6ba047d14247fdb3d8a..0c65390e109c171a29696b2a228a985fb66951dd 100644 (file)
@@ -497,15 +497,18 @@ 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,WIDTH,HEIGHT,
+   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);
+   }
+
    ctx = screen->context_create(screen, NULL);
    if (ctx == NULL)
       exit(3);