9df1f5e098c4b4996e05b5a5ab2793d3ecf5c14c
[mesa.git] / src / mesa / main / clear.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file clear.c
28 * glClearColor, glClearIndex, glClear() functions.
29 */
30
31
32
33 #include "glheader.h"
34 #include "clear.h"
35 #include "context.h"
36 #include "colormac.h"
37 #include "enums.h"
38 #include "macros.h"
39 #include "mtypes.h"
40 #include "state.h"
41
42
43
44 void GLAPIENTRY
45 _mesa_ClearIndex( GLfloat c )
46 {
47 GET_CURRENT_CONTEXT(ctx);
48
49 ctx->Color.ClearIndex = (GLuint) c;
50 }
51
52
53 /**
54 * Specify the clear values for the color buffers.
55 *
56 * \param red red color component.
57 * \param green green color component.
58 * \param blue blue color component.
59 * \param alpha alpha component.
60 *
61 * \sa glClearColor().
62 *
63 * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a
64 * change, flushes the vertices and notifies the driver via the
65 * dd_function_table::ClearColor callback.
66 */
67 void GLAPIENTRY
68 _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
69 {
70 GET_CURRENT_CONTEXT(ctx);
71
72 ctx->Color.ClearColor.f[0] = red;
73 ctx->Color.ClearColor.f[1] = green;
74 ctx->Color.ClearColor.f[2] = blue;
75 ctx->Color.ClearColor.f[3] = alpha;
76 }
77
78
79 /**
80 * GL_EXT_texture_integer
81 */
82 void GLAPIENTRY
83 _mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a)
84 {
85 GET_CURRENT_CONTEXT(ctx);
86
87 ctx->Color.ClearColor.i[0] = r;
88 ctx->Color.ClearColor.i[1] = g;
89 ctx->Color.ClearColor.i[2] = b;
90 ctx->Color.ClearColor.i[3] = a;
91 }
92
93
94 /**
95 * GL_EXT_texture_integer
96 */
97 void GLAPIENTRY
98 _mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a)
99 {
100 GET_CURRENT_CONTEXT(ctx);
101
102 ctx->Color.ClearColor.ui[0] = r;
103 ctx->Color.ClearColor.ui[1] = g;
104 ctx->Color.ClearColor.ui[2] = b;
105 ctx->Color.ClearColor.ui[3] = a;
106 }
107
108
109 /**
110 * Returns true if color writes are enabled for the given color attachment.
111 *
112 * Beyond checking ColorMask, this uses _mesa_format_has_color_component to
113 * ignore components that don't actually exist in the format (such as X in
114 * XRGB).
115 */
116 static bool
117 color_buffer_writes_enabled(const struct gl_context *ctx, unsigned idx)
118 {
119 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[idx];
120 GLuint c;
121 GLubyte colorMask = 0;
122
123 if (rb) {
124 for (c = 0; c < 4; c++) {
125 if (_mesa_format_has_color_component(rb->Format, c))
126 colorMask |= ctx->Color.ColorMask[idx][c];
127 }
128 }
129
130 return colorMask != 0;
131 }
132
133
134 /**
135 * Clear buffers.
136 *
137 * \param mask bit-mask indicating the buffers to be cleared.
138 *
139 * Flushes the vertices and verifies the parameter. If __struct gl_contextRec::NewState
140 * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin,
141 * etc. If the rasterization mode is set to GL_RENDER then requests the driver
142 * to clear the buffers, via the dd_function_table::Clear callback.
143 */
144 void GLAPIENTRY
145 _mesa_Clear( GLbitfield mask )
146 {
147 GET_CURRENT_CONTEXT(ctx);
148 FLUSH_VERTICES(ctx, 0);
149
150 FLUSH_CURRENT(ctx, 0);
151
152 if (MESA_VERBOSE & VERBOSE_API)
153 _mesa_debug(ctx, "glClear 0x%x\n", mask);
154
155 if (mask & ~(GL_COLOR_BUFFER_BIT |
156 GL_DEPTH_BUFFER_BIT |
157 GL_STENCIL_BUFFER_BIT |
158 GL_ACCUM_BUFFER_BIT)) {
159 /* invalid bit set */
160 _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
161 return;
162 }
163
164 /* Accumulation buffers were removed in core contexts, and they never
165 * existed in OpenGL ES.
166 */
167 if ((mask & GL_ACCUM_BUFFER_BIT) != 0
168 && (ctx->API == API_OPENGL_CORE || _mesa_is_gles(ctx))) {
169 _mesa_error( ctx, GL_INVALID_VALUE, "glClear(GL_ACCUM_BUFFER_BIT)");
170 return;
171 }
172
173 if (ctx->NewState) {
174 _mesa_update_state( ctx ); /* update _Xmin, etc */
175 }
176
177 if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
178 _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
179 "glClear(incomplete framebuffer)");
180 return;
181 }
182
183 if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 ||
184 ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax ||
185 ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
186 return;
187
188 if (ctx->RasterDiscard)
189 return;
190
191 if (ctx->RenderMode == GL_RENDER) {
192 GLbitfield bufferMask;
193
194 /* don't clear depth buffer if depth writing disabled */
195 if (!ctx->Depth.Mask)
196 mask &= ~GL_DEPTH_BUFFER_BIT;
197
198 /* Build the bitmask to send to device driver's Clear function.
199 * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
200 * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
201 * BUFFER_BIT_COLORn flags.
202 */
203 bufferMask = 0;
204 if (mask & GL_COLOR_BUFFER_BIT) {
205 GLuint i;
206 for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
207 GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
208
209 if (buf >= 0 && color_buffer_writes_enabled(ctx, i)) {
210 bufferMask |= 1 << buf;
211 }
212 }
213 }
214
215 if ((mask & GL_DEPTH_BUFFER_BIT)
216 && ctx->DrawBuffer->Visual.haveDepthBuffer) {
217 bufferMask |= BUFFER_BIT_DEPTH;
218 }
219
220 if ((mask & GL_STENCIL_BUFFER_BIT)
221 && ctx->DrawBuffer->Visual.haveStencilBuffer) {
222 bufferMask |= BUFFER_BIT_STENCIL;
223 }
224
225 if ((mask & GL_ACCUM_BUFFER_BIT)
226 && ctx->DrawBuffer->Visual.haveAccumBuffer) {
227 bufferMask |= BUFFER_BIT_ACCUM;
228 }
229
230 ASSERT(ctx->Driver.Clear);
231 ctx->Driver.Clear(ctx, bufferMask);
232 }
233 }
234
235
236 /** Returned by make_color_buffer_mask() for errors */
237 #define INVALID_MASK ~0x0
238
239
240 /**
241 * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of
242 * BUFFER_BIT_x values.
243 * Return INVALID_MASK if the drawbuffer value is invalid.
244 */
245 static GLbitfield
246 make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
247 {
248 const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment;
249 GLbitfield mask = 0x0;
250
251 /* From the GL 4.0 specification:
252 * If buffer is COLOR, a particular draw buffer DRAW_BUFFERi is
253 * specified by passing i as the parameter drawbuffer, and value
254 * points to a four-element vector specifying the R, G, B, and A
255 * color to clear that draw buffer to. If the draw buffer is one
256 * of FRONT, BACK, LEFT, RIGHT, or FRONT_AND_BACK, identifying
257 * multiple buffers, each selected buffer is cleared to the same
258 * value.
259 *
260 * Note that "drawbuffer" and "draw buffer" have different meaning.
261 * "drawbuffer" specifies DRAW_BUFFERi, while "draw buffer" is what's
262 * assigned to DRAW_BUFFERi. It could be COLOR_ATTACHMENT0, FRONT, BACK,
263 * etc.
264 */
265 if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) {
266 return INVALID_MASK;
267 }
268
269 switch (ctx->DrawBuffer->ColorDrawBuffer[drawbuffer]) {
270 case GL_FRONT:
271 if (att[BUFFER_FRONT_LEFT].Renderbuffer)
272 mask |= BUFFER_BIT_FRONT_LEFT;
273 if (att[BUFFER_FRONT_RIGHT].Renderbuffer)
274 mask |= BUFFER_BIT_FRONT_RIGHT;
275 break;
276 case GL_BACK:
277 if (att[BUFFER_BACK_LEFT].Renderbuffer)
278 mask |= BUFFER_BIT_BACK_LEFT;
279 if (att[BUFFER_BACK_RIGHT].Renderbuffer)
280 mask |= BUFFER_BIT_BACK_RIGHT;
281 break;
282 case GL_LEFT:
283 if (att[BUFFER_FRONT_LEFT].Renderbuffer)
284 mask |= BUFFER_BIT_FRONT_LEFT;
285 if (att[BUFFER_BACK_LEFT].Renderbuffer)
286 mask |= BUFFER_BIT_BACK_LEFT;
287 break;
288 case GL_RIGHT:
289 if (att[BUFFER_FRONT_RIGHT].Renderbuffer)
290 mask |= BUFFER_BIT_FRONT_RIGHT;
291 if (att[BUFFER_BACK_RIGHT].Renderbuffer)
292 mask |= BUFFER_BIT_BACK_RIGHT;
293 break;
294 case GL_FRONT_AND_BACK:
295 if (att[BUFFER_FRONT_LEFT].Renderbuffer)
296 mask |= BUFFER_BIT_FRONT_LEFT;
297 if (att[BUFFER_BACK_LEFT].Renderbuffer)
298 mask |= BUFFER_BIT_BACK_LEFT;
299 if (att[BUFFER_FRONT_RIGHT].Renderbuffer)
300 mask |= BUFFER_BIT_FRONT_RIGHT;
301 if (att[BUFFER_BACK_RIGHT].Renderbuffer)
302 mask |= BUFFER_BIT_BACK_RIGHT;
303 break;
304 default:
305 {
306 GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[drawbuffer];
307
308 if (buf >= 0 && att[buf].Renderbuffer) {
309 mask |= 1 << buf;
310 }
311 }
312 }
313
314 return mask;
315 }
316
317
318
319 /**
320 * New in GL 3.0
321 * Clear signed integer color buffer or stencil buffer (not depth).
322 */
323 void GLAPIENTRY
324 _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
325 {
326 GET_CURRENT_CONTEXT(ctx);
327 FLUSH_VERTICES(ctx, 0);
328
329 FLUSH_CURRENT(ctx, 0);
330
331 if (ctx->NewState) {
332 _mesa_update_state( ctx );
333 }
334
335 switch (buffer) {
336 case GL_STENCIL:
337 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
338 *
339 * "ClearBuffer generates an INVALID VALUE error if buffer is
340 * COLOR and drawbuffer is less than zero, or greater than the
341 * value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
342 * STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
343 */
344 if (drawbuffer != 0) {
345 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
346 drawbuffer);
347 return;
348 }
349 else if (ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer && !ctx->RasterDiscard) {
350 /* Save current stencil clear value, set to 'value', do the
351 * stencil clear and restore the clear value.
352 * XXX in the future we may have a new ctx->Driver.ClearBuffer()
353 * hook instead.
354 */
355 const GLuint clearSave = ctx->Stencil.Clear;
356 ctx->Stencil.Clear = *value;
357 ctx->Driver.Clear(ctx, BUFFER_BIT_STENCIL);
358 ctx->Stencil.Clear = clearSave;
359 }
360 break;
361 case GL_COLOR:
362 {
363 const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
364 if (mask == INVALID_MASK) {
365 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
366 drawbuffer);
367 return;
368 }
369 else if (mask && !ctx->RasterDiscard) {
370 union gl_color_union clearSave;
371
372 /* save color */
373 clearSave = ctx->Color.ClearColor;
374 /* set color */
375 COPY_4V(ctx->Color.ClearColor.i, value);
376 /* clear buffer(s) */
377 ctx->Driver.Clear(ctx, mask);
378 /* restore color */
379 ctx->Color.ClearColor = clearSave;
380 }
381 }
382 break;
383 case GL_DEPTH:
384 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
385 *
386 * "The result of ClearBuffer is undefined if no conversion between
387 * the type of the specified value and the type of the buffer being
388 * cleared is defined (for example, if ClearBufferiv is called for a
389 * fixed- or floating-point buffer, or if ClearBufferfv is called
390 * for a signed or unsigned integer buffer). This is not an error."
391 *
392 * In this case we take "undefined" and "not an error" to mean "ignore."
393 * Note that we still need to generate an error for the invalid
394 * drawbuffer case (see the GL_STENCIL case above).
395 */
396 if (drawbuffer != 0) {
397 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
398 drawbuffer);
399 return;
400 }
401 return;
402 default:
403 _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)",
404 _mesa_lookup_enum_by_nr(buffer));
405 return;
406 }
407 }
408
409
410 /**
411 * New in GL 3.0
412 * Clear unsigned integer color buffer (not depth, not stencil).
413 */
414 void GLAPIENTRY
415 _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
416 {
417 GET_CURRENT_CONTEXT(ctx);
418
419 FLUSH_VERTICES(ctx, 0);
420 FLUSH_CURRENT(ctx, 0);
421
422 if (ctx->NewState) {
423 _mesa_update_state( ctx );
424 }
425
426 switch (buffer) {
427 case GL_COLOR:
428 {
429 const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
430 if (mask == INVALID_MASK) {
431 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)",
432 drawbuffer);
433 return;
434 }
435 else if (mask && !ctx->RasterDiscard) {
436 union gl_color_union clearSave;
437
438 /* save color */
439 clearSave = ctx->Color.ClearColor;
440 /* set color */
441 COPY_4V(ctx->Color.ClearColor.ui, value);
442 /* clear buffer(s) */
443 ctx->Driver.Clear(ctx, mask);
444 /* restore color */
445 ctx->Color.ClearColor = clearSave;
446 }
447 }
448 break;
449 case GL_DEPTH:
450 case GL_STENCIL:
451 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
452 *
453 * "The result of ClearBuffer is undefined if no conversion between
454 * the type of the specified value and the type of the buffer being
455 * cleared is defined (for example, if ClearBufferiv is called for a
456 * fixed- or floating-point buffer, or if ClearBufferfv is called
457 * for a signed or unsigned integer buffer). This is not an error."
458 *
459 * In this case we take "undefined" and "not an error" to mean "ignore."
460 * Even though we could do something sensible for GL_STENCIL, page 263
461 * (page 279 of the PDF) says:
462 *
463 * "Only ClearBufferiv should be used to clear stencil buffers."
464 *
465 * Note that we still need to generate an error for the invalid
466 * drawbuffer case (see the GL_STENCIL case in _mesa_ClearBufferiv).
467 */
468 if (drawbuffer != 0) {
469 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)",
470 drawbuffer);
471 return;
472 }
473 return;
474 default:
475 _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)",
476 _mesa_lookup_enum_by_nr(buffer));
477 return;
478 }
479 }
480
481
482 /**
483 * New in GL 3.0
484 * Clear fixed-pt or float color buffer or depth buffer (not stencil).
485 */
486 void GLAPIENTRY
487 _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
488 {
489 GET_CURRENT_CONTEXT(ctx);
490
491 FLUSH_VERTICES(ctx, 0);
492 FLUSH_CURRENT(ctx, 0);
493
494 if (ctx->NewState) {
495 _mesa_update_state( ctx );
496 }
497
498 switch (buffer) {
499 case GL_DEPTH:
500 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
501 *
502 * "ClearBuffer generates an INVALID VALUE error if buffer is
503 * COLOR and drawbuffer is less than zero, or greater than the
504 * value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
505 * STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
506 */
507 if (drawbuffer != 0) {
508 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
509 drawbuffer);
510 return;
511 }
512 else if (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer && !ctx->RasterDiscard) {
513 /* Save current depth clear value, set to 'value', do the
514 * depth clear and restore the clear value.
515 * XXX in the future we may have a new ctx->Driver.ClearBuffer()
516 * hook instead.
517 */
518 const GLclampd clearSave = ctx->Depth.Clear;
519 ctx->Depth.Clear = *value;
520 ctx->Driver.Clear(ctx, BUFFER_BIT_DEPTH);
521 ctx->Depth.Clear = clearSave;
522 }
523 /* clear depth buffer to value */
524 break;
525 case GL_COLOR:
526 {
527 const GLbitfield mask = make_color_buffer_mask(ctx, drawbuffer);
528 if (mask == INVALID_MASK) {
529 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
530 drawbuffer);
531 return;
532 }
533 else if (mask && !ctx->RasterDiscard) {
534 union gl_color_union clearSave;
535
536 /* save color */
537 clearSave = ctx->Color.ClearColor;
538 /* set color */
539 COPY_4V(ctx->Color.ClearColor.f, value);
540 /* clear buffer(s) */
541 ctx->Driver.Clear(ctx, mask);
542 /* restore color */
543 ctx->Color.ClearColor = clearSave;
544 }
545 }
546 break;
547 case GL_STENCIL:
548 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
549 *
550 * "The result of ClearBuffer is undefined if no conversion between
551 * the type of the specified value and the type of the buffer being
552 * cleared is defined (for example, if ClearBufferiv is called for a
553 * fixed- or floating-point buffer, or if ClearBufferfv is called
554 * for a signed or unsigned integer buffer). This is not an error."
555 *
556 * In this case we take "undefined" and "not an error" to mean "ignore."
557 * Note that we still need to generate an error for the invalid
558 * drawbuffer case (see the GL_DEPTH case above).
559 */
560 if (drawbuffer != 0) {
561 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
562 drawbuffer);
563 return;
564 }
565 return;
566 default:
567 _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)",
568 _mesa_lookup_enum_by_nr(buffer));
569 return;
570 }
571 }
572
573
574 /**
575 * New in GL 3.0
576 * Clear depth/stencil buffer only.
577 */
578 void GLAPIENTRY
579 _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
580 GLfloat depth, GLint stencil)
581 {
582 GET_CURRENT_CONTEXT(ctx);
583 GLbitfield mask = 0;
584
585 FLUSH_VERTICES(ctx, 0);
586 FLUSH_CURRENT(ctx, 0);
587
588 if (buffer != GL_DEPTH_STENCIL) {
589 _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfi(buffer=%s)",
590 _mesa_lookup_enum_by_nr(buffer));
591 return;
592 }
593
594 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
595 *
596 * "ClearBuffer generates an INVALID VALUE error if buffer is
597 * COLOR and drawbuffer is less than zero, or greater than the
598 * value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
599 * STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
600 */
601 if (drawbuffer != 0) {
602 _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfi(drawbuffer=%d)",
603 drawbuffer);
604 return;
605 }
606
607 if (ctx->RasterDiscard)
608 return;
609
610 if (ctx->NewState) {
611 _mesa_update_state( ctx );
612 }
613
614 if (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer)
615 mask |= BUFFER_BIT_DEPTH;
616 if (ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer)
617 mask |= BUFFER_BIT_STENCIL;
618
619 if (mask) {
620 /* save current clear values */
621 const GLclampd clearDepthSave = ctx->Depth.Clear;
622 const GLuint clearStencilSave = ctx->Stencil.Clear;
623
624 /* set new clear values */
625 ctx->Depth.Clear = depth;
626 ctx->Stencil.Clear = stencil;
627
628 /* clear buffers */
629 ctx->Driver.Clear(ctx, mask);
630
631 /* restore */
632 ctx->Depth.Clear = clearDepthSave;
633 ctx->Stencil.Clear = clearStencilSave;
634 }
635 }