1 | /*
|
---|
2 | * Mesa 3-D graphics library
|
---|
3 | *
|
---|
4 | * Copyright (C) 1999-2005 Brian Paul 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 "Software"),
|
---|
8 | * to deal in the Software without restriction, including without limitation
|
---|
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
10 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
11 | * Software is furnished to do so, subject to the following conditions:
|
---|
12 | *
|
---|
13 | * The above copyright notice and this permission notice shall be included
|
---|
14 | * in all copies or substantial portions of the Software.
|
---|
15 | *
|
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
22 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
23 | */
|
---|
24 |
|
---|
25 |
|
---|
26 | /*
|
---|
27 | * Mesa Off-Screen rendering interface.
|
---|
28 | *
|
---|
29 | * This is an operating system and window system independent interface to
|
---|
30 | * Mesa which allows one to render images into a client-supplied buffer in
|
---|
31 | * main memory. Such images may manipulated or saved in whatever way the
|
---|
32 | * client wants.
|
---|
33 | *
|
---|
34 | * These are the API functions:
|
---|
35 | * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
|
---|
36 | * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
|
---|
37 | * and make the specified context the current one.
|
---|
38 | * OSMesaDestroyContext - destroy an OSMesaContext
|
---|
39 | * OSMesaGetCurrentContext - return thread's current context ID
|
---|
40 | * OSMesaPixelStore - controls how pixels are stored in image buffer
|
---|
41 | * OSMesaGetIntegerv - return OSMesa state parameters
|
---|
42 | *
|
---|
43 | *
|
---|
44 | * The limits on the width and height of an image buffer can be retrieved
|
---|
45 | * via OSMesaGetIntegerv(OSMESA_MAX_WIDTH/OSMESA_MAX_HEIGHT).
|
---|
46 | */
|
---|
47 |
|
---|
48 |
|
---|
49 | #ifndef OSMESA_H
|
---|
50 | #define OSMESA_H
|
---|
51 |
|
---|
52 |
|
---|
53 | #ifdef __cplusplus
|
---|
54 | extern "C" {
|
---|
55 | #endif
|
---|
56 |
|
---|
57 |
|
---|
58 | #include <GL/gl.h>
|
---|
59 |
|
---|
60 |
|
---|
61 | #define OSMESA_MAJOR_VERSION 10
|
---|
62 | #define OSMESA_MINOR_VERSION 0
|
---|
63 | #define OSMESA_PATCH_VERSION 0
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * Values for the format parameter of OSMesaCreateContext()
|
---|
69 | * New in version 2.0.
|
---|
70 | */
|
---|
71 | #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
|
---|
72 | #define OSMESA_RGBA GL_RGBA
|
---|
73 | #define OSMESA_BGRA 0x1
|
---|
74 | #define OSMESA_ARGB 0x2
|
---|
75 | #define OSMESA_RGB GL_RGB
|
---|
76 | #define OSMESA_BGR 0x4
|
---|
77 | #define OSMESA_RGB_565 0x5
|
---|
78 |
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * OSMesaPixelStore() parameters:
|
---|
82 | * New in version 2.0.
|
---|
83 | */
|
---|
84 | #define OSMESA_ROW_LENGTH 0x10
|
---|
85 | #define OSMESA_Y_UP 0x11
|
---|
86 |
|
---|
87 |
|
---|
88 | /*
|
---|
89 | * Accepted by OSMesaGetIntegerv:
|
---|
90 | */
|
---|
91 | #define OSMESA_WIDTH 0x20
|
---|
92 | #define OSMESA_HEIGHT 0x21
|
---|
93 | #define OSMESA_FORMAT 0x22
|
---|
94 | #define OSMESA_TYPE 0x23
|
---|
95 | #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
|
---|
96 | #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
|
---|
97 |
|
---|
98 |
|
---|
99 | typedef struct osmesa_context *OSMesaContext;
|
---|
100 |
|
---|
101 |
|
---|
102 | /*
|
---|
103 | * Create an Off-Screen Mesa rendering context. The only attribute needed is
|
---|
104 | * an RGBA vs Color-Index mode flag.
|
---|
105 | *
|
---|
106 | * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
|
---|
107 | * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
|
---|
108 | * sharelist - specifies another OSMesaContext with which to share
|
---|
109 | * display lists. NULL indicates no sharing.
|
---|
110 | * Return: an OSMesaContext or 0 if error
|
---|
111 | */
|
---|
112 | GLAPI OSMesaContext GLAPIENTRY
|
---|
113 | OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
|
---|
114 |
|
---|
115 |
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * Create an Off-Screen Mesa rendering context and specify desired
|
---|
119 | * size of depth buffer, stencil buffer and accumulation buffer.
|
---|
120 | * If you specify zero for depthBits, stencilBits, accumBits you
|
---|
121 | * can save some memory.
|
---|
122 | *
|
---|
123 | * New in Mesa 3.5
|
---|
124 | */
|
---|
125 | GLAPI OSMesaContext GLAPIENTRY
|
---|
126 | OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
|
---|
127 | GLint accumBits, OSMesaContext sharelist);
|
---|
128 |
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * Destroy an Off-Screen Mesa rendering context.
|
---|
132 | *
|
---|
133 | * Input: ctx - the context to destroy
|
---|
134 | */
|
---|
135 | GLAPI void GLAPIENTRY
|
---|
136 | OSMesaDestroyContext( OSMesaContext ctx );
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|
140 | /*
|
---|
141 | * Bind an OSMesaContext to an image buffer. The image buffer is just a
|
---|
142 | * block of memory which the client provides. Its size must be at least
|
---|
143 | * as large as width*height*sizeof(type). Its address should be a multiple
|
---|
144 | * of 4 if using RGBA mode.
|
---|
145 | *
|
---|
146 | * Image data is stored in the order of glDrawPixels: row-major order
|
---|
147 | * with the lower-left image pixel stored in the first array position
|
---|
148 | * (ie. bottom-to-top).
|
---|
149 | *
|
---|
150 | * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
|
---|
151 | * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
|
---|
152 | * value. If the context is in color indexed mode, each pixel will be
|
---|
153 | * stored as a 1-byte value.
|
---|
154 | *
|
---|
155 | * If the context's viewport hasn't been initialized yet, it will now be
|
---|
156 | * initialized to (0,0,width,height).
|
---|
157 | *
|
---|
158 | * Input: ctx - the rendering context
|
---|
159 | * buffer - the image buffer memory
|
---|
160 | * type - data type for pixel components, only GL_UNSIGNED_BYTE
|
---|
161 | * supported now
|
---|
162 | * width, height - size of image buffer in pixels, at least 1
|
---|
163 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
|
---|
164 | * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
|
---|
165 | * width>internal limit or height>internal limit.
|
---|
166 | */
|
---|
167 | GLAPI GLboolean GLAPIENTRY
|
---|
168 | OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
|
---|
169 | GLsizei width, GLsizei height );
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 |
|
---|
174 | /*
|
---|
175 | * Return the current Off-Screen Mesa rendering context handle.
|
---|
176 | */
|
---|
177 | GLAPI OSMesaContext GLAPIENTRY
|
---|
178 | OSMesaGetCurrentContext( void );
|
---|
179 |
|
---|
180 |
|
---|
181 |
|
---|
182 | /*
|
---|
183 | * Set pixel store/packing parameters for the current context.
|
---|
184 | * This is similar to glPixelStore.
|
---|
185 | * Input: pname - OSMESA_ROW_LENGTH
|
---|
186 | * specify actual pixels per row in image buffer
|
---|
187 | * 0 = same as image width (default)
|
---|
188 | * OSMESA_Y_UP
|
---|
189 | * zero = Y coordinates increase downward
|
---|
190 | * non-zero = Y coordinates increase upward (default)
|
---|
191 | * value - the value for the parameter pname
|
---|
192 | *
|
---|
193 | * New in version 2.0.
|
---|
194 | */
|
---|
195 | GLAPI void GLAPIENTRY
|
---|
196 | OSMesaPixelStore( GLint pname, GLint value );
|
---|
197 |
|
---|
198 |
|
---|
199 |
|
---|
200 | /*
|
---|
201 | * Return an integer value like glGetIntegerv.
|
---|
202 | * Input: pname -
|
---|
203 | * OSMESA_WIDTH return current image width
|
---|
204 | * OSMESA_HEIGHT return current image height
|
---|
205 | * OSMESA_FORMAT return image format
|
---|
206 | * OSMESA_TYPE return color component data type
|
---|
207 | * OSMESA_ROW_LENGTH return row length in pixels
|
---|
208 | * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
|
---|
209 | * value - pointer to integer in which to return result.
|
---|
210 | */
|
---|
211 | GLAPI void GLAPIENTRY
|
---|
212 | OSMesaGetIntegerv( GLint pname, GLint *value );
|
---|
213 |
|
---|
214 |
|
---|
215 |
|
---|
216 | /*
|
---|
217 | * Return the depth buffer associated with an OSMesa context.
|
---|
218 | * Input: c - the OSMesa context
|
---|
219 | * Output: width, height - size of buffer in pixels
|
---|
220 | * bytesPerValue - bytes per depth value (2 or 4)
|
---|
221 | * buffer - pointer to depth buffer values
|
---|
222 | * Return: GL_TRUE or GL_FALSE to indicate success or failure.
|
---|
223 | *
|
---|
224 | * New in Mesa 2.4.
|
---|
225 | */
|
---|
226 | GLAPI GLboolean GLAPIENTRY
|
---|
227 | OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
|
---|
228 | GLint *bytesPerValue, void **buffer );
|
---|
229 |
|
---|
230 |
|
---|
231 |
|
---|
232 | /*
|
---|
233 | * Return the color buffer associated with an OSMesa context.
|
---|
234 | * Input: c - the OSMesa context
|
---|
235 | * Output: width, height - size of buffer in pixels
|
---|
236 | * format - buffer format (OSMESA_FORMAT)
|
---|
237 | * buffer - pointer to depth buffer values
|
---|
238 | * Return: GL_TRUE or GL_FALSE to indicate success or failure.
|
---|
239 | *
|
---|
240 | * New in Mesa 3.3.
|
---|
241 | */
|
---|
242 | GLAPI GLboolean GLAPIENTRY
|
---|
243 | OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
|
---|
244 | GLint *format, void **buffer );
|
---|
245 |
|
---|
246 |
|
---|
247 |
|
---|
248 | /**
|
---|
249 | * This typedef is new in Mesa 6.3.
|
---|
250 | */
|
---|
251 | typedef void (*OSMESAproc)();
|
---|
252 |
|
---|
253 |
|
---|
254 | /*
|
---|
255 | * Return pointer to the named function.
|
---|
256 | * New in Mesa 4.1
|
---|
257 | * Return OSMESAproc in 6.3.
|
---|
258 | */
|
---|
259 | GLAPI OSMESAproc GLAPIENTRY
|
---|
260 | OSMesaGetProcAddress( const char *funcName );
|
---|
261 |
|
---|
262 |
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Enable/disable color clamping, off by default.
|
---|
266 | * New in Mesa 6.4.2
|
---|
267 | */
|
---|
268 | GLAPI void GLAPIENTRY
|
---|
269 | OSMesaColorClamp(GLboolean enable);
|
---|
270 |
|
---|
271 |
|
---|
272 | /**
|
---|
273 | * Enable/disable Gallium post-process filters.
|
---|
274 | * This should be called after a context is created, but before it is
|
---|
275 | * made current for the first time. After a context has been made
|
---|
276 | * current, this function has no effect.
|
---|
277 | * If the enable_value param is zero, the filter is disabled. Otherwise
|
---|
278 | * the filter is enabled, and the value may control the filter's quality.
|
---|
279 | * New in Mesa 10.0
|
---|
280 | */
|
---|
281 | GLAPI void GLAPIENTRY
|
---|
282 | OSMesaPostprocess(OSMesaContext osmesa, const char *filter,
|
---|
283 | unsigned enable_value);
|
---|
284 |
|
---|
285 |
|
---|
286 | #ifdef __cplusplus
|
---|
287 | }
|
---|
288 | #endif
|
---|
289 |
|
---|
290 |
|
---|
291 | #endif
|
---|