| 547 | } |
| 548 | |
| 549 | void GFXGLDevice::clear(U32 flags, const LinearColorF& color, F32 z, U32 stencil) |
| 550 | { |
| 551 | // Make sure we have flushed our render target state. |
| 552 | _updateRenderTargets(); |
| 553 | |
| 554 | bool writeAllColors = true; |
| 555 | bool zwrite = true; |
| 556 | bool writeAllStencil = true; |
| 557 | const GFXStateBlockDesc *desc = NULL; |
| 558 | if (mCurrentGLStateBlock) |
| 559 | { |
| 560 | desc = &mCurrentGLStateBlock->getDesc(); |
| 561 | zwrite = desc->zWriteEnable; |
| 562 | writeAllColors = desc->colorWriteRed && desc->colorWriteGreen && desc->colorWriteBlue && desc->colorWriteAlpha; |
| 563 | writeAllStencil = desc->stencilWriteMask == 0xFFFFFFFF; |
| 564 | } |
| 565 | |
| 566 | glColorMask(true, true, true, true); |
| 567 | glDepthMask(true); |
| 568 | glStencilMask(0xFFFFFFFF); |
| 569 | glClearColor(color.red, color.green, color.blue, color.alpha); |
| 570 | glClearDepth(z); |
| 571 | glClearStencil(stencil); |
| 572 | |
| 573 | GLbitfield clearflags = 0; |
| 574 | clearflags |= (flags & GFXClearTarget) ? GL_COLOR_BUFFER_BIT : 0; |
| 575 | clearflags |= (flags & GFXClearZBuffer) ? GL_DEPTH_BUFFER_BIT : 0; |
| 576 | clearflags |= (flags & GFXClearStencil) ? GL_STENCIL_BUFFER_BIT : 0; |
| 577 | |
| 578 | glClear(clearflags); |
| 579 | |
| 580 | if(!writeAllColors) |
| 581 | glColorMask(desc->colorWriteRed, desc->colorWriteGreen, desc->colorWriteBlue, desc->colorWriteAlpha); |
| 582 | |
| 583 | if(!zwrite) |
| 584 | glDepthMask(false); |
| 585 | |
| 586 | if(!writeAllStencil) |
| 587 | glStencilMask(desc->stencilWriteMask); |
| 588 | } |
| 589 | |
| 590 | void GFXGLDevice::clearColorAttachment(const U32 attachment, const LinearColorF& color) |
| 591 | { |
no test coverage detected