namespace HDK_Sample
{
{
public:
myDepthFBO(NULL),
myDoQueries(false) {}
~DM_OverdrawRender() override
{
delete myDepthFBO;
}
{
return false;
{
{
myDoQueries = doPreBeauty(r, hook_data);
}
else if(myDoQueries)
{
doPostBeauty(r);
}
}
else if(myDoQueries)
{
renderInfo(r, hook_data);
}
return false;
}
void viewportClosed() override
{
delete myDepthFBO;
myDepthFBO = NULL;
myQuery1.destroy();
myQuery2.destroy();
}
int bumpRefCount(bool inc)
{
myRefCount += (inc?1:-1);
return myRefCount;
}
private:
bool myDoQueries;
int myRefCount;
};
{
public:
~DM_OverdrawHook() override {}
{
return NULL;
DM_OverdrawRender *hook = NULL;
if(it != mySceneHooks.end())
{
hook = it->second;
}
else
{
hook = new DM_OverdrawRender(vport);
}
hook->bumpRefCount(true);
return hook;
}
{
if(static_cast<DM_OverdrawRender *>(hook)->bumpRefCount(false) == 0)
{
= mySceneHooks.find(id);
if(it != mySceneHooks.end())
mySceneHooks.erase(id);
delete hook;
}
}
private:
};
};
using namespace HDK_Sample;
bool
{
myQuery1.init(r);
myQuery2.init(r);
aa_samples = 1 << aa_samples;
if(!myDepthFBO ||
myDepthFBO->getSamples() != aa_samples)
{
if(myDepthFBO)
{
delete myDepthFBO;
myDepthFBO = NULL;
}
myDepthFBO->setSamples(aa_samples);
if(!myDepthFBO->isValid(r))
{
delete myDepthFBO;
myDepthFBO = NULL;
return false;
}
}
myQuery1.begin(r);
myQuery1.end(r);
myQuery2.begin(r);
return true;
}
void
DM_OverdrawRender::doPostBeauty(
RE_Render *r)
{
myQuery2.end(r);
}
void
{
int num1 = myQuery1.getNumDrawn(r);
int num2 = myQuery2.getNumDrawn(r);
string.sprintf("Overdraw %d%% (%d samples)", int(overdraw*100), num1-num2);
}
void
{
DM_OverdrawHook *hook = new DM_OverdrawHook();
}