2 * Mesa 3-D graphics library
4 * Copyright (C) 1995-1998 Brian Paul
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 static void clear_color_generic(GLcontext
*ctx
, const GLfloat color
[4])
23 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
25 CLAMPED_FLOAT_TO_UBYTE(r
, color
[0]);
26 CLAMPED_FLOAT_TO_UBYTE(g
, color
[1]);
27 CLAMPED_FLOAT_TO_UBYTE(b
, color
[2]);
28 context
->ClearColor
= makecol(r
, g
, b
);
32 static void set_color_generic(GLcontext
*ctx
,
33 GLubyte red
, GLubyte green
,
34 GLubyte blue
, GLubyte alpha
)
36 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
38 context
->CurrentColor
= makecol(red
, green
, blue
);
42 static GLbitfield
clear_generic(GLcontext
*ctx
,
43 GLbitfield mask
, GLboolean all
,
45 GLint width
, GLint height
)
47 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
49 if (mask
& GL_COLOR_BUFFER_BIT
)
52 clear_to_color(context
->Buffer
->Active
, context
->ClearColor
);
54 rect(context
->Buffer
->Active
,
55 x
, y
, x
+width
-1, y
+height
-1,
59 return mask
& (~GL_COLOR_BUFFER_BIT
);
63 static void write_rgba_span_generic(const GLcontext
*ctx
,
64 GLuint n
, GLint x
, GLint y
,
65 const GLubyte rgba
[][4],
68 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
69 BITMAP
*bmp
= context
->Buffer
->Active
;
77 if (mask
[0]) putpixel(bmp
, x
, y
, makecol(rgba
[0][RCOMP
], rgba
[0][GCOMP
], rgba
[0][BCOMP
]));
85 putpixel(bmp
, x
, y
, makecol(rgba
[0][RCOMP
], rgba
[0][GCOMP
], rgba
[0][BCOMP
]));
92 static void write_rgb_span_generic(const GLcontext
*ctx
,
93 GLuint n
, GLint x
, GLint y
,
94 const GLubyte rgb
[][3],
97 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
98 BITMAP
*bmp
= context
->Buffer
->Active
;
100 y
= FLIP(context
, y
);
106 if (mask
[0]) putpixel(bmp
, x
, y
, makecol(rgb
[0][RCOMP
], rgb
[0][GCOMP
], rgb
[0][BCOMP
]));
114 putpixel(bmp
, x
, y
, makecol(rgb
[0][RCOMP
], rgb
[0][GCOMP
], rgb
[0][BCOMP
]));
121 static void write_mono_rgba_span_generic(const GLcontext
*ctx
,
122 GLuint n
, GLint x
, GLint y
,
123 const GLubyte mask
[])
125 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
126 BITMAP
*bmp
= context
->Buffer
->Active
;
127 int color
= context
->CurrentColor
;
129 y
= FLIP(context
, y
);
135 if (mask
[0]) putpixel(bmp
, x
, y
, color
);
143 putpixel(bmp
, x
, y
, color
);
150 static void read_rgba_span_generic(const GLcontext
*ctx
,
151 GLuint n
, GLint x
, GLint y
,
154 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
155 BITMAP
*bmp
= context
->Buffer
->Active
;
157 y
= FLIP(context
, y
);
161 int color
= getpixel(bmp
, x
, y
);
163 rgba
[0][RCOMP
] = getr(color
);
164 rgba
[0][GCOMP
] = getg(color
);
165 rgba
[0][BCOMP
] = getb(color
);
166 rgba
[0][ACOMP
] = 255;
173 static void write_rgba_pixels_generic(const GLcontext
*ctx
,
177 const GLubyte rgba
[][4],
178 const GLubyte mask
[])
180 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
181 BITMAP
*bmp
= context
->Buffer
->Active
;
185 if (mask
[0]) putpixel(bmp
, x
[0], FLIP(context
, y
[0]), makecol(rgba
[0][RCOMP
], rgba
[0][GCOMP
], rgba
[0][BCOMP
]));
191 static void write_mono_rgba_pixels_generic(const GLcontext
*ctx
,
195 const GLubyte mask
[])
197 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
198 BITMAP
*bmp
= context
->Buffer
->Active
;
199 int color
= context
->CurrentColor
;
203 if (mask
[0]) putpixel(bmp
, x
[0], FLIP(context
, y
[0]), color
);
209 static void read_rgba_pixels_generic(const GLcontext
*ctx
,
214 const GLubyte mask
[])
216 AMesaContext context
= (AMesaContext
)(ctx
->DriverCtx
);
217 BITMAP
*bmp
= context
->Buffer
->Active
;
223 int color
= getpixel(bmp
, x
[0], FLIP(context
, y
[0]));
225 rgba
[0][RCOMP
] = getr(color
);
226 rgba
[0][GCOMP
] = getg(color
);
227 rgba
[0][BCOMP
] = getb(color
);
228 rgba
[0][ACOMP
] = 255;
231 x
++; y
++; mask
++; rgba
++;