Clone of mesa.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* $Id: osmesa.h,v 1.6 2000/09/08 16:41:38 brianp Exp $ */
  2. /*
  3. * Mesa 3-D graphics library
  4. * Version: 3.5
  5. *
  6. * Copyright (C) 1999-2000 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 3
  55. #define OSMESA_MINOR_VERSION 5
  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. /*
  67. * OSMesaPixelStore() parameters:
  68. * New in version 2.0.
  69. */
  70. #define OSMESA_ROW_LENGTH 0x10
  71. #define OSMESA_Y_UP 0x11
  72. /*
  73. * Accepted by OSMesaGetIntegerv:
  74. */
  75. #define OSMESA_WIDTH 0x20
  76. #define OSMESA_HEIGHT 0x21
  77. #define OSMESA_FORMAT 0x22
  78. #define OSMESA_TYPE 0x23
  79. typedef struct osmesa_context *OSMesaContext;
  80. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  81. #pragma export on
  82. #endif
  83. /*
  84. * Create an Off-Screen Mesa rendering context. The only attribute needed is
  85. * an RGBA vs Color-Index mode flag.
  86. *
  87. * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
  88. * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
  89. * sharelist - specifies another OSMesaContext with which to share
  90. * display lists. NULL indicates no sharing.
  91. * Return: an OSMesaContext or 0 if error
  92. */
  93. GLAPI OSMesaContext GLAPIENTRY
  94. OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
  95. /*
  96. * Create an Off-Screen Mesa rendering context and specify desired
  97. * size of depth buffer, stencil buffer and accumulation buffer.
  98. * If you specify zero for depthBits, stencilBits, accumBits you
  99. * can save some memory.
  100. *
  101. * New in Mesa 3.5
  102. */
  103. GLAPI OSMesaContext GLAPIENTRY
  104. OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
  105. GLint accumBits, OSMesaContext sharelist);
  106. /*
  107. * Destroy an Off-Screen Mesa rendering context.
  108. *
  109. * Input: ctx - the context to destroy
  110. */
  111. GLAPI void GLAPIENTRY
  112. OSMesaDestroyContext( OSMesaContext ctx );
  113. /*
  114. * Bind an OSMesaContext to an image buffer. The image buffer is just a
  115. * block of memory which the client provides. Its size must be at least
  116. * as large as width*height*sizeof(type). Its address should be a multiple
  117. * of 4 if using RGBA mode.
  118. *
  119. * Image data is stored in the order of glDrawPixels: row-major order
  120. * with the lower-left image pixel stored in the first array position
  121. * (ie. bottom-to-top).
  122. *
  123. * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
  124. * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
  125. * value. If the context is in color indexed mode, each pixel will be
  126. * stored as a 1-byte value.
  127. *
  128. * If the context's viewport hasn't been initialized yet, it will now be
  129. * initialized to (0,0,width,height).
  130. *
  131. * Input: ctx - the rendering context
  132. * buffer - the image buffer memory
  133. * type - data type for pixel components, only GL_UNSIGNED_BYTE
  134. * supported now
  135. * width, height - size of image buffer in pixels, at least 1
  136. * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
  137. * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
  138. * width>internal limit or height>internal limit.
  139. */
  140. GLAPI GLboolean GLAPIENTRY
  141. OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
  142. GLsizei width, GLsizei height );
  143. /*
  144. * Return the current Off-Screen Mesa rendering context handle.
  145. */
  146. GLAPI OSMesaContext GLAPIENTRY
  147. OSMesaGetCurrentContext( void );
  148. /*
  149. * Set pixel store/packing parameters for the current context.
  150. * This is similar to glPixelStore.
  151. * Input: pname - OSMESA_ROW_LENGTH
  152. * specify actual pixels per row in image buffer
  153. * 0 = same as image width (default)
  154. * OSMESA_Y_UP
  155. * zero = Y coordinates increase downward
  156. * non-zero = Y coordinates increase upward (default)
  157. * value - the value for the parameter pname
  158. *
  159. * New in version 2.0.
  160. */
  161. GLAPI void GLAPIENTRY
  162. OSMesaPixelStore( GLint pname, GLint value );
  163. /*
  164. * Return an integer value like glGetIntegerv.
  165. * Input: pname -
  166. * OSMESA_WIDTH return current image width
  167. * OSMESA_HEIGHT return current image height
  168. * OSMESA_FORMAT return image format
  169. * OSMESA_TYPE return color component data type
  170. * OSMESA_ROW_LENGTH return row length in pixels
  171. * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
  172. * value - pointer to integer in which to return result.
  173. */
  174. GLAPI void GLAPIENTRY
  175. OSMesaGetIntegerv( GLint pname, GLint *value );
  176. /*
  177. * Return the depth buffer associated with an OSMesa context.
  178. * Input: c - the OSMesa context
  179. * Output: width, height - size of buffer in pixels
  180. * bytesPerValue - bytes per depth value (2 or 4)
  181. * buffer - pointer to depth buffer values
  182. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  183. *
  184. * New in Mesa 2.4.
  185. */
  186. GLAPI GLboolean GLAPIENTRY
  187. OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
  188. GLint *bytesPerValue, void **buffer );
  189. /*
  190. * Return the color buffer associated with an OSMesa context.
  191. * Input: c - the OSMesa context
  192. * Output: width, height - size of buffer in pixels
  193. * format - buffer format (OSMESA_FORMAT)
  194. * buffer - pointer to depth buffer values
  195. * Return: GL_TRUE or GL_FALSE to indicate success or failure.
  196. *
  197. * New in Mesa 3.3.
  198. */
  199. GLAPI GLboolean GLAPIENTRY
  200. OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
  201. GLint *format, void **buffer );
  202. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  203. #pragma export off
  204. #endif
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208. #endif