///////////////////////////////////////////////////////
| 481 | |
| 482 | //////////////////////////////////////////////////////////// |
| 483 | bool RenderTarget::setActive(bool active) |
| 484 | { |
| 485 | // Mark this RenderTarget as active or no longer active in the tracking map |
| 486 | const std::lock_guard lock(RenderTargetImpl::getMutex()); |
| 487 | |
| 488 | const std::uint64_t contextId = Context::getActiveContextId(); |
| 489 | |
| 490 | using RenderTargetImpl::getContextRenderTargetMap; |
| 491 | auto& contextRenderTargetMap = getContextRenderTargetMap(); |
| 492 | const auto it = contextRenderTargetMap.find(contextId); |
| 493 | |
| 494 | if (active) |
| 495 | { |
| 496 | if (it == contextRenderTargetMap.end()) |
| 497 | { |
| 498 | contextRenderTargetMap[contextId] = m_id; |
| 499 | |
| 500 | m_cache.glStatesSet = false; |
| 501 | m_cache.enable = false; |
| 502 | } |
| 503 | else if (it->second != m_id) |
| 504 | { |
| 505 | it->second = m_id; |
| 506 | |
| 507 | m_cache.enable = false; |
| 508 | } |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | if (it != contextRenderTargetMap.end()) |
| 513 | contextRenderTargetMap.erase(it); |
| 514 | |
| 515 | m_cache.enable = false; |
| 516 | } |
| 517 | |
| 518 | return true; |
| 519 | } |
| 520 | |
| 521 | |
| 522 | //////////////////////////////////////////////////////////// |