MCPcopy Create free account
hub / github.com/SFML/SFML / updateTexture

Method updateTexture

src/SFML/Graphics/RenderTextureImplFBO.cpp:591–645  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

589
590////////////////////////////////////////////////////////////
591void RenderTextureImplFBO::updateTexture(unsigned int)
592{
593 // If multisampling is enabled, we need to resolve by blitting
594 // from our FBO with multisample renderbuffer attachments
595 // to our FBO to which our target texture is attached
596
597#ifndef SFML_OPENGL_ES
598
599 // In case of multisampling, make sure both FBOs
600 // are already available within the current context
601 if (m_multisample && m_size.x && m_size.y && activate(true))
602 {
603 const std::uint64_t contextId = Context::getActiveContextId();
604
605 const auto frameBufferIt = m_frameBuffers.find(contextId);
606 const auto multisampleIt = m_multisampleFrameBuffers.find(contextId);
607
608 if ((frameBufferIt != m_frameBuffers.end()) && (multisampleIt != m_multisampleFrameBuffers.end()))
609 {
610 const auto frameBuffer = frameBufferIt->second.lock();
611 const auto multiSampleFrameBuffer = multisampleIt->second.lock();
612
613 if (frameBuffer && multiSampleFrameBuffer)
614 {
615 // Scissor testing affects framebuffer blits as well
616 // Since we don't want scissor testing to interfere with our copying, we temporarily disable it for the blit if it is enabled
617 GLboolean scissorEnabled = GL_FALSE;
618 glCheck(glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled));
619
620 if (scissorEnabled == GL_TRUE)
621 glCheck(glDisable(GL_SCISSOR_TEST));
622
623 // Set up the blit target (draw framebuffer) and blit (from the read framebuffer, our multisample FBO)
624 glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, frameBuffer->object));
625 glCheck(GLEXT_glBlitFramebuffer(0,
626 0,
627 static_cast<GLint>(m_size.x),
628 static_cast<GLint>(m_size.y),
629 0,
630 0,
631 static_cast<GLint>(m_size.x),
632 static_cast<GLint>(m_size.y),
633 GL_COLOR_BUFFER_BIT,
634 GL_NEAREST));
635 glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_DRAW_FRAMEBUFFER, multiSampleFrameBuffer->object));
636
637 // Re-enable scissor testing if it was previously enabled
638 if (scissorEnabled == GL_TRUE)
639 glCheck(glEnable(GL_SCISSOR_TEST));
640 }
641 }
642 }
643
644#endif // SFML_OPENGL_ES
645}
646
647} // namespace sf::priv

Callers 1

displayMethod · 0.45

Calls 2

findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected