1 /* Display a cleared blue window. This demo has no dependencies on
2 * any utility code, just the graw interface and gallium.
5 #include "state_tracker/graw.h"
6 #include "pipe/p_screen.h"
7 #include "pipe/p_context.h"
8 #include "pipe/p_state.h"
9 #include "pipe/p_defines.h"
10 #include <unistd.h> /* for sleep() */
12 #include "util/u_debug.h" /* debug_dump_surface_bmp() */
14 enum pipe_format formats
[] = {
15 PIPE_FORMAT_R8G8B8A8_UNORM
,
16 PIPE_FORMAT_B8G8R8A8_UNORM
,
20 static const int WIDTH
= 300;
21 static const int HEIGHT
= 300;
23 int main( int argc
, char *argv
[] )
25 struct pipe_screen
*screen
;
26 struct pipe_context
*pipe
;
27 struct pipe_surface
*surf
;
28 struct pipe_framebuffer_state fb
;
29 struct pipe_texture
*tex
, templat
;
31 float clear_color
[4] = {1,0,1,1};
39 window
== NULL
&& formats
[i
] != PIPE_FORMAT_NONE
;
42 window
= graw_create_window(0,0,300,300, formats
[i
]);
48 pipe
= screen
->context_create(screen
, NULL
);
52 templat
.target
= PIPE_TEXTURE_2D
;
53 templat
.format
= formats
[i
];
54 templat
.width0
= WIDTH
;
55 templat
.height0
= HEIGHT
;
57 templat
.last_level
= 0;
58 templat
.nr_samples
= 1;
59 templat
.tex_usage
= (PIPE_TEXTURE_USAGE_RENDER_TARGET
|
60 PIPE_TEXTURE_USAGE_DISPLAY_TARGET
);
62 tex
= screen
->texture_create(screen
,
67 surf
= screen
->get_tex_surface(screen
, tex
, 0, 0, 0,
68 PIPE_TEXTURE_USAGE_RENDER_TARGET
|
69 PIPE_TEXTURE_USAGE_DISPLAY_TARGET
);
73 memset(&fb
, 0, sizeof fb
);
79 pipe
->set_framebuffer_state(pipe
, &fb
);
80 pipe
->clear(pipe
, PIPE_CLEAR_COLOR
, clear_color
, 0, 0);
81 pipe
->flush(pipe
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
83 /* At the moment, libgraw includes/makes available all the symbols
84 * from gallium/auxiliary, including these debug helpers. Will
85 * eventually want to bless some of these paths, and lock the
86 * others down so they aren't accessible from test programs.
89 debug_dump_surface_bmp(pipe
, "result.bmp", surf
);
91 screen
->flush_frontbuffer(screen
, surf
, window
);