1 /* $Id: pb.h,v 1.4 1997/11/13 02:16:48 brianp Exp $ */
4 * Mesa 3-D graphics library
6 * Copyright (C) 1995-1997 Brian Paul
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.
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.
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.
26 * Revision 1.4 1997/11/13 02:16:48 brianp
27 * added lambda array, initialized to zeros
29 * Revision 1.3 1997/05/09 22:40:19 brianp
32 * Revision 1.2 1997/02/09 18:43:14 brianp
33 * added GL_EXT_texture3D support
35 * Revision 1.1 1996/09/13 01:38:16 brianp
50 * Pixel buffer size, must be larger than MAX_WIDTH.
52 #define PB_SIZE (3*MAX_WIDTH)
56 GLint x
[PB_SIZE
]; /* X window coord in [0,MAX_WIDTH) */
57 GLint y
[PB_SIZE
]; /* Y window coord in [0,MAX_HEIGHT) */
58 GLdepth z
[PB_SIZE
]; /* Z window coord in [0,MAX_DEPTH] */
59 GLubyte r
[PB_SIZE
]; /* Red */
60 GLubyte g
[PB_SIZE
]; /* Green */
61 GLubyte b
[PB_SIZE
]; /* Blue */
62 GLubyte a
[PB_SIZE
]; /* Alpha */
63 GLuint i
[PB_SIZE
]; /* Index */
64 GLfloat s
[PB_SIZE
]; /* Texture S coordinate */
65 GLfloat t
[PB_SIZE
]; /* Texture T coordinate */
66 GLfloat u
[PB_SIZE
]; /* Texture R coordinate */
67 GLfloat lambda
[PB_SIZE
];/* Texture lambda value */
68 GLint color
[4]; /* Mono color, integers! */
69 GLuint index
; /* Mono index */
70 GLuint count
; /* Number of pixels in buffer */
71 GLboolean mono
; /* Same color or index for all pixels? */
72 GLenum primitive
; /* GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP*/
77 * Initialize the Pixel Buffer, specifying the type of primitive being drawn.
79 #define PB_INIT( PB, PRIM ) \
81 (PB)->mono = GL_FALSE; \
82 (PB)->primitive = (PRIM);
87 * Set the color used for all subsequent pixels in the buffer.
89 #define PB_SET_COLOR( CTX, PB, R, G, B, A ) \
90 if ((PB)->color[0]!=(R) || (PB)->color[1]!=(G) \
91 || (PB)->color[2]!=(B) || (PB)->color[3]!=(A) \
103 * Set the color index used for all subsequent pixels in the buffer.
105 #define PB_SET_INDEX( CTX, PB, I ) \
106 if ((PB)->index!=(I) || !(PB)->mono) { \
107 gl_flush_pb( CTX ); \
110 (PB)->mono = GL_TRUE;
114 * "write" a pixel using current color or index
116 #define PB_WRITE_PIXEL( PB, X, Y, Z ) \
117 (PB)->x[(PB)->count] = X; \
118 (PB)->y[(PB)->count] = Y; \
119 (PB)->z[(PB)->count] = Z; \
124 * "write" an RGBA pixel
126 #define PB_WRITE_RGBA_PIXEL( PB, X, Y, Z, R, G, B, A ) \
127 (PB)->x[(PB)->count] = X; \
128 (PB)->y[(PB)->count] = Y; \
129 (PB)->z[(PB)->count] = Z; \
130 (PB)->r[(PB)->count] = R; \
131 (PB)->g[(PB)->count] = G; \
132 (PB)->b[(PB)->count] = B; \
133 (PB)->a[(PB)->count] = A; \
137 * "write" a color-index pixel
139 #define PB_WRITE_CI_PIXEL( PB, X, Y, Z, I ) \
140 (PB)->x[(PB)->count] = X; \
141 (PB)->y[(PB)->count] = Y; \
142 (PB)->z[(PB)->count] = Z; \
143 (PB)->i[(PB)->count] = I; \
148 * "write" an RGBA pixel with texture coordinates
150 #define PB_WRITE_TEX_PIXEL( PB, X, Y, Z, R, G, B, A, S, T, U ) \
151 (PB)->x[(PB)->count] = X; \
152 (PB)->y[(PB)->count] = Y; \
153 (PB)->z[(PB)->count] = Z; \
154 (PB)->r[(PB)->count] = R; \
155 (PB)->g[(PB)->count] = G; \
156 (PB)->b[(PB)->count] = B; \
157 (PB)->a[(PB)->count] = A; \
158 (PB)->s[(PB)->count] = S; \
159 (PB)->t[(PB)->count] = T; \
160 (PB)->u[(PB)->count] = U; \
165 * Call this function at least every MAX_WIDTH pixels:
167 #define PB_CHECK_FLUSH( CTX, PB ) \
168 if ((PB)->count>=PB_SIZE-MAX_WIDTH) { \
169 gl_flush_pb( CTX ); \
173 extern struct pixel_buffer
*gl_alloc_pb(void);
175 extern void gl_flush_pb( GLcontext
*ctx
);