5939a5acd3ca8ede3e67a44d807810be953eacaf
[mesa.git] / src / gallium / targets / graw-null / graw_null.c
1 #include "pipe/p_compiler.h"
2 #include "util/u_debug.h"
3 #include "util/u_memory.h"
4 #include "target-helpers/wrap_screen.h"
5 #include "sw/null/null_sw_winsys.h"
6 #include "os/os_time.h"
7 #include "state_tracker/graw.h"
8
9 #ifdef GALLIUM_SOFTPIPE
10 #include "softpipe/sp_public.h"
11 #endif
12
13 #ifdef GALLIUM_LLVMPIPE
14 #include "llvmpipe/lp_public.h"
15 #endif
16
17 /* Haven't figured out a decent way to build the helper code yet -
18 * #include it here temporarily.
19 */
20 #include "sw/sw_public.h"
21 #include "sw/sw.c"
22
23 #include <stdio.h>
24
25
26 static struct {
27 void (*draw)(void);
28 } graw;
29
30
31
32 struct pipe_screen *
33 graw_create_window_and_screen( int x,
34 int y,
35 unsigned width,
36 unsigned height,
37 enum pipe_format format,
38 void **handle)
39 {
40 const char *default_driver;
41 const char *driver;
42 struct pipe_screen *screen = NULL;
43 struct sw_winsys *winsys = NULL;
44 static int dummy;
45
46
47 /* Create the underlying winsys, which performs presents to Xlib
48 * drawables:
49 */
50 winsys = null_sw_create();
51 if (winsys == NULL)
52 return NULL;
53
54 #if defined(GALLIUM_LLVMPIPE)
55 default_driver = "llvmpipe";
56 #elif defined(GALLIUM_SOFTPIPE)
57 default_driver = "softpipe";
58 #else
59 default_driver = "";
60 #endif
61
62 driver = debug_get_option("GALLIUM_DRIVER", default_driver);
63
64 #if defined(GALLIUM_LLVMPIPE)
65 if (screen == NULL && strcmp(driver, "llvmpipe") == 0)
66 screen = llvmpipe_create_screen( winsys );
67 #endif
68
69 #if defined(GALLIUM_SOFTPIPE)
70 if (screen == NULL)
71 screen = softpipe_create_screen( winsys );
72 #endif
73
74 *handle = &dummy;
75
76 /* Inject any wrapping layers we want to here:
77 */
78 return gallium_wrap_screen( screen );
79 }
80
81
82
83 void
84 graw_set_display_func( void (*draw)( void ) )
85 {
86 graw.draw = draw;
87 }
88
89
90 void
91 graw_main_loop( void )
92 {
93 graw.draw();
94 os_time_sleep(100000);
95 }