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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /* $Id: osmesa.h,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
  2. /*
  3. * Mesa 3-D graphics library
  4. * Version: 3.1
  5. *
  6. * Copyright (C) 1999 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. * $Log: osmesa.h,v $
  27. * Revision 1.1 1999/08/19 00:55:40 jtg
  28. * Initial revision
  29. *
  30. * Revision 1.4 1999/02/14 03:39:09 brianp
  31. * new copyright
  32. *
  33. * Revision 1.3 1999/01/03 02:52:30 brianp
  34. * now using GLAPI and GLAPIENTRY keywords (Ted Jump)
  35. *
  36. * Revision 1.2 1998/07/26 01:33:51 brianp
  37. * added WINGDIAPI and APIENTRY keywords per Ted Jump
  38. *
  39. * Revision 1.1 1998/02/13 03:17:50 brianp
  40. * Initial revision
  41. *
  42. */
  43. /*
  44. * Mesa Off-Screen rendering interface.
  45. *
  46. * This is an operating system and window system independent interface to
  47. * Mesa which allows one to render images into a client-supplied buffer in
  48. * main memory. Such images may manipulated or saved in whatever way the
  49. * client wants.
  50. *
  51. * These are the API functions:
  52. * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
  53. * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
  54. * and make the specified context the current one.
  55. * OSMesaDestroyContext - destroy an OSMesaContext
  56. * OSMesaGetCurrentContext - return thread's current context ID
  57. * OSMesaPixelStore - controls how pixels are stored in image buffer
  58. * OSMesaGetIntegerv - return OSMesa state parameters
  59. *
  60. *
  61. * The limits on the width and height of an image buffer are MAX_WIDTH and
  62. * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024.
  63. * You can increase them as needed but beware that many temporary arrays in
  64. * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
  65. */
  66. #ifndef OSMESA_H
  67. #define OSMESA_H
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71. #include "GL/gl.h"
  72. #define OSMESA_MAJOR_VERSION 3
  73. #define OSMESA_MINOR_VERSION 0
  74. /*
  75. * Values for the format parameter of OSMesaCreateContext()
  76. * New in version 2.0.
  77. */
  78. #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
  79. #define OSMESA_RGBA GL_RGBA
  80. #define OSMESA_BGRA 0x1
  81. #define OSMESA_ARGB 0x2
  82. #define OSMESA_RGB GL_RGB
  83. #define OSMESA_BGR 0x4
  84. /*
  85. * OSMesaPixelStore() parameters:
  86. * New in version 2.0.
  87. */
  88. #define OSMESA_ROW_LENGTH 0x10
  89. #define OSMESA_Y_UP 0x11
  90. /*
  91. * Accepted by OSMesaGetIntegerv:
  92. */
  93. #define OSMESA_WIDTH 0x20
  94. #define OSMESA_HEIGHT 0x21
  95. #define OSMESA_FORMAT 0x22
  96. #define OSMESA_TYPE 0x23
  97. typedef struct osmesa_context *OSMesaContext;
  98. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  99. #pragma export on
  100. #endif
  101. /*
  102. * Create an Off-Screen Mesa rendering context. The only attribute needed is
  103. * an RGBA vs Color-Index mode flag.
  104. *
  105. * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
  106. * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
  107. * sharelist - specifies another OSMesaContext with which to share
  108. * display lists. NULL indicates no sharing.
  109. * Return: an OSMesaContext or 0 if error
  110. */
  111. GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContext( GLenum format,
  112. OSMesaContext sharelist );
  113. /*
  114. * Destroy an Off-Screen Mesa rendering context.
  115. *
  116. * Input: ctx - the context to destroy
  117. */
  118. GLAPI void GLAPIENTRY OSMesaDestroyContext( OSMesaContext ctx );
  119. /*
  120. * Bind an OSMesaContext to an image buffer. The image buffer is just a
  121. * block of memory which the client provides. Its size must be at least
  122. * as large as width*height*sizeof(type). Its address should be a multiple
  123. * of 4 if using RGBA mode.
  124. *
  125. * Image data is stored in the order of glDrawPixels: row-major order
  126. * with the lower-left image pixel stored in the first array position
  127. * (ie. bottom-to-top).
  128. *
  129. * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
  130. * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
  131. * value. If the context is in color indexed mode, each pixel will be
  132. * stored as a 1-byte value.
  133. *
  134. * If the context's viewport hasn't been initialized yet, it will now be
  135. * initialized to (0,0,width,height).
  136. *
  137. * Input: ctx - the rendering context
  138. * buffer - the image buffer memory
  139. * type - data type for pixel components, only GL_UNSIGNED_BYTE
  140. * supported now
  141. * width, height - size of image buffer in pixels, at least 1
  142. * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
  143. * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
  144. * width>internal limit or height>internal limit.
  145. */
  146. GLAPI GLboolean GLAPIENTRY OSMesaMakeCurrent( OSMesaContext ctx,
  147. void *buffer, GLenum type,
  148. GLsizei width, GLsizei height );
  149. /*
  150. * Return the current Off-Screen Mesa rendering context handle.
  151. */
  152. GLAPI OSMesaContext GLAPIENTRY OSMesaGetCurrentContext( void );
  153. /*
  154. * Set pixel store/packing parameters for the current context.
  155. * This is similar to glPixelStore.
  156. * Input: pname - OSMESA_ROW_LENGTH
  157. * specify actual pixels per row in image buffer
  158. * 0 = same as image width (default)
  159. * OSMESA_Y_UP
  160. * zero = Y coordinates increase downward
  161. * non-zero = Y coordinates increase upward (default)
  162. * value - the value for the parameter pname
  163. *
  164. * New in version 2.0.
  165. */
  166. GLAPI void GLAPIENTRY OSMesaPixelStore( GLint pname, GLint value );
  167. /*
  168. * Return context info. This is 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 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 OSMesaGetDepthBuffer( OSMesaContext c,
  190. GLint *width, GLint *height,
  191. GLint *bytesPerValue, void **buffer );
  192. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  193. #pragma export off
  194. #endif
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif