| 486 | } |
| 487 | |
| 488 | static bool renderOcclusionQueryGoldfeather(const std::vector<Primitive*>& primitives) |
| 489 | { |
| 490 | scissor = new ScissorMemo; |
| 491 | |
| 492 | unsigned int layer = 0; |
| 493 | |
| 494 | scissor->setIntersected(primitives); |
| 495 | scissor->setCurrent(primitives); |
| 496 | |
| 497 | OpenGL::OcclusionQuery* occlusionTest = 0; |
| 498 | |
| 499 | bool retVal = true; |
| 500 | |
| 501 | while (true) { |
| 502 | if (channelMgr->request() == NoChannel) { |
| 503 | channelMgr->free(); |
| 504 | channelMgr->request(); |
| 505 | } |
| 506 | |
| 507 | scissor->store(channelMgr->current()); |
| 508 | scissor->enableScissor(); |
| 509 | |
| 510 | if (!occlusionTest) { |
| 511 | occlusionTest = OpenGL::getOcclusionQuery(false); |
| 512 | if (!occlusionTest) { |
| 513 | retVal = false; |
| 514 | break; |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | channelMgr->renderToChannel(true); |
| 519 | |
| 520 | glStencilMask(OpenGL::stencilMask); |
| 521 | glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 522 | |
| 523 | glDepthFunc(GL_ALWAYS); |
| 524 | glDepthMask(GL_TRUE); |
| 525 | glColor4ub(255, 255, 255, 255); |
| 526 | |
| 527 | occlusionTest->beginQuery(); |
| 528 | OpenGL::renderLayer(layer, primitives); |
| 529 | occlusionTest->endQuery(); |
| 530 | // the fragment count query could occur here, but benches show that |
| 531 | // the algorithm is faster if the query is delayed. |
| 532 | glClear(GL_STENCIL_BUFFER_BIT); |
| 533 | |
| 534 | parityTestAndDiscard(primitives, primitives, true, OpenGL::stencilMax); |
| 535 | |
| 536 | unsigned int anyFragmentRendered = occlusionTest->getQueryResult(); |
| 537 | if (!anyFragmentRendered) { |
| 538 | retVal = true; |
| 539 | break; |
| 540 | } |
| 541 | |
| 542 | channelMgr->store(channelMgr->current(), primitives, layer); |
| 543 | |
| 544 | scissor->disableScissor(); |
| 545 |
no test coverage detected