added do /while to multi-line macros
[mesa.git] / include / GL / osmesa.h
1 /* $Id: osmesa.h,v 1.3 2000/01/15 06:12:18 rjfrank Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 /*
29 * Mesa Off-Screen rendering interface.
30 *
31 * This is an operating system and window system independent interface to
32 * Mesa which allows one to render images into a client-supplied buffer in
33 * main memory. Such images may manipulated or saved in whatever way the
34 * client wants.
35 *
36 * These are the API functions:
37 * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
38 * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
39 * and make the specified context the current one.
40 * OSMesaDestroyContext - destroy an OSMesaContext
41 * OSMesaGetCurrentContext - return thread's current context ID
42 * OSMesaPixelStore - controls how pixels are stored in image buffer
43 * OSMesaGetIntegerv - return OSMesa state parameters
44 *
45 *
46 * The limits on the width and height of an image buffer are MAX_WIDTH and
47 * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024.
48 * You can increase them as needed but beware that many temporary arrays in
49 * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
50 */
51
52
53
54 #ifndef OSMESA_H
55 #define OSMESA_H
56
57
58
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62
63
64 #include "GL/gl.h"
65
66
67
68 #define OSMESA_MAJOR_VERSION 3
69 #define OSMESA_MINOR_VERSION 3
70
71
72
73 /*
74 * Values for the format parameter of OSMesaCreateContext()
75 * New in version 2.0.
76 */
77 #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
78 #define OSMESA_RGBA GL_RGBA
79 #define OSMESA_BGRA 0x1
80 #define OSMESA_ARGB 0x2
81 #define OSMESA_RGB GL_RGB
82 #define OSMESA_BGR 0x4
83
84
85 /*
86 * OSMesaPixelStore() parameters:
87 * New in version 2.0.
88 */
89 #define OSMESA_ROW_LENGTH 0x10
90 #define OSMESA_Y_UP 0x11
91
92
93 /*
94 * Accepted by OSMesaGetIntegerv:
95 */
96 #define OSMESA_WIDTH 0x20
97 #define OSMESA_HEIGHT 0x21
98 #define OSMESA_FORMAT 0x22
99 #define OSMESA_TYPE 0x23
100
101 /*
102 * Accepted by OSMesaGetBooleanv:
103 * New in version 3.3
104 */
105 /* This is based on the HP proposed extension */
106 #define OSMESA_OCCLUSION_TEST_RESULT_HP 0x30
107
108
109
110 typedef struct osmesa_context *OSMesaContext;
111
112
113 #if defined(__BEOS__) || defined(__QUICKDRAW__)
114 #pragma export on
115 #endif
116
117
118 /*
119 * Create an Off-Screen Mesa rendering context. The only attribute needed is
120 * an RGBA vs Color-Index mode flag.
121 *
122 * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
123 * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
124 * sharelist - specifies another OSMesaContext with which to share
125 * display lists. NULL indicates no sharing.
126 * Return: an OSMesaContext or 0 if error
127 */
128 GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContext( GLenum format,
129 OSMesaContext sharelist );
130
131
132
133
134 /*
135 * Destroy an Off-Screen Mesa rendering context.
136 *
137 * Input: ctx - the context to destroy
138 */
139 GLAPI void GLAPIENTRY OSMesaDestroyContext( OSMesaContext ctx );
140
141
142
143 /*
144 * Bind an OSMesaContext to an image buffer. The image buffer is just a
145 * block of memory which the client provides. Its size must be at least
146 * as large as width*height*sizeof(type). Its address should be a multiple
147 * of 4 if using RGBA mode.
148 *
149 * Image data is stored in the order of glDrawPixels: row-major order
150 * with the lower-left image pixel stored in the first array position
151 * (ie. bottom-to-top).
152 *
153 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
154 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
155 * value. If the context is in color indexed mode, each pixel will be
156 * stored as a 1-byte value.
157 *
158 * If the context's viewport hasn't been initialized yet, it will now be
159 * initialized to (0,0,width,height).
160 *
161 * Input: ctx - the rendering context
162 * buffer - the image buffer memory
163 * type - data type for pixel components, only GL_UNSIGNED_BYTE
164 * supported now
165 * width, height - size of image buffer in pixels, at least 1
166 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
167 * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
168 * width>internal limit or height>internal limit.
169 */
170 GLAPI GLboolean GLAPIENTRY OSMesaMakeCurrent( OSMesaContext ctx,
171 void *buffer, GLenum type,
172 GLsizei width, GLsizei height );
173
174
175
176
177 /*
178 * Return the current Off-Screen Mesa rendering context handle.
179 */
180 GLAPI OSMesaContext GLAPIENTRY OSMesaGetCurrentContext( void );
181
182
183
184 /*
185 * Set pixel store/packing parameters for the current context.
186 * This is similar to glPixelStore.
187 * Input: pname - OSMESA_ROW_LENGTH
188 * specify actual pixels per row in image buffer
189 * 0 = same as image width (default)
190 * OSMESA_Y_UP
191 * zero = Y coordinates increase downward
192 * non-zero = Y coordinates increase upward (default)
193 * value - the value for the parameter pname
194 *
195 * New in version 2.0.
196 */
197 GLAPI void GLAPIENTRY OSMesaPixelStore( GLint pname, GLint value );
198
199
200
201 /*
202 * Return context info. This is like glGetIntegerv.
203 * Input: pname -
204 * OSMESA_WIDTH return current image width
205 * OSMESA_HEIGHT return current image height
206 * OSMESA_FORMAT return image format
207 * OSMESA_TYPE return color component data type
208 * OSMESA_ROW_LENGTH return row length in pixels
209 * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
210 * value - pointer to integer in which to return result.
211 */
212 GLAPI void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value );
213
214 /*
215 * Return context info. This is like glGetBooleanv.
216 * Input: pname -
217 * OSMESA_OCCLUSION_TEST_RESULT_HP return current test result
218 * value - pointer to boolean in which to return result.
219 */
220 GLAPI void GLAPIENTRY OSMesaGetBooleanv( GLint pname, GLboolean *value );
221
222 /*
223 * Return the depth buffer associated with an OSMesa context.
224 * Input: c - the OSMesa context
225 * Output: width, height - size of buffer in pixels
226 * bytesPerValue - bytes per depth value (2 or 4)
227 * buffer - pointer to depth buffer values
228 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
229 *
230 * New in Mesa 2.4.
231 */
232 GLAPI GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c,
233 GLint *width, GLint *height,
234 GLint *bytesPerValue, void **buffer );
235
236
237
238
239 #if defined(__BEOS__) || defined(__QUICKDRAW__)
240 #pragma export off
241 #endif
242
243
244 #ifdef __cplusplus
245 }
246 #endif
247
248
249 #endif