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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 4.1
  4. *
  5. * Copyright (C) 1999-2002 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. * Mesa Off-Screen rendering interface.
  26. *
  27. * This is an operating system and window system independent interface to
  28. * Mesa which allows one to render images into a client-supplied buffer in
  29. * main memory. Such images may manipulated or saved in whatever way the
  30. * client wants.
  31. *
  32. * These are the API functions:
  33. * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
  34. * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
  35. * and make the specified context the current one.
  36. * OSMesaDestroyContext - destroy an OSMesaContext
  37. * OSMesaGetCurrentContext - return thread's current context ID
  38. * OSMesaPixelStore - controls how pixels are stored in image buffer
  39. * OSMesaGetIntegerv - return OSMesa state parameters
  40. *
  41. *
  42. * The limits on the width and height of an image buffer are MAX_WIDTH and
  43. * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024.
  44. * You can increase them as needed but beware that many temporary arrays in
  45. * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
  46. */
  47. #ifndef OSMESA_H
  48. #define OSMESA_H
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. #include <GL/gl.h>
  53. #define OSMESA_MAJOR_VERSION 4
  54. #define OSMESA_MINOR_VERSION 1
  55. #define OSMESA_PATCH_VERSION 0
  56. /*
  57. * Values for the format parameter of OSMesaCreateContext()
  58. * New in version 2.0.
  59. */
  60. #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
  61. #define OSMESA_RGBA GL_RGBA
  62. #define OSMESA_BGRA 0x1
  63. #define OSMESA_ARGB 0x2
  64. #define OSMESA_RGB GL_RGB
  65. #define OSMESA_BGR 0x4
  66. #define OSMESA_RGB_565 0x5
  67. /*
  68. * OSMesaPixelStore() parameters:
  69. * New in version 2.0.
  70. */
  71. #define OSMESA_ROW_LENGTH 0x10
  72. #define OSMESA_Y_UP 0x11
  73. /*
  74. * Accepted by OSMesaGetIntegerv:
  75. */
  76. #define OSMESA_WIDTH 0x20
  77. #define OSMESA_HEIGHT 0x21
  78. #define OSMESA_FORMAT 0x22
  79. #define OSMESA_TYPE 0x23
  80. #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
  81. #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
  82. typedef struct osmesa_context *OSMesaContext;
  83. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  84. #pragma export on
  85. #endif
  86. /*
  87. * Create an Off-Screen Mesa rendering context. The only attribute needed is
  88. * an RGBA vs Color-Index mode flag.
  89. *
  90. * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
  91. * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
  92. * sharelist - specifies another OSMesaContext with which to share
  93. * display lists. NULL indicates no sharing.
  94. * Return: an OSMesaContext or 0 if error
  95. */
  96. GLAPI OSMesaContext GLAPIENTRY
  97. OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
  98. /*
  99. * Create an Off-Screen Mesa rendering context and specify desired
  100. * size of depth buffer, stencil buffer and accumulation buffer.
  101. * If you specify zero for depthBits, stencilBits, accumBits you
  102. * can save some memory.
  103. *
  104. * New in Mesa 3.5
  105. */
  106. GLAPI OSMesaContext GLAPIENTRY
  107. OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
  108. GLint accumBits, OSMesaContext sharelist);
  109. /*
  110. * Destroy an Off-Screen Mesa rendering context.
  111. *
  112. * Input: ctx - the context to destroy
  113. */
  114. GLAPI void GLAPIENTRY
  115. OSMesaDestroyContext( OSMesaContext ctx );
  116. /*
  117. * Bind an OSMesaContext to an image buffer. The image buffer is just a
  118. * block of memory which the client provides. Its size must be at least
  119. * as large as width*height*sizeof(type). Its address should be a multiple
  120. * of 4 if using RGBA mode.
  121. *
  122. * Image data is stored in the order of glDrawPixels: row-major order
  123. * with the lower-left image pixel stored in the first array position
  124. * (ie. bottom-to-top).
  125. *
  126. * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
  127. * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
  128. * value. If the context is in color indexed mode, each pixel will be
  129. * stored as a 1-byte value.
  130. *
  131. * If the context's viewport hasn't been initialized yet, it will now be
  132. * initialized to (0,0,width,height).
  133. *
  134. * Input: ctx - the rendering context
  135. * buffer - the image buffer memory
  136. * type - data type for pixel components, only GL_UNSIGNED_BYTE
  137. * supported now
  138. * width, height - size of image buffer in pixels, at least 1
  139. * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
  140. * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
  141. * width>internal limit or height>internal limit.
  142. */
  143. GLAPI GLboolean GLAPIENTRY
  144. OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
  145. GLsizei width, GLsizei height );
  146. /*
  147. * Return the current Off-Screen Mesa rendering context handle.
  148. */
  149. GLAPI OSMesaContext GLAPIENTRY
  150. OSMesaGetCurrentContext( void );
  151. /*
  152. * Set pixel store/packing parameters for the current context.
  153. * This is similar to glPixelStore.
  154. * Input: pname - OSMESA_ROW_LENGTH
  155. * specify actual pixels per row in image buffer
  156. * 0 = same as image width (default)
  157. * OSMESA_Y_UP
  158. * zero = Y coordinates increase downward
  159. * non-zero = Y coordinates increase upward (default)
  160. * value - the value for the parameter pname
  161. *
  162. * New in version 2.0.
  163. */
  164. GLAPI void GLAPIENTRY
  165. OSMesaPixelStore( GLint pname, GLint value );
  166. /*
  167. * Return an integer value like glGetIntegerv.
  168. * Input: pname -
  169. * OSMESA_WIDTH return current image width
  170. * OSMESA_HEIGHT return current image height
  171. * OSMESA_FORMAT return image format
  172. * OSMESA_TYPE return color component data type
  173. * OSMESA_ROW_LENGTH return row length in pixels
  174. * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
  175. * value - pointer to integer in which to return result.
  176. */
  177. GLAPI void GLAPIENTRY
  178. OSMesaGetIntegerv( GLint pname, GLint *value );
  179. /*
  180. * Return the depth buffer associated with an OSMesa context.
  181. * Input: c - the OSMesa context
  182. * Output: width, height - size of buffer in pixels
  183. * bytesPerValue - bytes per depth value (2 or 4)
  184. * buffer - pointer to depth buffer values
  185. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  186. *
  187. * New in Mesa 2.4.
  188. */
  189. GLAPI GLboolean GLAPIENTRY
  190. OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
  191. GLint *bytesPerValue, void **buffer );
  192. /*
  193. * Return the color buffer associated with an OSMesa context.
  194. * Input: c - the OSMesa context
  195. * Output: width, height - size of buffer in pixels
  196. * format - buffer format (OSMESA_FORMAT)
  197. * buffer - pointer to depth buffer values
  198. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  199. *
  200. * New in Mesa 3.3.
  201. */
  202. GLAPI GLboolean GLAPIENTRY
  203. OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
  204. GLint *format, void **buffer );
  205. /*
  206. * Return pointer to the named function.
  207. *
  208. * New in Mesa 4.1
  209. */
  210. GLAPI void * GLAPIENTRY
  211. OSMesaGetProcAddress( const char *funcName );
  212. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  213. #pragma export off
  214. #endif
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218. #endif