home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / include / gl / osmesa.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  7.4 KB  |  259 lines

  1. /* $Id: osmesa.h,v 1.7 1997/09/29 23:22:16 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.5
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: osmesa.h,v $
  26.  * Revision 1.7  1997/09/29 23:22:16  brianp
  27.  * updated version to 2.5
  28.  *
  29.  * Revision 1.6  1997/07/11 23:07:16  brianp
  30.  * added OSMesaGetDepthBuffer function (Randy Frank)
  31.  *
  32.  * Revision 1.5  1997/02/19 10:13:54  brianp
  33.  * now test for __QUICKDRAW__ like for __BEOS__ (Randy Frank)
  34.  *
  35.  * Revision 1.4  1997/02/10 20:31:41  brianp
  36.  * added OSMESA_RGB and OSMESA_BGR, per Randy Frank
  37.  *
  38.  * Revision 1.3  1997/02/03 20:07:40  brianp
  39.  * patches for BeOS
  40.  *
  41.  * Revision 1.2  1996/10/30 03:12:30  brianp
  42.  * incremented version to 2.1
  43.  *
  44.  * Revision 1.1  1996/09/13 01:26:41  brianp
  45.  * Initial revision
  46.  *
  47.  */
  48.  
  49.  
  50. /*
  51.  * Mesa Off-Screen rendering interface.
  52.  *
  53.  * This is an operating system and window system independent interface to
  54.  * Mesa which allows one to render images into a client-supplied buffer in
  55.  * main memory.  Such images may manipulated or saved in whatever way the
  56.  * client wants.
  57.  *
  58.  * These are the API functions:
  59.  *   OSMesaCreateContext - create a new Off-Screen Mesa rendering context
  60.  *   OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
  61.  *                       and make the specified context the current one.
  62.  *   OSMesaDestroyContext - destroy an OSMesaContext
  63.  *   OSMesaGetCurrentContext - return thread's current context ID
  64.  *   OSMesaPixelStore - controls how pixels are stored in image buffer
  65.  *   OSMesaGetIntegerv - return OSMesa state parameters
  66.  *
  67.  *
  68.  * The limits on the width and height of an image buffer are MAX_WIDTH and
  69.  * MAX_HEIGHT as defined in Mesa/src/config.h.  Defaults are 1280 and 1024.
  70.  * You can increase them as needed but beware that many temporary arrays in
  71.  * Mesa are dimensioned by MAX_WIDTH or MAX_WIDTH.
  72.  */
  73.  
  74.  
  75.  
  76. #ifndef OSMESA_H
  77. #define OSMESA_H
  78.  
  79.  
  80.  
  81. #ifdef __cplusplus
  82. extern "C" {
  83. #endif
  84.  
  85.  
  86. #include "GL/gl.h"
  87.  
  88.  
  89.  
  90. #define OSMESA_MAJOR_VERSION 2
  91. #define OSMESA_MINOR_VERSION 5
  92.  
  93.  
  94.  
  95. /*
  96.  * Values for the format parameter of OSMesaCreateContext()
  97.  * New in version 2.0.
  98.  */
  99. #define OSMESA_COLOR_INDEX    GL_COLOR_INDEX
  100. #define OSMESA_RGBA        GL_RGBA
  101. #define OSMESA_BGRA        0x1
  102. #define OSMESA_ARGB        0x2
  103. #define OSMESA_RGB        GL_RGB
  104. #define OSMESA_BGR        0x4
  105.  
  106.  
  107. /*
  108.  * OSMesaPixelStore() parameters:
  109.  * New in version 2.0.
  110.  */
  111. #define OSMESA_ROW_LENGTH    0x10
  112. #define OSMESA_Y_UP        0x11
  113.  
  114.  
  115. /*
  116.  * Accepted by OSMesaGetIntegerv:
  117.  */
  118. #define OSMESA_WIDTH        0x20
  119. #define OSMESA_HEIGHT        0x21
  120. #define OSMESA_FORMAT        0x22
  121. #define OSMESA_TYPE        0x23
  122.  
  123.  
  124.  
  125. typedef struct osmesa_context *OSMesaContext;
  126.  
  127.  
  128. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  129. #pragma export on
  130. #endif
  131.  
  132.  
  133. /*
  134.  * Create an Off-Screen Mesa rendering context.  The only attribute needed is
  135.  * an RGBA vs Color-Index mode flag.
  136.  *
  137.  * Input:  format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
  138.  *                  OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
  139.  *         sharelist - specifies another OSMesaContext with which to share
  140.  *                     display lists.  NULL indicates no sharing.
  141.  * Return:  an OSMesaContext or 0 if error
  142.  */
  143. extern OSMesaContext OSMesaCreateContext( GLenum format,
  144.                                           OSMesaContext sharelist );
  145.  
  146.  
  147.  
  148.  
  149. /*
  150.  * Destroy an Off-Screen Mesa rendering context.
  151.  *
  152.  * Input:  ctx - the context to destroy
  153.  */
  154. extern void OSMesaDestroyContext( OSMesaContext ctx );
  155.  
  156.  
  157.  
  158. /*
  159.  * Bind an OSMesaContext to an image buffer.  The image buffer is just a
  160.  * block of memory which the client provides.  Its size must be at least
  161.  * as large as width*height*sizeof(type).  Its address should be a multiple
  162.  * of 4 if using RGBA mode.
  163.  *
  164.  * Image data is stored in the order of glDrawPixels:  row-major order
  165.  * with the lower-left image pixel stored in the first array position
  166.  * (ie. bottom-to-top).
  167.  *
  168.  * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
  169.  * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
  170.  * value.  If the context is in color indexed mode, each pixel will be
  171.  * stored as a 1-byte value.
  172.  *
  173.  * If the context's viewport hasn't been initialized yet, it will now be
  174.  * initialized to (0,0,width,height).
  175.  *
  176.  * Input:  ctx - the rendering context
  177.  *         buffer - the image buffer memory
  178.  *         type - data type for pixel components, only GL_UNSIGNED_BYTE
  179.  *                supported now
  180.  *         width, height - size of image buffer in pixels, at least 1
  181.  * Return:  GL_TRUE if success, GL_FALSE if error because of invalid ctx,
  182.  *          invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
  183.  *          width>internal limit or height>internal limit.
  184.  */
  185. extern GLboolean OSMesaMakeCurrent( OSMesaContext ctx,
  186.                                     void *buffer, GLenum type,
  187.                                     GLsizei width, GLsizei height );
  188.  
  189.  
  190.  
  191.  
  192. /*
  193.  * Return the current Off-Screen Mesa rendering context handle.
  194.  */
  195. extern OSMesaContext OSMesaGetCurrentContext( void );
  196.  
  197.  
  198.  
  199. /*
  200.  * Set pixel store/packing parameters for the current context.
  201.  * This is similar to glPixelStore.
  202.  * Input:  pname - OSMESA_ROW_LENGTH
  203.  *                    specify actual pixels per row in image buffer
  204.  *                    0 = same as image width (default)
  205.  *                 OSMESA_Y_UP
  206.  *                    zero = Y coordinates increase downward
  207.  *                    non-zero = Y coordinates increase upward (default)
  208.  *         value - the value for the parameter pname
  209.  *
  210.  * New in version 2.0.
  211.  */
  212. extern void OSMesaPixelStore( GLint pname, GLint value );
  213.  
  214.  
  215.  
  216. /*
  217.  * Return context info.  This is like glGetIntegerv.
  218.  * Input:  pname -
  219.  *                 OSMESA_WIDTH  return current image width
  220.  *                 OSMESA_HEIGHT  return current image height
  221.  *                 OSMESA_FORMAT  return image format
  222.  *                 OSMESA_TYPE  return color component data type
  223.  *                 OSMESA_ROW_LENGTH return row length in pixels
  224.  *                 OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
  225.  *         value - pointer to integer in which to return result.
  226.  */
  227. extern void OSMesaGetIntegerv( GLint pname, GLint *value );
  228.  
  229.  
  230.  
  231. /*
  232.  * Return the depth buffer associated with an OSMesa context.
  233.  * Input:  c - the OSMesa context
  234.  * Output:  width, height - size of buffer in pixels
  235.  *          bytesPerValue - bytes per depth value (2 or 4)
  236.  *          buffer - pointer to depth buffer values
  237.  * Return:  GL_TRUE or GL_FALSE to indicate success or failure.
  238.  *
  239.  * New in Mesa 2.4.
  240.  */
  241. extern GLboolean OSMesaGetDepthBuffer( OSMesaContext c,
  242.                                        GLint *width, GLint *height,
  243.                                        GLint *bytesPerValue, void **buffer );
  244.  
  245.  
  246.  
  247.  
  248. #if defined(__BEOS__) || defined(__QUICKDRAW__)
  249. #pragma export off
  250. #endif
  251.  
  252.  
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256.  
  257.  
  258. #endif
  259.