graw: Export graw_save_surface_to_file().
[mesa.git] / src / gallium / include / state_tracker / graw.h
1 /**************************************************************************
2 *
3 * Copyright 2010 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef GALLIUM_RAW_H
29 #define GALLIUM_RAW_H
30
31 /* This is an API for exercising gallium functionality in a
32 * platform-neutral fashion. Whatever platform integration is
33 * necessary to implement this interface is orchestrated by the
34 * individual target building this entity.
35 *
36 * For instance, the graw-xlib target includes code to implent these
37 * interfaces on top of the X window system.
38 *
39 * Programs using this interface may additionally benefit from some of
40 * the utilities currently in the libgallium.a library, especially
41 * those for parsing text representations of TGSI shaders.
42 */
43
44 #include "pipe/p_compiler.h"
45 #include "pipe/p_format.h"
46
47 struct pipe_screen;
48 struct pipe_context;
49
50 /* Returns a handle to be used with flush_frontbuffer()/present().
51 *
52 * Query format support with screen::is_format_supported and usage
53 * XXX.
54 */
55 PUBLIC struct pipe_screen *graw_create_window_and_screen( int x,
56 int y,
57 unsigned width,
58 unsigned height,
59 enum pipe_format format,
60 void **handle);
61
62 PUBLIC void graw_set_display_func( void (*func)( void ) );
63 PUBLIC void graw_main_loop( void );
64
65 PUBLIC void *graw_parse_geometry_shader( struct pipe_context *pipe,
66 const char *text );
67
68 PUBLIC void *graw_parse_vertex_shader( struct pipe_context *pipe,
69 const char *text );
70
71 PUBLIC void *graw_parse_fragment_shader( struct pipe_context *pipe,
72 const char *text );
73
74 /* Parse a single command-line option, if any. Options include:
75 *
76 * -o <filename>
77 *
78 * If an option has been successfully parsed, argi is updated
79 * to point just after the option and return TRUE.
80 */
81 PUBLIC boolean graw_parse_args(int *argi, int argc, char *argv[]);
82
83 /* Saves surface contents to a file.
84 *
85 * If filename is NULL, the filename provided with the `-o' option
86 * is used. If the option has not been specified, the surface
87 * will not be saved.
88 *
89 * Returns TRUE if the surface has been saved.
90 */
91 PUBLIC boolean graw_save_surface_to_file(struct pipe_context *pipe,
92 struct pipe_surface *surface,
93 const char *filename);
94
95 #endif