Debian Codegraph @

debian/external_deps/fetk/sg/src/gl/dd.h

raw
1 /* $Id: dd.h,v 1.2 2000/10/27 15:21:40 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 #ifndef DD_INCLUDED
24 #define DD_INCLUDED
25
26
27 /* THIS FILE ONLY INCLUDED BY types.h !!!!! */
28
29
30 /*
31 * Device Driver (DD) interface
32 *
33 *
34 * All device driver functions are accessed through pointers in the
35 * dd_function_table struct (defined below) which is stored in the GLcontext
36 * struct. Since the device driver is strictly accessed trough a table of
37 * function pointers we can:
38 * 1. switch between a number of different device drivers at runtime.
39 * 2. use optimized functions dependant on current rendering state or
40 * frame buffer configuration.
41 *
42 * The function pointers in the dd_function_table struct are divided into
43 * two groups: mandatory and optional.
44 * Mandatory functions have to be implemented by every device driver.
45 * Optional functions may or may not be implemented by the device driver.
46 * The optional functions provide ways to take advantage of special hardware
47 * or optimized algorithms.
48 *
49 * The function pointers in the dd_function_table struct are first
50 * initialized in the "MakeCurrent" function. The "MakeCurrent" function
51 * is a little different in each divice driver. See the X/Mesa, GLX, or
52 * OS/Mesa drivers for examples.
53 *
54 * Later, Mesa may call the dd_function_table's UpdateState() function.
55 * This function should initialize the dd_function_table's pointers again.
56 * The UpdateState() function is called whenever the core (GL) rendering
57 * state is changed in a way which may effect rasterization. For example,
58 * the TriangleFunc() pointer may have to point to different functions
59 * depending on whether smooth or flat shading is enabled.
60 *
61 * Note that the first argument to every device driver function is a
62 * GLcontext *. In turn, the GLcontext->DriverCtx pointer points to
63 * the driver-specific context struct. See the X/Mesa or OS/Mesa interface
64 * for an example.
65 *
66 * For more information about writing a device driver see the ddsample.c
67 * file and other device drivers (xmesa[123].c, osmesa.c, etc) for examples.
68 *
69 *
70 * Look below in the dd_function_table struct definition for descriptions
71 * of each device driver function.
72 *
73 *
74 * In the future more function pointers may be added for glReadPixels
75 * glCopyPixels, etc.
76 *
77 *
78 * Notes:
79 * ------
80 * RGBA = red/green/blue/alpha
81 * CI = color index (color mapped mode)
82 * mono = all pixels have the same color or index
83 *
84 * The write_ functions all take an array of mask flags which indicate
85 * whether or not the pixel should be written. One special case exists
86 * in the write_color_span function: if the mask array is NULL, then
87 * draw all pixels. This is an optimization used for glDrawPixels().
88 *
89 * IN ALL CASES:
90 * X coordinates start at 0 at the left and increase to the right
91 * Y coordinates start at 0 at the bottom and increase upward
92 *
93 */
94
95
96
97
98
99 /*
100 * Device Driver function table.
101 */
102 struct dd_function_table {
103
104 /**********************************************************************
105 *** Mandatory functions: these functions must be implemented by ***
106 *** every device driver. ***
107 **********************************************************************/
108
109 void (*UpdateState)( GLcontext *ctx );
110 /*
111 * UpdateState() is called whenver Mesa thinks the device driver should
112 * update its state and/or the other pointers (such as PointsFunc,
113 * LineFunc, or TriangleFunc).
114 */
115
116 void (*ClearIndex)( GLcontext *ctx, GLuint index );
117 /*
118 * Called whenever glClearIndex() is called. Set the index for clearing
119 * the color buffer.
120 */
121
122 void (*ClearColor)( GLcontext *ctx, GLubyte red, GLubyte green,
123 GLubyte blue, GLubyte alpha );
124 /*
125 * Called whenever glClearColor() is called. Set the color for clearing
126 * the color buffer.
127 */
128
129 void (*Clear)( GLcontext *ctx,
130 GLboolean all, GLint x, GLint y, GLint width, GLint height );
131 /*
132 * Clear the current color buffer. If 'all' is set the clear the whole
133 * buffer, else clear the region defined by (x,y,width,height).
134 */
135
136 void (*Index)( GLcontext *ctx, GLuint index );
137 /*
138 * Sets current color index for drawing flat-shaded primitives.
139 */
140
141 void (*Color)( GLcontext *ctx,
142 GLubyte red, GLubyte green, GLubyte glue, GLubyte alpha );
143 /*
144 * Sets current color for drawing flat-shaded primitives.
145 */
146
147 GLboolean (*SetBuffer)( GLcontext *ctx, GLenum mode );
148 /*
149 * Selects either the front or back color buffer for reading and writing.
150 * mode is either GL_FRONT or GL_BACK.
151 */
152
153 void (*GetBufferSize)( GLcontext *ctx,
154 GLuint *width, GLuint *height );
155 /*
156 * Returns the width and height of the current color buffer.
157 */
158
159
160 /***
161 *** Functions for writing pixels to the frame buffer:
162 ***/
163 void (*WriteColorSpan)( GLcontext *ctx,
164 GLuint n, GLint x, GLint y,
165 const GLubyte red[], const GLubyte green[],
166 const GLubyte blue[], const GLubyte alpha[],
167 const GLubyte mask[] );
168 /*
169 * Write a horizontal run of RGBA pixels.
170 */
171
172 void (*WriteMonocolorSpan)( GLcontext *ctx,
173 GLuint n, GLint x, GLint y,
174 const GLubyte mask[] );
175 /*
176 * Write a horizontal run of mono-RGBA pixels.
177 */
178
179 void (*WriteColorPixels)( GLcontext *ctx,
180 GLuint n, const GLint x[], const GLint y[],
181 const GLubyte red[], const GLubyte green[],
182 const GLubyte blue[], const GLubyte alpha[],
183 const GLubyte mask[] );
184 /*
185 * Write an array of RGBA pixels at random locations.
186 */
187
188 void (*WriteMonocolorPixels)( GLcontext *ctx,
189 GLuint n, const GLint x[], const GLint y[],
190 const GLubyte mask[] );
191 /*
192 * Write an array of mono-RGBA pixels at random locations.
193 */
194
195 void (*WriteIndexSpan)( GLcontext *ctx,
196 GLuint n, GLint x, GLint y, const GLuint index[],
197 const GLubyte mask[] );
198 /*
199 * Write a horizontal run of CI pixels.
200 */
201
202 void (*WriteMonoindexSpan)( GLcontext *ctx,
203 GLuint n, GLint x, GLint y,
204 const GLubyte mask[] );
205 /*
206 * Write a horizontal run of mono-CI pixels.
207 */
208
209 void (*WriteIndexPixels)( GLcontext *ctx,
210 GLuint n, const GLint x[], const GLint y[],
211 const GLuint index[], const GLubyte mask[] );
212 /*
213 * Write a random array of CI pixels.
214 */
215
216 void (*WriteMonoindexPixels)( GLcontext *ctx,
217 GLuint n, const GLint x[], const GLint y[],
218 const GLubyte mask[] );
219 /*
220 * Write a random array of mono-CI pixels.
221 */
222
223 /***
224 *** Functions to read pixels from frame buffer:
225 ***/
226 void (*ReadIndexSpan)( GLcontext *ctx,
227 GLuint n, GLint x, GLint y, GLuint index[] );
228 /*
229 * Read a horizontal run of color index pixels.
230 */
231
232 void (*ReadColorSpan)( GLcontext *ctx,
233 GLuint n, GLint x, GLint y,
234 GLubyte red[], GLubyte green[],
235 GLubyte blue[], GLubyte alpha[] );
236 /*
237 * Read a horizontal run of RGBA pixels.
238 */
239
240 void (*ReadIndexPixels)( GLcontext *ctx,
241 GLuint n, const GLint x[], const GLint y[],
242 GLuint indx[], const GLubyte mask[] );
243 /*
244 * Read a random array of CI pixels.
245 */
246
247 void (*ReadColorPixels)( GLcontext *ctx,
248 GLuint n, const GLint x[], const GLint y[],
249 GLubyte red[], GLubyte green[],
250 GLubyte blue[], GLubyte alpha[],
251 const GLubyte mask[] );
252 /*
253 * Read a random array of RGBA pixels.
254 */
255
256
257 /**********************************************************************
258 *** Optional functions: these functions may or may not be ***
259 *** implemented by the device driver. If the device driver ***
260 *** doesn't implement them it should never touch these pointers ***
261 *** since Mesa will either set them to NULL or point them at a ***
262 *** fall-back function. ***
263 **********************************************************************/
264
265 void (*Finish)( GLcontext *ctx );
266 /*
267 * Called whenever glFinish() is called.
268 */
269
270 void (*Flush)( GLcontext *ctx );
271 /*
272 * Called whenever glFlush() is called.
273 */
274
275 GLboolean (*IndexMask)( GLcontext *ctx, GLuint mask );
276 /*
277 * Implements glIndexMask() if possible, else return GL_FALSE.
278 */
279
280 GLboolean (*ColorMask)( GLcontext *ctx,
281 GLboolean rmask, GLboolean gmask,
282 GLboolean bmask, GLboolean amask );
283 /*
284 * Implements glColorMask() if possible, else return GL_FALSE.
285 */
286
287 GLboolean (*LogicOp)( GLcontext *ctx, GLenum op );
288 /*
289 * Implements glLogicOp() if possible, else return GL_FALSE.
290 */
291
292 void (*Dither)( GLcontext *ctx, GLboolean enable );
293 /*
294 * Enable/disable dithering.
295 */
296
297 void (*Error)( GLcontext *ctx );
298 /*
299 * Called whenever an error is generated. ctx->ErrorValue contains
300 * the error value.
301 */
302
303
304 /***
305 *** For supporting hardware Z buffers:
306 ***/
307
308 void (*AllocDepthBuffer)( GLcontext *ctx );
309 /*
310 * Called when the depth buffer must be allocated or possibly resized.
311 */
312
313 void (*ClearDepthBuffer)( GLcontext *ctx );
314 /*
315 * Clear the depth buffer to depth specified by CC.Depth.Clear value.
316 */
317
318 GLuint (*DepthTestSpan)( GLcontext *ctx,
319 GLuint n, GLint x, GLint y, const GLdepth z[],
320 GLubyte mask[] );
321 void (*DepthTestPixels)( GLcontext *ctx,
322 GLuint n, const GLint x[], const GLint y[],
323 const GLdepth z[], GLubyte mask[] );
324 /*
325 * Apply the depth buffer test to an span/array of pixels and return
326 * an updated pixel mask. This function is not used when accelerated
327 * point, line, polygon functions are used.
328 */
329
330 void (*ReadDepthSpanFloat)( GLcontext *ctx,
331 GLuint n, GLint x, GLint y, GLfloat depth[]);
332 void (*ReadDepthSpanInt)( GLcontext *ctx,
333 GLuint n, GLint x, GLint y, GLdepth depth[] );
334 /*
335 * Return depth values as integers for glReadPixels.
336 * Floats should be returned in the range [0,1].
337 * Ints (GLdepth) values should be in the range [0,MAXDEPTH].
338 */
339
340
341 /***
342 *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
343 ***/
344
345 points_func PointsFunc;
346 /*
347 * Called to draw an array of points.
348 */
349
350 line_func LineFunc;
351 /*
352 * Called to draw a line segment.
353 */
354
355 triangle_func TriangleFunc;
356 /*
357 * Called to draw a filled triangle.
358 */
359
360
361 /***
362 *** Misc functions:
363 ***/
364
365 GLboolean (*DrawPixels)( GLcontext *ctx,
366 GLint x, GLint y, GLsizei width, GLsizei height,
367 GLenum format, GLenum type, GLboolean packed,
368 const GLvoid *pixels );
369 /*
370 * Called from glDrawPixels().
371 */
372
373 GLboolean (*Bitmap)( GLcontext *ctx, GLsizei width, GLsizei height,
374 GLfloat xorig, GLfloat yorig,
375 GLfloat xmove, GLfloat ymove,
376 const struct gl_image *bitmap );
377 /*
378 * Called from glBitmap().
379 */
380
381 void (*Begin)( GLcontext *ctx, GLenum mode );
382 void (*End)( GLcontext *ctx );
383 /*
384 * These are called whenever glBegin() or glEnd() are called.
385 * The device driver may do some sort of window locking/unlocking here.
386 */
387
388
389 /***
390 *** Texture mapping functions:
391 ***/
392
393 void (*TexEnv)( GLcontext *ctx, GLenum pname, const GLfloat *param );
394 /*
395 * Called whenever glTexEnv*() is called.
396 * Pname will be one of GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR.
397 * If pname is GL_TEXTURE_ENV_MODE then param will be one
398 * of GL_MODULATE, GL_BLEND, GL_DECAL, or GL_REPLACE.
399 */
400
401 void (*TexImage)( GLcontext *ctx, GLenum target,
402 GLuint texObject, GLint level, GLint internalFormat,
403 const struct gl_texture_image *image );
404 /*
405 * Called whenever a texture object's image is changed.
406 * texObject is the number of the texture object being changed.
407 * level indicates the mipmap level.
408 * internalFormat is the format in which the texture is to be stored.
409 * image is a pointer to a gl_texture_image struct which contains
410 * the actual image data.
411 */
412
413 void (*TexParameter)( GLcontext *ctx, GLenum target, GLuint texObject,
414 GLenum pname, const GLfloat *params );
415 /*
416 * Called whenever glTexParameter*() is called.
417 * target is GL_TEXTURE_1D or GL_TEXTURE_2D
418 * texObject is the texture object to modify
419 * pname is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
420 * GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, or GL_TEXTURE_BORDER_COLOR.
421 * params is dependant on pname. See man glTexParameter.
422 */
423
424 void (*BindTexture)( GLcontext *ctx, GLenum target, GLuint texObject );
425 /*
426 * Called whenever glBindTexture() is called. This specifies which
427 * texture is to be the current one.
428 */
429
430 void (*DeleteTexture)( GLcontext *ctx, GLuint texObject );
431 /*
432 * Called when a texture object can be deallocated.
433 */
434
435 };
436
437
438
439 #endif
440