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

Method activate

src/SFML/Graphics/RenderTextureImplFBO.cpp:510–580  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

508
509////////////////////////////////////////////////////////////
510bool RenderTextureImplFBO::activate(bool active)
511{
512 // Unbind the FBO if requested
513 if (!active)
514 {
515 glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, 0));
516 return true;
517 }
518
519 std::uint64_t contextId = Context::getActiveContextId();
520
521 // In the odd case we have to activate and there is no active
522 // context yet, we have to create one
523 if (!contextId)
524 {
525 if (!m_context)
526 m_context = std::make_unique<Context>();
527
528 if (!m_context->setActive(true))
529 {
530 err() << "Failed to set context as active during render texture activation" << std::endl;
531 return false;
532 }
533
534 contextId = Context::getActiveContextId();
535
536 if (!contextId)
537 {
538 err() << "Impossible to activate render texture (failed to create backup context)" << std::endl;
539 return false;
540 }
541 }
542
543 // Lookup the FBO corresponding to the currently active context
544 // If none is found, there is no FBO corresponding to the
545 // currently active context so we will have to create a new FBO
546 if (m_multisample)
547 {
548 const auto it = m_multisampleFrameBuffers.find(contextId);
549
550 if (it != m_multisampleFrameBuffers.end())
551 {
552 const auto frameBuffer = it->second.lock();
553
554 if (frameBuffer)
555 {
556 glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer->object));
557
558 return true;
559 }
560 }
561 }
562 else
563 {
564 const auto it = m_frameBuffers.find(contextId);
565
566 if (it != m_frameBuffers.end())
567 {

Callers 1

setActiveMethod · 0.45

Calls 3

findMethod · 0.80
setActiveMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected