| 417 | } // unnamed namespace |
| 418 | |
| 419 | static void renderGoldfeather(const std::vector<Primitive*>& primitives) |
| 420 | { |
| 421 | scissor = new ScissorMemo; |
| 422 | |
| 423 | Batcher batches(primitives); |
| 424 | |
| 425 | scissor->setIntersected(primitives); |
| 426 | |
| 427 | for (std::vector<Batch>::const_iterator itr = batches.begin(); itr != batches.end(); ++itr) { |
| 428 | unsigned int maxConvexity = Algo::getConvexity(*itr); |
| 429 | for (unsigned int currentLayer = 0; currentLayer < maxConvexity; ++currentLayer) { |
| 430 | |
| 431 | if (channelMgr->request() == NoChannel) { |
| 432 | channelMgr->free(); |
| 433 | channelMgr->request(); |
| 434 | } |
| 435 | |
| 436 | channelMgr->renderToChannel(true); glColor4ub(255, 255, 255, 255); |
| 437 | glStencilMask(OpenGL::stencilMask); |
| 438 | glEnable(GL_STENCIL_TEST); |
| 439 | |
| 440 | glDepthFunc(GL_ALWAYS); |
| 441 | glDepthMask(GL_TRUE); |
| 442 | |
| 443 | scissor->setCurrent(*itr); |
| 444 | scissor->store(channelMgr->current()); |
| 445 | scissor->enableScissor(); |
| 446 | |
| 447 | if (maxConvexity == 1) { |
| 448 | // shapes of interest: we need to determine which parts of them are visible. |
| 449 | // first assume they are fully visible |
| 450 | glStencilFunc(GL_ALWAYS, 0, OpenGL::stencilMask); |
| 451 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
| 452 | glEnable(GL_CULL_FACE); |
| 453 | |
| 454 | for (Batch::const_iterator j = itr->begin(); j != itr->end(); ++j) { |
| 455 | glCullFace((*j)->getOperation() == Intersection ? GL_BACK : GL_FRONT); |
| 456 | (*j)->render(); |
| 457 | } |
| 458 | |
| 459 | glDisable(GL_CULL_FACE); |
| 460 | } else { |
| 461 | // shapes of interest: we need to determine the appropriate layer of |
| 462 | // the shapes, using stencil counting |
| 463 | glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 464 | OpenGL::renderLayer(currentLayer, *itr); |
| 465 | glClear(GL_STENCIL_BUFFER_BIT); |
| 466 | } |
| 467 | |
| 468 | GLenum depthFunc = getParityDepthFunc(); |
| 469 | if (depthFunc == GL_GREATER) |
| 470 | scissor->enableDepthBoundsFront(); |
| 471 | else if (depthFunc == GL_LEQUAL) |
| 472 | scissor->enableDepthBoundsBack(); |
| 473 | |
| 474 | parityTestAndDiscard(*itr, primitives, false, OpenGL::stencilMask); |
| 475 | |
| 476 | scissor->disableDepthBounds(); |
no test coverage detected