blob: 0e4a10b2f8b3c55065706eaabb97754390a4a660 [file] [log] [blame]
Brian Paul206eda82001-06-27 13:56:17 +00001/* $Id: osmesa.h,v 1.7 2001/06/27 13:56:17 brianp Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paul2bf5d942000-09-08 16:41:38 +00005 * Version: 3.5
jtgafb833d1999-08-19 00:55:39 +00006 *
Brian Paul187bce02000-01-18 17:29:18 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
jtgafb833d1999-08-19 00:55:39 +00008 *
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/*
jtgafb833d1999-08-19 00:55:39 +000029 * Mesa Off-Screen rendering interface.
30 *
31 * This is an operating system and window system independent interface to
32 * Mesa which allows one to render images into a client-supplied buffer in
33 * main memory. Such images may manipulated or saved in whatever way the
34 * client wants.
35 *
36 * These are the API functions:
37 * OSMesaCreateContext - create a new Off-Screen Mesa rendering context
38 * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer
39 * and make the specified context the current one.
40 * OSMesaDestroyContext - destroy an OSMesaContext
41 * OSMesaGetCurrentContext - return thread's current context ID
42 * OSMesaPixelStore - controls how pixels are stored in image buffer
43 * OSMesaGetIntegerv - return OSMesa state parameters
44 *
45 *
46 * The limits on the width and height of an image buffer are MAX_WIDTH and
47 * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024.
48 * You can increase them as needed but beware that many temporary arrays in
49 * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT.
50 */
51
52
jtgafb833d1999-08-19 00:55:39 +000053#ifndef OSMESA_H
54#define OSMESA_H
55
56
jtgafb833d1999-08-19 00:55:39 +000057#ifdef __cplusplus
58extern "C" {
59#endif
60
61
Brian Paul2bf5d942000-09-08 16:41:38 +000062#include <GL/gl.h>
jtgafb833d1999-08-19 00:55:39 +000063
64
jtgafb833d1999-08-19 00:55:39 +000065#define OSMESA_MAJOR_VERSION 3
Brian Paul2bf5d942000-09-08 16:41:38 +000066#define OSMESA_MINOR_VERSION 5
jtgafb833d1999-08-19 00:55:39 +000067
68
69
70/*
71 * Values for the format parameter of OSMesaCreateContext()
72 * New in version 2.0.
73 */
74#define OSMESA_COLOR_INDEX GL_COLOR_INDEX
75#define OSMESA_RGBA GL_RGBA
76#define OSMESA_BGRA 0x1
77#define OSMESA_ARGB 0x2
78#define OSMESA_RGB GL_RGB
79#define OSMESA_BGR 0x4
Brian Paul206eda82001-06-27 13:56:17 +000080#define OSMESA_RGB_565 0x5
jtgafb833d1999-08-19 00:55:39 +000081
82
83/*
84 * OSMesaPixelStore() parameters:
85 * New in version 2.0.
86 */
87#define OSMESA_ROW_LENGTH 0x10
88#define OSMESA_Y_UP 0x11
89
90
91/*
92 * Accepted by OSMesaGetIntegerv:
93 */
94#define OSMESA_WIDTH 0x20
95#define OSMESA_HEIGHT 0x21
96#define OSMESA_FORMAT 0x22
97#define OSMESA_TYPE 0x23
98
Brian Paul187bce02000-01-18 17:29:18 +000099
jtgafb833d1999-08-19 00:55:39 +0000100typedef struct osmesa_context *OSMesaContext;
101
102
103#if defined(__BEOS__) || defined(__QUICKDRAW__)
104#pragma export on
105#endif
106
107
108/*
109 * Create an Off-Screen Mesa rendering context. The only attribute needed is
110 * an RGBA vs Color-Index mode flag.
111 *
112 * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
113 * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
114 * sharelist - specifies another OSMesaContext with which to share
115 * display lists. NULL indicates no sharing.
116 * Return: an OSMesaContext or 0 if error
117 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000118GLAPI OSMesaContext GLAPIENTRY
119OSMesaCreateContext( GLenum format, OSMesaContext sharelist );
jtgafb833d1999-08-19 00:55:39 +0000120
121
122
Brian Paul2bf5d942000-09-08 16:41:38 +0000123/*
124 * Create an Off-Screen Mesa rendering context and specify desired
125 * size of depth buffer, stencil buffer and accumulation buffer.
126 * If you specify zero for depthBits, stencilBits, accumBits you
127 * can save some memory.
128 *
129 * New in Mesa 3.5
130 */
131GLAPI OSMesaContext GLAPIENTRY
132OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
133 GLint accumBits, OSMesaContext sharelist);
134
jtgafb833d1999-08-19 00:55:39 +0000135
136/*
137 * Destroy an Off-Screen Mesa rendering context.
138 *
139 * Input: ctx - the context to destroy
140 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000141GLAPI void GLAPIENTRY
142OSMesaDestroyContext( OSMesaContext ctx );
jtgafb833d1999-08-19 00:55:39 +0000143
144
145
146/*
147 * Bind an OSMesaContext to an image buffer. The image buffer is just a
148 * block of memory which the client provides. Its size must be at least
149 * as large as width*height*sizeof(type). Its address should be a multiple
150 * of 4 if using RGBA mode.
151 *
152 * Image data is stored in the order of glDrawPixels: row-major order
153 * with the lower-left image pixel stored in the first array position
154 * (ie. bottom-to-top).
155 *
156 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
157 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
158 * value. If the context is in color indexed mode, each pixel will be
159 * stored as a 1-byte value.
160 *
161 * If the context's viewport hasn't been initialized yet, it will now be
162 * initialized to (0,0,width,height).
163 *
164 * Input: ctx - the rendering context
165 * buffer - the image buffer memory
166 * type - data type for pixel components, only GL_UNSIGNED_BYTE
167 * supported now
168 * width, height - size of image buffer in pixels, at least 1
169 * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx,
170 * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
171 * width>internal limit or height>internal limit.
172 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000173GLAPI GLboolean GLAPIENTRY
174OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type,
175 GLsizei width, GLsizei height );
jtgafb833d1999-08-19 00:55:39 +0000176
177
178
179
180/*
181 * Return the current Off-Screen Mesa rendering context handle.
182 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000183GLAPI OSMesaContext GLAPIENTRY
184OSMesaGetCurrentContext( void );
jtgafb833d1999-08-19 00:55:39 +0000185
186
187
188/*
189 * Set pixel store/packing parameters for the current context.
190 * This is similar to glPixelStore.
191 * Input: pname - OSMESA_ROW_LENGTH
192 * specify actual pixels per row in image buffer
193 * 0 = same as image width (default)
194 * OSMESA_Y_UP
195 * zero = Y coordinates increase downward
196 * non-zero = Y coordinates increase upward (default)
197 * value - the value for the parameter pname
198 *
199 * New in version 2.0.
200 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000201GLAPI void GLAPIENTRY
202OSMesaPixelStore( GLint pname, GLint value );
jtgafb833d1999-08-19 00:55:39 +0000203
204
205
206/*
Brian Paul187bce02000-01-18 17:29:18 +0000207 * Return an integer value like glGetIntegerv.
jtgafb833d1999-08-19 00:55:39 +0000208 * Input: pname -
209 * OSMESA_WIDTH return current image width
210 * OSMESA_HEIGHT return current image height
211 * OSMESA_FORMAT return image format
212 * OSMESA_TYPE return color component data type
213 * OSMESA_ROW_LENGTH return row length in pixels
214 * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction
215 * value - pointer to integer in which to return result.
216 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000217GLAPI void GLAPIENTRY
218OSMesaGetIntegerv( GLint pname, GLint *value );
jtgafb833d1999-08-19 00:55:39 +0000219
Brian Paul187bce02000-01-18 17:29:18 +0000220
221
Randy Frank0deb3732000-01-15 06:12:18 +0000222/*
jtgafb833d1999-08-19 00:55:39 +0000223 * Return the depth buffer associated with an OSMesa context.
224 * Input: c - the OSMesa context
225 * Output: width, height - size of buffer in pixels
226 * bytesPerValue - bytes per depth value (2 or 4)
227 * buffer - pointer to depth buffer values
228 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
229 *
230 * New in Mesa 2.4.
231 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000232GLAPI GLboolean GLAPIENTRY
233OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
234 GLint *bytesPerValue, void **buffer );
235
jtgafb833d1999-08-19 00:55:39 +0000236
237
Randy Frank23ee0492000-03-28 16:59:39 +0000238/*
239 * Return the color buffer associated with an OSMesa context.
240 * Input: c - the OSMesa context
241 * Output: width, height - size of buffer in pixels
242 * format - buffer format (OSMESA_FORMAT)
243 * buffer - pointer to depth buffer values
244 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
245 *
246 * New in Mesa 3.3.
247 */
Brian Paul2bf5d942000-09-08 16:41:38 +0000248GLAPI GLboolean GLAPIENTRY
249OSMesaGetColorBuffer( OSMesaContext c, GLint *width, GLint *height,
250 GLint *format, void **buffer );
251
jtgafb833d1999-08-19 00:55:39 +0000252
253
254#if defined(__BEOS__) || defined(__QUICKDRAW__)
255#pragma export off
256#endif
257
258
259#ifdef __cplusplus
260}
261#endif
262
263
264#endif