home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / Mesa-3.1 / include / GL / osmesa.h < prev   
C/C++ Source or Header  |  1999-09-01  |  8KB  |  257 lines

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