1 /* $Id: osmesa.h,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
30 * Revision 1.1 1999/08/19 00:55:40 jtg
33 * Revision 1.4 1999/02/14 03:39:09 brianp
36 * Revision 1.3 1999/01/03 02:52:30 brianp
37 * now using GLAPI and GLAPIENTRY keywords (Ted Jump)
39 * Revision 1.2 1998/07/26 01:33:51 brianp
40 * added WINGDIAPI and APIENTRY keywords per Ted Jump
42 * Revision 1.1 1998/02/13 03:17:50 brianp
49 * Mesa Off-Screen rendering interface.
51 * This is an operating system and window system independent interface to
52 * Mesa which allows one to render images into a client-supplied buffer in
53 * main memory. Such images may manipulated or saved in whatever way the
56 * These are the API functions:
57 * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
58 * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
59 * and make the specified context the current one.
60 * OSMesaDestroyContext - destroy an OSMesaContext
61 * OSMesaGetCurrentContext - return thread's current context ID
62 * OSMesaPixelStore - controls how pixels are stored in image buffer
63 * OSMesaGetIntegerv - return OSMesa state parameters
66 * The limits on the width and height of an image buffer are MAX_WIDTH and
67 * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024.
68 * You can increase them as needed but beware that many temporary arrays in
69 * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
88 #define OSMESA_MAJOR_VERSION 3
89 #define OSMESA_MINOR_VERSION 0
94 * Values for the format parameter of OSMesaCreateContext()
97 #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
98 #define OSMESA_RGBA GL_RGBA
99 #define OSMESA_BGRA 0x1
100 #define OSMESA_ARGB 0x2
101 #define OSMESA_RGB GL_RGB
102 #define OSMESA_BGR 0x4
106 * OSMesaPixelStore() parameters:
107 * New in version 2.0.
109 #define OSMESA_ROW_LENGTH 0x10
110 #define OSMESA_Y_UP 0x11
114 * Accepted by OSMesaGetIntegerv:
116 #define OSMESA_WIDTH 0x20
117 #define OSMESA_HEIGHT 0x21
118 #define OSMESA_FORMAT 0x22
119 #define OSMESA_TYPE 0x23
123 typedef struct osmesa_context
*OSMesaContext
;
126 #if defined(__BEOS__) || defined(__QUICKDRAW__)
132 * Create an Off-Screen Mesa rendering context. The only attribute needed is
133 * an RGBA vs Color-Index mode flag.
135 * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
136 * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
137 * sharelist - specifies another OSMesaContext with which to share
138 * display lists. NULL indicates no sharing.
139 * Return: an OSMesaContext or 0 if error
141 GLAPI OSMesaContext GLAPIENTRY
OSMesaCreateContext( GLenum format
,
142 OSMesaContext sharelist
);
148 * Destroy an Off-Screen Mesa rendering context.
150 * Input: ctx - the context to destroy
152 GLAPI
void GLAPIENTRY
OSMesaDestroyContext( OSMesaContext ctx
);
157 * Bind an OSMesaContext to an image buffer. The image buffer is just a
158 * block of memory which the client provides. Its size must be at least
159 * as large as width*height*sizeof(type). Its address should be a multiple
160 * of 4 if using RGBA mode.
162 * Image data is stored in the order of glDrawPixels: row-major order
163 * with the lower-left image pixel stored in the first array position
164 * (ie. bottom-to-top).
166 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
167 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
168 * value. If the context is in color indexed mode, each pixel will be
169 * stored as a 1-byte value.
171 * If the context's viewport hasn't been initialized yet, it will now be
172 * initialized to (0,0,width,height).
174 * Input: ctx - the rendering context
175 * buffer - the image buffer memory
176 * type - data type for pixel components, only GL_UNSIGNED_BYTE
178 * width, height - size of image buffer in pixels, at least 1
179 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
180 * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
181 * width>internal limit or height>internal limit.
183 GLAPI GLboolean GLAPIENTRY
OSMesaMakeCurrent( OSMesaContext ctx
,
184 void *buffer
, GLenum type
,
185 GLsizei width
, GLsizei height
);
191 * Return the current Off-Screen Mesa rendering context handle.
193 GLAPI OSMesaContext GLAPIENTRY
OSMesaGetCurrentContext( void );
198 * Set pixel store/packing parameters for the current context.
199 * This is similar to glPixelStore.
200 * Input: pname - OSMESA_ROW_LENGTH
201 * specify actual pixels per row in image buffer
202 * 0 = same as image width (default)
204 * zero = Y coordinates increase downward
205 * non-zero = Y coordinates increase upward (default)
206 * value - the value for the parameter pname
208 * New in version 2.0.
210 GLAPI
void GLAPIENTRY
OSMesaPixelStore( GLint pname
, GLint value
);
215 * Return context info. This is like glGetIntegerv.
217 * OSMESA_WIDTH return current image width
218 * OSMESA_HEIGHT return current image height
219 * OSMESA_FORMAT return image format
220 * OSMESA_TYPE return color component data type
221 * OSMESA_ROW_LENGTH return row length in pixels
222 * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
223 * value - pointer to integer in which to return result.
225 GLAPI
void GLAPIENTRY
OSMesaGetIntegerv( GLint pname
, GLint
*value
);
230 * Return the depth buffer associated with an OSMesa context.
231 * Input: c - the OSMesa context
232 * Output: width, height - size of buffer in pixels
233 * bytesPerValue - bytes per depth value (2 or 4)
234 * buffer - pointer to depth buffer values
235 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
239 GLAPI GLboolean GLAPIENTRY
OSMesaGetDepthBuffer( OSMesaContext c
,
240 GLint
*width
, GLint
*height
,
241 GLint
*bytesPerValue
, void **buffer
);
246 #if defined(__BEOS__) || defined(__QUICKDRAW__)