From 7375d7a5c9d5c32fd6bdde0cc8cab8fe41415964 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 14 May 2010 12:07:38 +0100 Subject: graw: move towards glut-like interface, add tri.c --- src/gallium/tests/graw/SConscript | 3 +- src/gallium/tests/graw/clear.c | 69 ++++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 27 deletions(-) (limited to 'src/gallium/tests') diff --git a/src/gallium/tests/graw/SConscript b/src/gallium/tests/graw/SConscript index 8a92ac2c49..1dc8dca381 100644 --- a/src/gallium/tests/graw/SConscript +++ b/src/gallium/tests/graw/SConscript @@ -12,7 +12,8 @@ env.Prepend(LIBPATH = [graw.dir]) env.Prepend(LIBS = ['graw']) progs = [ - 'clear' + 'clear', + 'tri' ] for prog in progs: diff --git a/src/gallium/tests/graw/clear.c b/src/gallium/tests/graw/clear.c index 84dd780733..adcbb08308 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; } -- cgit v1.2.3