summaryrefslogtreecommitdiffstats
path: root/src/gallium/tests/graw/tri-gs.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-01-20 13:32:35 -0700
committerBrian Paul <[email protected]>2011-01-20 13:37:26 -0700
commit4ef955a12a526dcad388133b6dc8426a51054cdd (patch)
treee76e5fa219a1d7cef0d20bacef102a56979ad951 /src/gallium/tests/graw/tri-gs.c
parent22eeb1b331767abb29d03be2f11cfe9d8626c440 (diff)
graw: fix logic error in pixel format selection
The loop to choose a pixel format for the window was incrementing 'i' after we succeeded in creating the window so if we chose format[0] for graw_create_window_and_screen() we were putting format[1] in the pipe_resource template for creating the render target. This only worked because of the order of the elements in the formats[] array. The graw_xlib.c code now properly compares the requested gallium pixel format against the visual's color layout. Update all the graw demos to fix the off-by-one-i error.
Diffstat (limited to 'src/gallium/tests/graw/tri-gs.c')
-rw-r--r--src/gallium/tests/graw/tri-gs.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c
index 84ff3e67735..a1a00b32098 100644
--- a/src/gallium/tests/graw/tri-gs.c
+++ b/src/gallium/tests/graw/tri-gs.c
@@ -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"
@@ -182,13 +183,16 @@ 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);
}
ctx = screen->context_create(screen, NULL);