| 546 | } |
| 547 | |
| 548 | GLShaderPtr |
| 549 | OSGLContext::getOrCreateCopyUnprocessedChannelsShader(bool doR, |
| 550 | bool doG, |
| 551 | bool doB, |
| 552 | bool doA) |
| 553 | { |
| 554 | int index = 0x0; |
| 555 | |
| 556 | if (doR) { |
| 557 | index |= 0x01; |
| 558 | } |
| 559 | if (doG) { |
| 560 | index |= 0x02; |
| 561 | } |
| 562 | if (doB) { |
| 563 | index |= 0x04; |
| 564 | } |
| 565 | if (doA) { |
| 566 | index |= 0x08; |
| 567 | } |
| 568 | if (_imp->copyUnprocessedChannelsShader[index]) { |
| 569 | return _imp->copyUnprocessedChannelsShader[index]; |
| 570 | } |
| 571 | _imp->copyUnprocessedChannelsShader[index] = std::make_shared<GLShader>(); |
| 572 | |
| 573 | std::string fragmentSource; |
| 574 | if (!doR) { |
| 575 | fragmentSource += "#define DO_R\n"; |
| 576 | } |
| 577 | if (!doG) { |
| 578 | fragmentSource += "#define DO_G\n"; |
| 579 | } |
| 580 | if (!doB) { |
| 581 | fragmentSource += "#define DO_B\n"; |
| 582 | } |
| 583 | if (!doA) { |
| 584 | fragmentSource += "#define DO_A\n"; |
| 585 | } |
| 586 | fragmentSource += std::string(copyUnprocessedChannels_FragmentShader); |
| 587 | |
| 588 | |
| 589 | #ifdef DEBUG |
| 590 | std::string error; |
| 591 | bool ok = _imp->copyUnprocessedChannelsShader[index]->addShader(GLShader::eShaderTypeFragment, fragmentSource.c_str(), &error); |
| 592 | if (!ok) { |
| 593 | qDebug() << error.c_str(); |
| 594 | } |
| 595 | #else |
| 596 | bool ok = _imp->copyUnprocessedChannelsShader[index]->addShader(GLShader::eShaderTypeFragment, fragmentSource.c_str(), nullptr); |
| 597 | #endif |
| 598 | assert(ok); |
| 599 | #ifdef DEBUG |
| 600 | ok = _imp->copyUnprocessedChannelsShader[index]->link(&error); |
| 601 | if (!ok) { |
| 602 | qDebug() << error.c_str(); |
| 603 | } |
| 604 | #else |
| 605 | ok = _imp->copyUnprocessedChannelsShader[index]->link(); |
no test coverage detected