Page MenuHomePhorge

RenderTargetNotifier.cpp
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

RenderTargetNotifier.cpp

#include <echo/Graphics/RenderTargetNotifier.h>
#include <echo/Graphics/RenderTarget.h>
namespace Echo
{
RenderTargetNotifier::RenderTargetNotifier()
{
}
RenderTargetNotifier::~RenderTargetNotifier()
{
}
bool RenderTargetNotifier::AddRenderTarget(const std::string& name, shared_ptr<RenderTarget> renderTarget, bool isPrimary)
{
NamedRenderTargetMap::iterator it = mRenderTargets.find(name);
if(it!=mRenderTargets.end())
{
ECHO_LOG_ERROR("RenderTarget already associated with name \"" << name << "\"");
return false;
}
if(!mPrimaryRenderTarget || isPrimary)
{
mPrimaryRenderTarget = renderTarget;
}
mRenderTargets.insert(std::make_pair(name, renderTarget));
return true;
}
shared_ptr<RenderTarget> RenderTargetNotifier::GetRenderTarget(const std::string& name)
{
NamedRenderTargetMap::iterator it = mRenderTargets.find(name);
if(it==mRenderTargets.end())
{
ECHO_LOG_ERROR("RenderTarget not found where name \"" << name << "\"");
return shared_ptr<RenderTarget>();
}
return it->second;
}
void RenderTargetNotifier::RemoveRenderTarget(const std::string& name)
{
NamedRenderTargetMap::iterator it = mRenderTargets.find(name);
if(it==mRenderTargets.end())
{
ECHO_LOG_ERROR("RenderTarget not found where name \"" << name << "\"");
return;
}
mRenderTargets.erase(it);
}
void RenderTargetNotifier::RemoveAllRenderTargets()
{
mRenderTargets.clear();
}
shared_ptr<RenderTarget> RenderTargetNotifier::GetPrimaryRenderTarget() const
{
return mPrimaryRenderTarget;
}
void RenderTargetNotifier::GraphicsContextLost()
{
for(NamedRenderTargetPair& namedRenderTarget : mRenderTargets)
{
if(namedRenderTarget.second)
{
namedRenderTarget.second->ContextLost();
}
}
}
void RenderTargetNotifier::GraphicsContextRestored()
{
for(NamedRenderTargetPair& namedRenderTarget : mRenderTargets)
{
if(namedRenderTarget.second)
{
namedRenderTarget.second->ContextLost();
}
}
}
}

File Metadata

Mime Type
text/x-c++
Expires
Thu, Dec 5, 6:46 PM (23 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
63445
Default Alt Text
RenderTargetNotifier.cpp (2 KB)

Event Timeline