Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

osmesa.h 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /* $Id: osmesa.h,v 1.10 2002/04/04 16:58:04 brianp Exp $ */
  2. /*
  3. * Mesa 3-D graphics library
  4. * Version: 4.1
  5. *
  6. * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a
  9. * copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  22. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. /*
  26. * Mesa Off-Screen rendering interface.
  27. *
  28. * This is an operating system and window system independent interface to
  29. * Mesa which allows one to render images into a client-supplied buffer in
  30. * main memory. Such images may manipulated or saved in whatever way the
  31. * client wants.
  32. *
  33. * These are the API functions:
  34. * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
  35. * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
  36. * and make the specified context the current one.
  37. * OSMesaDestroyContext - destroy an OSMesaContext
  38. * OSMesaGetCurrentContext - return thread's current context ID
  39. * OSMesaPixelStore - controls how pixels are stored in image buffer
  40. * OSMesaGetIntegerv - return OSMesa state parameters
  41. *
  42. *
  43. * The limits on the width and height of an image buffer are MAX_WIDTH and
  44. * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024.
  45. * You can increase them as needed but beware that many temporary arrays in
  46. * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
  47. */
  48. #ifndef OSMESA_H
  49. #define OSMESA_H
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. #include <GL/gl.h>
  54. #define OSMESA_MAJOR_VERSION 4
  55. #define OSMESA_MINOR_VERSION 1
  56. #define OSMESA_PATCH_VERSION 0
  57. /*
  58. * Values for the format parameter of OSMesaCreateContext()
  59. * New in version 2.0.
  60. */
  61. #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
  62. #define OSMESA_RGBA GL_RGBA
  63. #define OSMESA_BGRA 0x1
  64. #define OSMESA_ARGB 0x2
  65. #define OSMESA_RGB GL_RGB
  66. #define OSMESA_BGR 0x4
  67. #define OSMESA_RGB_565 0x5
  68. /*
  69. * OSMesaPixelStore() parameters:
  70. * New in version 2.0.
  71. */
  72. #define OSMESA_ROW_LENGTH 0x10
  73. #define OSMESA_Y_UP 0x11
  74. /*
  75. * Accepted by OSMesaGetIntegerv:
  76. */
  77. #define OSMESA_WIDTH 0x20
  78. #define OSMESA_HEIGHT 0x21
  79. #define OSMESA_FORMAT 0x22
  80. #define OSMESA_TYPE 0x23
  81. #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
  82. #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
  83. typedef struct osmesa_context *OSMesaContext;
  84. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  85. #pragma export on
  86. #endif
  87. /*
  88. * Create an Off-Screen Mesa rendering context. The only attribute needed is
  89. * an RGBA vs Color-Index mode flag.
  90. *
  91. * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
  92. * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
  93. * sharelist - specifies another OSMesaContext with which to share
  94. * display lists. NULL indicates no sharing.
  95. * Return: an OSMesaContext or 0 if error
  96. */
  97. GLAPI OSMesaContext GLAPIENTRY
  98. OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
  99. /*
  100. * Create an Off-Screen Mesa rendering context and specify desired
  101. * size of depth buffer, stencil buffer and accumulation buffer.
  102. * If you specify zero for depthBits, stencilBits, accumBits you
  103. * can save some memory.
  104. *
  105. * New in Mesa 3.5
  106. */
  107. GLAPI OSMesaContext GLAPIENTRY
  108. OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
  109. GLint accumBits, OSMesaContext sharelist);
  110. /*
  111. * Destroy an Off-Screen Mesa rendering context.
  112. *
  113. * Input: ctx - the context to destroy
  114. */
  115. GLAPI void GLAPIENTRY
  116. OSMesaDestroyContext( OSMesaContext ctx );
  117. /*
  118. * Bind an OSMesaContext to an image buffer. The image buffer is just a
  119. * block of memory which the client provides. Its size must be at least
  120. * as large as width*height*sizeof(type). Its address should be a multiple
  121. * of 4 if using RGBA mode.
  122. *
  123. * Image data is stored in the order of glDrawPixels: row-major order
  124. * with the lower-left image pixel stored in the first array position
  125. * (ie. bottom-to-top).
  126. *
  127. * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
  128. * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
  129. * value. If the context is in color indexed mode, each pixel will be
  130. * stored as a 1-byte value.
  131. *
  132. * If the context's viewport hasn't been initialized yet, it will now be
  133. * initialized to (0,0,width,height).
  134. *
  135. * Input: ctx - the rendering context
  136. * buffer - the image buffer memory
  137. * type - data type for pixel components, only GL_UNSIGNED_BYTE
  138. * supported now
  139. * width, height - size of image buffer in pixels, at least 1
  140. * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
  141. * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
  142. * width>internal limit or height>internal limit.
  143. */
  144. GLAPI GLboolean GLAPIENTRY
  145. OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
  146. GLsizei width, GLsizei height );
  147. /*
  148. * Return the current Off-Screen Mesa rendering context handle.
  149. */
  150. GLAPI OSMesaContext GLAPIENTRY
  151. OSMesaGetCurrentContext( void );
  152. /*
  153. * Set pixel store/packing parameters for the current context.
  154. * This is similar to glPixelStore.
  155. * Input: pname - OSMESA_ROW_LENGTH
  156. * specify actual pixels per row in image buffer
  157. * 0 = same as image width (default)
  158. * OSMESA_Y_UP
  159. * zero = Y coordinates increase downward
  160. * non-zero = Y coordinates increase upward (default)
  161. * value - the value for the parameter pname
  162. *
  163. * New in version 2.0.
  164. */
  165. GLAPI void GLAPIENTRY
  166. OSMesaPixelStore( GLint pname, GLint value );
  167. /*
  168. * Return an integer value like glGetIntegerv.
  169. * Input: pname -
  170. * OSMESA_WIDTH return current image width
  171. * OSMESA_HEIGHT return current image height
  172. * OSMESA_FORMAT return image format
  173. * OSMESA_TYPE return color component data type
  174. * OSMESA_ROW_LENGTH return row length in pixels
  175. * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
  176. * value - pointer to integer in which to return result.
  177. */
  178. GLAPI void GLAPIENTRY
  179. OSMesaGetIntegerv( GLint pname, GLint *value );
  180. /*
  181. * Return the depth buffer associated with an OSMesa context.
  182. * Input: c - the OSMesa context
  183. * Output: width, height - size of buffer in pixels
  184. * bytesPerValue - bytes per depth value (2 or 4)
  185. * buffer - pointer to depth buffer values
  186. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  187. *
  188. * New in Mesa 2.4.
  189. */
  190. GLAPI GLboolean GLAPIENTRY
  191. OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
  192. GLint *bytesPerValue, void **buffer );
  193. /*
  194. * Return the color buffer associated with an OSMesa context.
  195. * Input: c - the OSMesa context
  196. * Output: width, height - size of buffer in pixels
  197. * format - buffer format (OSMESA_FORMAT)
  198. * buffer - pointer to depth buffer values
  199. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  200. *
  201. * New in Mesa 3.3.
  202. */
  203. GLAPI GLboolean GLAPIENTRY
  204. OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
  205. GLint *format, void **buffer );
  206. /*
  207. * Return pointer to the named function.
  208. *
  209. * New in Mesa 4.1
  210. */
  211. GLAPI void * GLAPIENTRY
  212. OSMesaGetProcAddress( const char *funcName );
  213. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  214. #pragma export off
  215. #endif
  216. #ifdef __cplusplus
  217. }
  218. #endif
  219. #endif