1 /* 2 * Mesa 3-D graphics library 3 * Version: 6.5 4 * 5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. 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 /* 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 51 #ifndef OSMESA_H 52 #define OSMESA_H 53 54 55 #ifdef __cplusplus 56 extern "C" { 57 #endif 58 59 60 #include <GL/gl.h> 61 62 63 #define OSMESA_MAJOR_VERSION 6 64 #define OSMESA_MINOR_VERSION 5 65 #define OSMESA_PATCH_VERSION 0 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 79 #define OSMESA_RGB_565 0x5 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 #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */ 98 #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */ 99 100 101 typedef struct osmesa_context *OSMesaContext; 102 103 104 /* See https://bugs.freedesktop.org/show_bug.cgi?id=77749 */ 105 #if 0 /* defined(__QUICKDRAW__) */ 106 #pragma export on 107 #endif 108 109 110 /* 111 * Create an Off-Screen Mesa rendering context. The only attribute needed is 112 * an RGBA vs Color-Index mode flag. 113 * 114 * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA, 115 * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR. 116 * sharelist - specifies another OSMesaContext with which to share 117 * display lists. NULL indicates no sharing. 118 * Return: an OSMesaContext or 0 if error 119 */ 120 GLAPI OSMesaContext GLAPIENTRY 121 OSMesaCreateContext( GLenum format, OSMesaContext sharelist ); 122 123 124 125 /* 126 * Create an Off-Screen Mesa rendering context and specify desired 127 * size of depth buffer, stencil buffer and accumulation buffer. 128 * If you specify zero for depthBits, stencilBits, accumBits you 129 * can save some memory. 130 * 131 * New in Mesa 3.5 132 */ 133 GLAPI OSMesaContext GLAPIENTRY 134 OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, 135 GLint accumBits, OSMesaContext sharelist); 136 137 138 /* 139 * Destroy an Off-Screen Mesa rendering context. 140 * 141 * Input: ctx - the context to destroy 142 */ 143 GLAPI void GLAPIENTRY 144 OSMesaDestroyContext( OSMesaContext ctx ); 145 146 147 148 /* 149 * Bind an OSMesaContext to an image buffer. The image buffer is just a 150 * block of memory which the client provides. Its size must be at least 151 * as large as width*height*sizeof(type). Its address should be a multiple 152 * of 4 if using RGBA mode. 153 * 154 * Image data is stored in the order of glDrawPixels: row-major order 155 * with the lower-left image pixel stored in the first array position 156 * (ie. bottom-to-top). 157 * 158 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the 159 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA 160 * value. If the context is in color indexed mode, each pixel will be 161 * stored as a 1-byte value. 162 * 163 * If the context's viewport hasn't been initialized yet, it will now be 164 * initialized to (0,0,width,height). 165 * 166 * Input: ctx - the rendering context 167 * buffer - the image buffer memory 168 * type - data type for pixel components, only GL_UNSIGNED_BYTE 169 * supported now 170 * width, height - size of image buffer in pixels, at least 1 171 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx, 172 * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1, 173 * width>internal limit or height>internal limit. 174 */ 175 GLAPI GLboolean GLAPIENTRY 176 OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type, 177 GLsizei width, GLsizei height ); 178 179 180 181 182 /* 183 * Return the current Off-Screen Mesa rendering context handle. 184 */ 185 GLAPI OSMesaContext GLAPIENTRY 186 OSMesaGetCurrentContext( void ); 187 188 189 190 /* 191 * Set pixel store/packing parameters for the current context. 192 * This is similar to glPixelStore. 193 * Input: pname - OSMESA_ROW_LENGTH 194 * specify actual pixels per row in image buffer 195 * 0 = same as image width (default) 196 * OSMESA_Y_UP 197 * zero = Y coordinates increase downward 198 * non-zero = Y coordinates increase upward (default) 199 * value - the value for the parameter pname 200 * 201 * New in version 2.0. 202 */ 203 GLAPI void GLAPIENTRY 204 OSMesaPixelStore( GLint pname, GLint value ); 205 206 207 208 /* 209 * Return an integer value like glGetIntegerv. 210 * Input: pname - 211 * OSMESA_WIDTH return current image width 212 * OSMESA_HEIGHT return current image height 213 * OSMESA_FORMAT return image format 214 * OSMESA_TYPE return color component data type 215 * OSMESA_ROW_LENGTH return row length in pixels 216 * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction 217 * value - pointer to integer in which to return result. 218 */ 219 GLAPI void GLAPIENTRY 220 OSMesaGetIntegerv( GLint pname, GLint *value ); 221 222 223 224 /* 225 * Return the depth buffer associated with an OSMesa context. 226 * Input: c - the OSMesa context 227 * Output: width, height - size of buffer in pixels 228 * bytesPerValue - bytes per depth value (2 or 4) 229 * buffer - pointer to depth buffer values 230 * Return: GL_TRUE or GL_FALSE to indicate success or failure. 231 * 232 * New in Mesa 2.4. 233 */ 234 GLAPI GLboolean GLAPIENTRY 235 OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height, 236 GLint *bytesPerValue, void **buffer ); 237 238 239 240 /* 241 * Return the color buffer associated with an OSMesa context. 242 * Input: c - the OSMesa context 243 * Output: width, height - size of buffer in pixels 244 * format - buffer format (OSMESA_FORMAT) 245 * buffer - pointer to depth buffer values 246 * Return: GL_TRUE or GL_FALSE to indicate success or failure. 247 * 248 * New in Mesa 3.3. 249 */ 250 GLAPI GLboolean GLAPIENTRY 251 OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height, 252 GLint *format, void **buffer ); 253 254 255 256 /** 257 * This typedef is new in Mesa 6.3. 258 */ 259 typedef void (*OSMESAproc)(); 260 261 262 /* 263 * Return pointer to the named function. 264 * New in Mesa 4.1 265 * Return OSMESAproc in 6.3. 266 */ 267 GLAPI OSMESAproc GLAPIENTRY 268 OSMesaGetProcAddress( const char *funcName ); 269 270 271 272 /** 273 * Enable/disable color clamping, off by default. 274 * New in Mesa 6.4.2 275 */ 276 GLAPI void GLAPIENTRY 277 OSMesaColorClamp(GLboolean enable); 278 279 #ifdef __cplusplus 280 } 281 #endif 282 283 284 #endif 285