diff options
Diffstat (limited to 'src/gallium/tests/graw/clear.c')
-rw-r--r-- | src/gallium/tests/graw/clear.c | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/src/gallium/tests/graw/clear.c b/src/gallium/tests/graw/clear.c index 84dd7807337..adcbb08308f 100644 --- a/src/gallium/tests/graw/clear.c +++ b/src/gallium/tests/graw/clear.c @@ -20,21 +20,39 @@ enum pipe_format formats[] = { static const int WIDTH = 300; static const int HEIGHT = 300; -int main( int argc, char *argv[] ) +struct pipe_screen *screen; +struct pipe_context *ctx; +struct pipe_surface *surf; +static void *window = NULL; + +static void draw( void ) +{ + float clear_color[4] = {1,0,1,1}; + + ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0); + ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); + +#if 0 + /* At the moment, libgraw leaks out/makes available some of the + * symbols from gallium/auxiliary, including these debug helpers. + * Will eventually want to bless some of these paths, and lock the + * others down so they aren't accessible from test programs. + * + * This currently just happens to work on debug builds - a release + * build will probably fail to link here: + */ + debug_dump_surface_bmp(ctx, "result.bmp", surf); +#endif + + screen->flush_frontbuffer(screen, surf, window); +} + +static void init( void ) { - struct pipe_screen *screen; - struct pipe_context *pipe; - struct pipe_surface *surf; struct pipe_framebuffer_state fb; struct pipe_resource *tex, templat; - void *window = NULL; - float clear_color[4] = {1,0,1,1}; int i; - screen = graw_init(); - if (screen == NULL) - exit(1); - for (i = 0; window == NULL && formats[i] != PIPE_FORMAT_NONE; i++) { @@ -45,8 +63,8 @@ int main( int argc, char *argv[] ) if (window == NULL) exit(2); - pipe = screen->context_create(screen, NULL); - if (pipe == NULL) + ctx = screen->context_create(screen, NULL); + if (ctx == NULL) exit(3); templat.target = PIPE_TEXTURE_2D; @@ -57,10 +75,10 @@ int main( int argc, char *argv[] ) templat.last_level = 0; templat.nr_samples = 1; templat.bind = (PIPE_BIND_RENDER_TARGET | - PIPE_BIND_DISPLAY_TARGET); + PIPE_BIND_DISPLAY_TARGET); tex = screen->resource_create(screen, - &templat); + &templat); if (tex == NULL) exit(4); @@ -76,21 +94,20 @@ int main( int argc, char *argv[] ) fb.height = HEIGHT; fb.cbufs[0] = surf; - pipe->set_framebuffer_state(pipe, &fb); - pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0, 0); - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->set_framebuffer_state(ctx, &fb); +} - /* At the moment, libgraw includes/makes available all the symbols - * from gallium/auxiliary, including these debug helpers. Will - * eventually want to bless some of these paths, and lock the - * others down so they aren't accessible from test programs. - */ - if (0) - debug_dump_surface_bmp(pipe, "result.bmp", surf); - screen->flush_frontbuffer(screen, surf, window); +int main( int argc, char *argv[] ) +{ + screen = graw_init(); + if (screen == NULL) + exit(1); + + init(); - os_time_sleep(100*1000*100); + graw_set_display_func( draw ); + graw_main_loop(); return 0; } |