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/targets/graw-xlib/graw_xlib.c | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/gallium/targets/graw-xlib/graw_xlib.c') diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c index 21715c26fd..d0e3e4bdd6 100644 --- a/src/gallium/targets/graw-xlib/graw_xlib.c +++ b/src/gallium/targets/graw-xlib/graw_xlib.c @@ -1,6 +1,8 @@ #include "pipe/p_compiler.h" +#include "pipe/p_context.h" #include "util/u_debug.h" #include "util/u_memory.h" +#include "tgsi/tgsi_text.h" #include "target-helpers/wrap_screen.h" #include "state_tracker/xlib_sw_winsys.h" @@ -27,6 +29,7 @@ static struct { Display *display; + void (*draw)(void); } graw; @@ -179,3 +182,49 @@ graw_destroy_window( void *xlib_drawable ) { } +void +graw_set_display_func( void (*draw)( void ) ) +{ + graw.draw = draw; +} + +void +graw_main_loop( void ) +{ + int i; + for (i = 0; i < 10; i++) { + graw.draw(); + sleep(1); + } +} + + + +/* Helper functions. These are the same for all graw implementations. + */ +void *graw_parse_vertex_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_vs_state(pipe, &state); +} + +void *graw_parse_fragment_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_fs_state(pipe, &state); +} + -- cgit v1.2.3