| 653 | } |
| 654 | |
| 655 | int32_t Shade::Start(olc::Effect* pEffect) |
| 656 | { |
| 657 | // Reconstruct frame buffer |
| 658 | locBindFrameBuffer(36160U, m_nFBO); |
| 659 | |
| 660 | std::array<GLenum, 8> attachments = |
| 661 | { { 36064U, 36065U, 36066U, 36067U, 36068U, 36069U, 36070U, 36071U } }; |
| 662 | |
| 663 | // Remove existing buffer links |
| 664 | for (const auto& a : attachments) |
| 665 | { |
| 666 | locFrameBufferTexture2D(36160U, a, GL_TEXTURE_2D, 0, 0); |
| 667 | } |
| 668 | |
| 669 | // Count Target slots in use from beginning |
| 670 | int nTargetSlots = 0; |
| 671 | while (slotTarget[nTargetSlots].nTargetResID > 0) |
| 672 | nTargetSlots++; |
| 673 | |
| 674 | // Allocate target buffers |
| 675 | locDrawBuffers(nTargetSlots, attachments.data()); |
| 676 | |
| 677 | // Bind buffers to texture resources |
| 678 | for (uint32_t i = 0; i < pEffect->GetTargetSlots(); i++) |
| 679 | { |
| 680 | locFrameBufferTexture2D(36160U, attachments[i], GL_TEXTURE_2D, slotTarget[i].nTargetResID, 0); |
| 681 | } |
| 682 | |
| 683 | // Apply Effect |
| 684 | locUseProgram(pEffect->m_nID); |
| 685 | |
| 686 | // Set vertex stream source |
| 687 | locBindVertexArray(m_nVA); |
| 688 | |
| 689 | glDisable(GL_DEPTH_TEST); |
| 690 | glDisable(GL_CULL_FACE); |
| 691 | //glEnable(GL_BLEND); |
| 692 | //locBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 693 | //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 694 | |
| 695 | |
| 696 | #if defined(OLC_PLATFORM_EMSCRIPTEN) |
| 697 | locVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(sOmniVertex), 0); locEnableVertexAttribArray(0); |
| 698 | locVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(sOmniVertex), (void*)(3 * sizeof(float))); locEnableVertexAttribArray(1); |
| 699 | locVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(sOmniVertex), (void*)(5 * sizeof(float))); locEnableVertexAttribArray(2); |
| 700 | #endif |
| 701 | |
| 702 | glViewport(0, 0, int32_t(slotTarget[0].vSize.x), int32_t(slotTarget[0].vSize.y)); |
| 703 | |
| 704 | return 0; |
| 705 | } |
| 706 | |
| 707 | int32_t Shade::End() |
| 708 | { |