s/void */GLvoid */
[mesa.git] / include / GL / osmesa.h
1 /* $Id: osmesa.h,v 1.6 2000/09/08 16:41:38 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2000 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 #ifndef OSMESA_H
54 #define OSMESA_H
55
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61
62 #include <GL/gl.h>
63
64
65 #define OSMESA_MAJOR_VERSION 3
66 #define OSMESA_MINOR_VERSION 5
67
68
69
70 /*
71 * Values for the format parameter of OSMesaCreateContext()
72 * New in version 2.0.
73 */
74 #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
75 #define OSMESA_RGBA GL_RGBA
76 #define OSMESA_BGRA 0x1
77 #define OSMESA_ARGB 0x2
78 #define OSMESA_RGB GL_RGB
79 #define OSMESA_BGR 0x4
80
81
82 /*
83 * OSMesaPixelStore() parameters:
84 * New in version 2.0.
85 */
86 #define OSMESA_ROW_LENGTH 0x10
87 #define OSMESA_Y_UP 0x11
88
89
90 /*
91 * Accepted by OSMesaGetIntegerv:
92 */
93 #define OSMESA_WIDTH 0x20
94 #define OSMESA_HEIGHT 0x21
95 #define OSMESA_FORMAT 0x22
96 #define OSMESA_TYPE 0x23
97
98
99 typedef struct osmesa_context *OSMesaContext;
100
101
102 #if defined(__BEOS__) || defined(__QUICKDRAW__)
103 #pragma export on
104 #endif
105
106
107 /*
108 * Create an Off-Screen Mesa rendering context. The only attribute needed is
109 * an RGBA vs Color-Index mode flag.
110 *
111 * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
112 * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
113 * sharelist - specifies another OSMesaContext with which to share
114 * display lists. NULL indicates no sharing.
115 * Return: an OSMesaContext or 0 if error
116 */
117 GLAPI OSMesaContext GLAPIENTRY
118 OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
119
120
121
122 /*
123 * Create an Off-Screen Mesa rendering context and specify desired
124 * size of depth buffer, stencil buffer and accumulation buffer.
125 * If you specify zero for depthBits, stencilBits, accumBits you
126 * can save some memory.
127 *
128 * New in Mesa 3.5
129 */
130 GLAPI OSMesaContext GLAPIENTRY
131 OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
132 GLint accumBits, OSMesaContext sharelist);
133
134
135 /*
136 * Destroy an Off-Screen Mesa rendering context.
137 *
138 * Input: ctx - the context to destroy
139 */
140 GLAPI void GLAPIENTRY
141 OSMesaDestroyContext( OSMesaContext ctx );
142
143
144
145 /*
146 * Bind an OSMesaContext to an image buffer. The image buffer is just a
147 * block of memory which the client provides. Its size must be at least
148 * as large as width*height*sizeof(type). Its address should be a multiple
149 * of 4 if using RGBA mode.
150 *
151 * Image data is stored in the order of glDrawPixels: row-major order
152 * with the lower-left image pixel stored in the first array position
153 * (ie. bottom-to-top).
154 *
155 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
156 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
157 * value. If the context is in color indexed mode, each pixel will be
158 * stored as a 1-byte value.
159 *
160 * If the context's viewport hasn't been initialized yet, it will now be
161 * initialized to (0,0,width,height).
162 *
163 * Input: ctx - the rendering context
164 * buffer - the image buffer memory
165 * type - data type for pixel components, only GL_UNSIGNED_BYTE
166 * supported now
167 * width, height - size of image buffer in pixels, at least 1
168 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
169 * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
170 * width>internal limit or height>internal limit.
171 */
172 GLAPI GLboolean GLAPIENTRY
173 OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
174 GLsizei width, GLsizei height );
175
176
177
178
179 /*
180 * Return the current Off-Screen Mesa rendering context handle.
181 */
182 GLAPI OSMesaContext GLAPIENTRY
183 OSMesaGetCurrentContext( void );
184
185
186
187 /*
188 * Set pixel store/packing parameters for the current context.
189 * This is similar to glPixelStore.
190 * Input: pname - OSMESA_ROW_LENGTH
191 * specify actual pixels per row in image buffer
192 * 0 = same as image width (default)
193 * OSMESA_Y_UP
194 * zero = Y coordinates increase downward
195 * non-zero = Y coordinates increase upward (default)
196 * value - the value for the parameter pname
197 *
198 * New in version 2.0.
199 */
200 GLAPI void GLAPIENTRY
201 OSMesaPixelStore( GLint pname, GLint value );
202
203
204
205 /*
206 * Return an integer value like glGetIntegerv.
207 * Input: pname -
208 * OSMESA_WIDTH return current image width
209 * OSMESA_HEIGHT return current image height
210 * OSMESA_FORMAT return image format
211 * OSMESA_TYPE return color component data type
212 * OSMESA_ROW_LENGTH return row length in pixels
213 * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
214 * value - pointer to integer in which to return result.
215 */
216 GLAPI void GLAPIENTRY
217 OSMesaGetIntegerv( GLint pname, GLint *value );
218
219
220
221 /*
222 * Return the depth buffer associated with an OSMesa context.
223 * Input: c - the OSMesa context
224 * Output: width, height - size of buffer in pixels
225 * bytesPerValue - bytes per depth value (2 or 4)
226 * buffer - pointer to depth buffer values
227 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
228 *
229 * New in Mesa 2.4.
230 */
231 GLAPI GLboolean GLAPIENTRY
232 OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
233 GLint *bytesPerValue, void **buffer );
234
235
236
237 /*
238 * Return the color buffer associated with an OSMesa context.
239 * Input: c - the OSMesa context
240 * Output: width, height - size of buffer in pixels
241 * format - buffer format (OSMESA_FORMAT)
242 * buffer - pointer to depth buffer values
243 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
244 *
245 * New in Mesa 3.3.
246 */
247 GLAPI GLboolean GLAPIENTRY
248 OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
249 GLint *format, void **buffer );
250
251
252
253 #if defined(__BEOS__) || defined(__QUICKDRAW__)
254 #pragma export off
255 #endif
256
257
258 #ifdef __cplusplus
259 }
260 #endif
261
262
263 #endif