/*1* Mesa 3-D graphics library2*3* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the "Software"),7* to deal in the Software without restriction, including without limitation8* the rights to use, copy, modify, merge, publish, distribute, sublicense,9* and/or sell copies of the Software, and to permit persons to whom the10* Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice shall be included13* in all copies or substantial portions of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS16* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR19* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,20* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR21* OTHER DEALINGS IN THE SOFTWARE.22*/232425/*26* Mesa Off-Screen rendering interface.27*28* This is an operating system and window system independent interface to29* Mesa which allows one to render images into a client-supplied buffer in30* main memory. Such images may manipulated or saved in whatever way the31* client wants.32*33* These are the API functions:34* OSMesaCreateContext - create a new Off-Screen Mesa rendering context35* OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer36* and make the specified context the current one.37* OSMesaDestroyContext - destroy an OSMesaContext38* OSMesaGetCurrentContext - return thread's current context ID39* OSMesaPixelStore - controls how pixels are stored in image buffer40* OSMesaGetIntegerv - return OSMesa state parameters41*42*43* The limits on the width and height of an image buffer can be retrieved44* via OSMesaGetIntegerv(OSMESA_MAX_WIDTH/OSMESA_MAX_HEIGHT).45*/464748#ifndef OSMESA_H49#define OSMESA_H505152#ifdef __cplusplus53extern "C" {54#endif555657#include <GL/gl.h>585960#define OSMESA_MAJOR_VERSION 1161#define OSMESA_MINOR_VERSION 262#define OSMESA_PATCH_VERSION 063646566/*67* Values for the format parameter of OSMesaCreateContext()68* New in version 2.0.69*/70#define OSMESA_COLOR_INDEX GL_COLOR_INDEX71#define OSMESA_RGBA GL_RGBA72#define OSMESA_BGRA 0x173#define OSMESA_ARGB 0x274#define OSMESA_RGB GL_RGB75#define OSMESA_BGR 0x476#define OSMESA_RGB_565 0x5777879/*80* OSMesaPixelStore() parameters:81* New in version 2.0.82*/83#define OSMESA_ROW_LENGTH 0x1084#define OSMESA_Y_UP 0x11858687/*88* Accepted by OSMesaGetIntegerv:89*/90#define OSMESA_WIDTH 0x2091#define OSMESA_HEIGHT 0x2192#define OSMESA_FORMAT 0x2293#define OSMESA_TYPE 0x2394#define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */95#define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */9697/*98* Accepted in OSMesaCreateContextAttrib's attribute list.99*/100#define OSMESA_DEPTH_BITS 0x30101#define OSMESA_STENCIL_BITS 0x31102#define OSMESA_ACCUM_BITS 0x32103#define OSMESA_PROFILE 0x33104#define OSMESA_CORE_PROFILE 0x34105#define OSMESA_COMPAT_PROFILE 0x35106#define OSMESA_CONTEXT_MAJOR_VERSION 0x36107#define OSMESA_CONTEXT_MINOR_VERSION 0x37108109110typedef struct osmesa_context *OSMesaContext;111112113/*114* Create an Off-Screen Mesa rendering context. The only attribute needed is115* an RGBA vs Color-Index mode flag.116*117* Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,118* OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.119* sharelist - specifies another OSMesaContext with which to share120* display lists. NULL indicates no sharing.121* Return: an OSMesaContext or 0 if error122*/123GLAPI OSMesaContext GLAPIENTRY124OSMesaCreateContext( GLenum format, OSMesaContext sharelist );125126127128/*129* Create an Off-Screen Mesa rendering context and specify desired130* size of depth buffer, stencil buffer and accumulation buffer.131* If you specify zero for depthBits, stencilBits, accumBits you132* can save some memory.133*134* New in Mesa 3.5135*/136GLAPI OSMesaContext GLAPIENTRY137OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,138GLint accumBits, OSMesaContext sharelist);139140141/*142* Create an Off-Screen Mesa rendering context with attribute list.143* The list is composed of (attribute, value) pairs and terminated with144* attribute==0. Supported Attributes:145*146* Attributes Values147* --------------------------------------------------------------------------148* OSMESA_FORMAT OSMESA_RGBA*, OSMESA_BGRA, OSMESA_ARGB, etc.149* OSMESA_DEPTH_BITS 0*, 16, 24, 32150* OSMESA_STENCIL_BITS 0*, 8151* OSMESA_ACCUM_BITS 0*, 16152* OSMESA_PROFILE OSMESA_COMPAT_PROFILE*, OSMESA_CORE_PROFILE153* OSMESA_CONTEXT_MAJOR_VERSION 1*, 2, 3154* OSMESA_CONTEXT_MINOR_VERSION 0+155*156* Note: * = default value157*158* We return a context version >= what's specified by OSMESA_CONTEXT_MAJOR/159* MINOR_VERSION for the given profile. For example, if you request a GL 1.4160* compat profile, you might get a GL 3.0 compat profile.161* Otherwise, null is returned if the version/profile is not supported.162*163* New in Mesa 11.2164*/165GLAPI OSMesaContext GLAPIENTRY166OSMesaCreateContextAttribs( const int *attribList, OSMesaContext sharelist );167168169170/*171* Destroy an Off-Screen Mesa rendering context.172*173* Input: ctx - the context to destroy174*/175GLAPI void GLAPIENTRY176OSMesaDestroyContext( OSMesaContext ctx );177178179180/*181* Bind an OSMesaContext to an image buffer. The image buffer is just a182* block of memory which the client provides. Its size must be at least183* as large as width*height*sizeof(type). Its address should be a multiple184* of 4 if using RGBA mode.185*186* Image data is stored in the order of glDrawPixels: row-major order187* with the lower-left image pixel stored in the first array position188* (ie. bottom-to-top).189*190* Since the only type initially supported is GL_UNSIGNED_BYTE, if the191* context is in RGBA mode, each pixel will be stored as a 4-byte RGBA192* value. If the context is in color indexed mode, each pixel will be193* stored as a 1-byte value.194*195* If the context's viewport hasn't been initialized yet, it will now be196* initialized to (0,0,width,height).197*198* Input: ctx - the rendering context199* buffer - the image buffer memory200* type - data type for pixel components, only GL_UNSIGNED_BYTE201* supported now202* width, height - size of image buffer in pixels, at least 1203* Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,204* invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,205* width>internal limit or height>internal limit.206*/207GLAPI GLboolean GLAPIENTRY208OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,209GLsizei width, GLsizei height );210211212213214/*215* Return the current Off-Screen Mesa rendering context handle.216*/217GLAPI OSMesaContext GLAPIENTRY218OSMesaGetCurrentContext( void );219220221222/*223* Set pixel store/packing parameters for the current context.224* This is similar to glPixelStore.225* Input: pname - OSMESA_ROW_LENGTH226* specify actual pixels per row in image buffer227* 0 = same as image width (default)228* OSMESA_Y_UP229* zero = Y coordinates increase downward230* non-zero = Y coordinates increase upward (default)231* value - the value for the parameter pname232*233* New in version 2.0.234*/235GLAPI void GLAPIENTRY236OSMesaPixelStore( GLint pname, GLint value );237238239240/*241* Return an integer value like glGetIntegerv.242* Input: pname -243* OSMESA_WIDTH return current image width244* OSMESA_HEIGHT return current image height245* OSMESA_FORMAT return image format246* OSMESA_TYPE return color component data type247* OSMESA_ROW_LENGTH return row length in pixels248* OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction249* value - pointer to integer in which to return result.250*/251GLAPI void GLAPIENTRY252OSMesaGetIntegerv( GLint pname, GLint *value );253254255256/*257* Return the depth buffer associated with an OSMesa context.258* Input: c - the OSMesa context259* Output: width, height - size of buffer in pixels260* bytesPerValue - bytes per depth value (2 or 4)261* buffer - pointer to depth buffer values262* Return: GL_TRUE or GL_FALSE to indicate success or failure.263*264* New in Mesa 2.4.265*/266GLAPI GLboolean GLAPIENTRY267OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,268GLint *bytesPerValue, void **buffer );269270271272/*273* Return the color buffer associated with an OSMesa context.274* Input: c - the OSMesa context275* Output: width, height - size of buffer in pixels276* format - buffer format (OSMESA_FORMAT)277* buffer - pointer to depth buffer values278* Return: GL_TRUE or GL_FALSE to indicate success or failure.279*280* New in Mesa 3.3.281*/282GLAPI GLboolean GLAPIENTRY283OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,284GLint *format, void **buffer );285286287288/**289* This typedef is new in Mesa 6.3.290*/291typedef void (*OSMESAproc)();292293294/*295* Return pointer to the named function.296* New in Mesa 4.1297* Return OSMESAproc in 6.3.298*/299GLAPI OSMESAproc GLAPIENTRY300OSMesaGetProcAddress( const char *funcName );301302303304/**305* Enable/disable color clamping, off by default.306* New in Mesa 6.4.2307*/308GLAPI void GLAPIENTRY309OSMesaColorClamp(GLboolean enable);310311312/**313* Enable/disable Gallium post-process filters.314* This should be called after a context is created, but before it is315* made current for the first time. After a context has been made316* current, this function has no effect.317* If the enable_value param is zero, the filter is disabled. Otherwise318* the filter is enabled, and the value may control the filter's quality.319* New in Mesa 10.0320*/321GLAPI void GLAPIENTRY322OSMesaPostprocess(OSMesaContext osmesa, const char *filter,323unsigned enable_value);324325326#ifdef __cplusplus327}328#endif329330331#endif332333334