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 7.7KB

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