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