jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | 4d88098 | 2004-11-27 16:24:39 +0000 | [diff] [blame^] | 3 | * Version: 6.3 |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 4 | * |
Brian Paul | 4d88098 | 2004-11-27 16:24:39 +0000 | [diff] [blame^] | 5 | * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | /* |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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 are MAX_WIDTH and |
| 45 | * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024. |
| 46 | * You can increase them as needed but beware that many temporary arrays in |
| 47 | * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT. |
| 48 | */ |
| 49 | |
| 50 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 51 | #ifndef OSMESA_H |
| 52 | #define OSMESA_H |
| 53 | |
| 54 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 55 | #ifdef __cplusplus |
| 56 | extern "C" { |
| 57 | #endif |
| 58 | |
| 59 | |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 60 | #include <GL/gl.h> |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 61 | |
| 62 | |
Brian Paul | 4d88098 | 2004-11-27 16:24:39 +0000 | [diff] [blame^] | 63 | #define OSMESA_MAJOR_VERSION 6 |
| 64 | #define OSMESA_MINOR_VERSION 3 |
Brian Paul | 78a03d3 | 2001-09-23 16:06:13 +0000 | [diff] [blame] | 65 | #define OSMESA_PATCH_VERSION 0 |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 66 | |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | * Values for the format parameter of OSMesaCreateContext() |
| 71 | * New in version 2.0. |
| 72 | */ |
| 73 | #define OSMESA_COLOR_INDEX GL_COLOR_INDEX |
| 74 | #define OSMESA_RGBA GL_RGBA |
| 75 | #define OSMESA_BGRA 0x1 |
| 76 | #define OSMESA_ARGB 0x2 |
| 77 | #define OSMESA_RGB GL_RGB |
| 78 | #define OSMESA_BGR 0x4 |
Brian Paul | 206eda8 | 2001-06-27 13:56:17 +0000 | [diff] [blame] | 79 | #define OSMESA_RGB_565 0x5 |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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 |
Brian Paul | 78a03d3 | 2001-09-23 16:06:13 +0000 | [diff] [blame] | 97 | #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */ |
| 98 | #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 99 | |
Brian Paul | 187bce0 | 2000-01-18 17:29:18 +0000 | [diff] [blame] | 100 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 101 | typedef struct osmesa_context *OSMesaContext; |
| 102 | |
| 103 | |
| 104 | #if defined(__BEOS__) || defined(__QUICKDRAW__) |
| 105 | #pragma export on |
| 106 | #endif |
| 107 | |
| 108 | |
| 109 | /* |
| 110 | * Create an Off-Screen Mesa rendering context. The only attribute needed is |
| 111 | * an RGBA vs Color-Index mode flag. |
| 112 | * |
| 113 | * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA, |
| 114 | * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR. |
| 115 | * sharelist - specifies another OSMesaContext with which to share |
| 116 | * display lists. NULL indicates no sharing. |
| 117 | * Return: an OSMesaContext or 0 if error |
| 118 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 119 | GLAPI OSMesaContext GLAPIENTRY |
| 120 | OSMesaCreateContext( GLenum format, OSMesaContext sharelist ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 121 | |
| 122 | |
| 123 | |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 124 | /* |
| 125 | * Create an Off-Screen Mesa rendering context and specify desired |
| 126 | * size of depth buffer, stencil buffer and accumulation buffer. |
| 127 | * If you specify zero for depthBits, stencilBits, accumBits you |
| 128 | * can save some memory. |
| 129 | * |
| 130 | * New in Mesa 3.5 |
| 131 | */ |
| 132 | GLAPI OSMesaContext GLAPIENTRY |
| 133 | OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, |
| 134 | GLint accumBits, OSMesaContext sharelist); |
| 135 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * Destroy an Off-Screen Mesa rendering context. |
| 139 | * |
| 140 | * Input: ctx - the context to destroy |
| 141 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 142 | GLAPI void GLAPIENTRY |
| 143 | OSMesaDestroyContext( OSMesaContext ctx ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 144 | |
| 145 | |
| 146 | |
| 147 | /* |
| 148 | * Bind an OSMesaContext to an image buffer. The image buffer is just a |
| 149 | * block of memory which the client provides. Its size must be at least |
| 150 | * as large as width*height*sizeof(type). Its address should be a multiple |
| 151 | * of 4 if using RGBA mode. |
| 152 | * |
| 153 | * Image data is stored in the order of glDrawPixels: row-major order |
| 154 | * with the lower-left image pixel stored in the first array position |
| 155 | * (ie. bottom-to-top). |
| 156 | * |
| 157 | * Since the only type initially supported is GL_UNSIGNED_BYTE, if the |
| 158 | * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA |
| 159 | * value. If the context is in color indexed mode, each pixel will be |
| 160 | * stored as a 1-byte value. |
| 161 | * |
| 162 | * If the context's viewport hasn't been initialized yet, it will now be |
| 163 | * initialized to (0,0,width,height). |
| 164 | * |
| 165 | * Input: ctx - the rendering context |
| 166 | * buffer - the image buffer memory |
| 167 | * type - data type for pixel components, only GL_UNSIGNED_BYTE |
| 168 | * supported now |
| 169 | * width, height - size of image buffer in pixels, at least 1 |
| 170 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx, |
| 171 | * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1, |
| 172 | * width>internal limit or height>internal limit. |
| 173 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 174 | GLAPI GLboolean GLAPIENTRY |
| 175 | OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type, |
| 176 | GLsizei width, GLsizei height ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | /* |
| 182 | * Return the current Off-Screen Mesa rendering context handle. |
| 183 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 184 | GLAPI OSMesaContext GLAPIENTRY |
| 185 | OSMesaGetCurrentContext( void ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 186 | |
| 187 | |
| 188 | |
| 189 | /* |
| 190 | * Set pixel store/packing parameters for the current context. |
| 191 | * This is similar to glPixelStore. |
| 192 | * Input: pname - OSMESA_ROW_LENGTH |
| 193 | * specify actual pixels per row in image buffer |
| 194 | * 0 = same as image width (default) |
| 195 | * OSMESA_Y_UP |
| 196 | * zero = Y coordinates increase downward |
| 197 | * non-zero = Y coordinates increase upward (default) |
| 198 | * value - the value for the parameter pname |
| 199 | * |
| 200 | * New in version 2.0. |
| 201 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 202 | GLAPI void GLAPIENTRY |
| 203 | OSMesaPixelStore( GLint pname, GLint value ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 204 | |
| 205 | |
| 206 | |
| 207 | /* |
Brian Paul | 187bce0 | 2000-01-18 17:29:18 +0000 | [diff] [blame] | 208 | * Return an integer value like glGetIntegerv. |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 209 | * Input: pname - |
| 210 | * OSMESA_WIDTH return current image width |
| 211 | * OSMESA_HEIGHT return current image height |
| 212 | * OSMESA_FORMAT return image format |
| 213 | * OSMESA_TYPE return color component data type |
| 214 | * OSMESA_ROW_LENGTH return row length in pixels |
| 215 | * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction |
| 216 | * value - pointer to integer in which to return result. |
| 217 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 218 | GLAPI void GLAPIENTRY |
| 219 | OSMesaGetIntegerv( GLint pname, GLint *value ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 220 | |
Brian Paul | 187bce0 | 2000-01-18 17:29:18 +0000 | [diff] [blame] | 221 | |
| 222 | |
Randy Frank | 0deb373 | 2000-01-15 06:12:18 +0000 | [diff] [blame] | 223 | /* |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 224 | * Return the depth buffer associated with an OSMesa context. |
| 225 | * Input: c - the OSMesa context |
| 226 | * Output: width, height - size of buffer in pixels |
| 227 | * bytesPerValue - bytes per depth value (2 or 4) |
| 228 | * buffer - pointer to depth buffer values |
| 229 | * Return: GL_TRUE or GL_FALSE to indicate success or failure. |
| 230 | * |
| 231 | * New in Mesa 2.4. |
| 232 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 233 | GLAPI GLboolean GLAPIENTRY |
| 234 | OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height, |
| 235 | GLint *bytesPerValue, void **buffer ); |
| 236 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 237 | |
| 238 | |
Randy Frank | 23ee049 | 2000-03-28 16:59:39 +0000 | [diff] [blame] | 239 | /* |
| 240 | * Return the color buffer associated with an OSMesa context. |
| 241 | * Input: c - the OSMesa context |
| 242 | * Output: width, height - size of buffer in pixels |
| 243 | * format - buffer format (OSMESA_FORMAT) |
| 244 | * buffer - pointer to depth buffer values |
| 245 | * Return: GL_TRUE or GL_FALSE to indicate success or failure. |
| 246 | * |
| 247 | * New in Mesa 3.3. |
| 248 | */ |
Brian Paul | 2bf5d94 | 2000-09-08 16:41:38 +0000 | [diff] [blame] | 249 | GLAPI GLboolean GLAPIENTRY |
| 250 | OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height, |
| 251 | GLint *format, void **buffer ); |
| 252 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 253 | |
| 254 | |
Brian Paul | 4d88098 | 2004-11-27 16:24:39 +0000 | [diff] [blame^] | 255 | /** |
| 256 | * This typedef is new in Mesa 6.3. |
| 257 | */ |
| 258 | typedef void (*OSMESAproc)(); |
| 259 | |
| 260 | |
Brian Paul | 01dc182 | 2002-04-04 16:58:04 +0000 | [diff] [blame] | 261 | /* |
| 262 | * Return pointer to the named function. |
Brian Paul | 01dc182 | 2002-04-04 16:58:04 +0000 | [diff] [blame] | 263 | * New in Mesa 4.1 |
Brian Paul | 4d88098 | 2004-11-27 16:24:39 +0000 | [diff] [blame^] | 264 | * Return OSMESAproc in 6.3. |
Brian Paul | 01dc182 | 2002-04-04 16:58:04 +0000 | [diff] [blame] | 265 | */ |
Brian Paul | 4d88098 | 2004-11-27 16:24:39 +0000 | [diff] [blame^] | 266 | GLAPI OSMESAproc GLAPIENTRY |
Brian Paul | 01dc182 | 2002-04-04 16:58:04 +0000 | [diff] [blame] | 267 | OSMesaGetProcAddress( const char *funcName ); |
| 268 | |
| 269 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 270 | #if defined(__BEOS__) || defined(__QUICKDRAW__) |
| 271 | #pragma export off |
| 272 | #endif |
| 273 | |
| 274 | |
| 275 | #ifdef __cplusplus |
| 276 | } |
| 277 | #endif |
| 278 | |
| 279 | |
| 280 | #endif |