|
|
|
@ -96,21 +96,13 @@ CStereoDebugger::CStereoDebugger() : m_Driver(NULL), m_Stage(0), m_SubStage(0),
|
|
|
|
|
|
|
|
|
|
CStereoDebugger::~CStereoDebugger()
|
|
|
|
|
{
|
|
|
|
|
releaseTextures();
|
|
|
|
|
|
|
|
|
|
if (!m_Mat.empty())
|
|
|
|
|
{
|
|
|
|
|
m_Mat.getObjectPtr()->setTexture(0, NULL);
|
|
|
|
|
m_Mat.getObjectPtr()->setTexture(1, NULL);
|
|
|
|
|
m_Driver->deleteMaterial(m_Mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete m_LeftTexU;
|
|
|
|
|
m_LeftTexU = NULL;
|
|
|
|
|
m_LeftTex = NULL; // CSmartPtr
|
|
|
|
|
|
|
|
|
|
delete m_RightTexU;
|
|
|
|
|
m_RightTexU = NULL;
|
|
|
|
|
m_RightTex = NULL; // CSmartPtr
|
|
|
|
|
|
|
|
|
|
delete m_PixelProgram;
|
|
|
|
|
m_PixelProgram = NULL;
|
|
|
|
|
|
|
|
|
@ -143,10 +135,57 @@ void CStereoDebugger::setDriver(NL3D::UDriver *driver)
|
|
|
|
|
{
|
|
|
|
|
m_Driver = driver;
|
|
|
|
|
|
|
|
|
|
// todo: handle reso change!
|
|
|
|
|
initTextures();
|
|
|
|
|
|
|
|
|
|
m_Mat = m_Driver->createMaterial();
|
|
|
|
|
m_Mat.initUnlit();
|
|
|
|
|
m_Mat.setColor(CRGBA::White);
|
|
|
|
|
m_Mat.setBlend (false);
|
|
|
|
|
m_Mat.setAlphaTest (false);
|
|
|
|
|
NL3D::CMaterial *mat = m_Mat.getObjectPtr();
|
|
|
|
|
mat->setShader(NL3D::CMaterial::PostProcessing);
|
|
|
|
|
mat->setBlendFunc(CMaterial::one, CMaterial::zero);
|
|
|
|
|
mat->setZWrite(false);
|
|
|
|
|
mat->setZFunc(CMaterial::always);
|
|
|
|
|
mat->setDoubleSided(true);
|
|
|
|
|
|
|
|
|
|
setTextures();
|
|
|
|
|
|
|
|
|
|
m_QuadUV.V0 = CVector(0.f, 0.f, 0.5f);
|
|
|
|
|
m_QuadUV.V1 = CVector(1.f, 0.f, 0.5f);
|
|
|
|
|
m_QuadUV.V2 = CVector(1.f, 1.f, 0.5f);
|
|
|
|
|
m_QuadUV.V3 = CVector(0.f, 1.f, 0.5f);
|
|
|
|
|
|
|
|
|
|
m_QuadUV.Uv0 = CUV(0.f, 0.f);
|
|
|
|
|
m_QuadUV.Uv1 = CUV(1.f, 0.f);
|
|
|
|
|
m_QuadUV.Uv2 = CUV(1.f, 1.f);
|
|
|
|
|
m_QuadUV.Uv3 = CUV(0.f, 1.f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CStereoDebugger::releaseTextures()
|
|
|
|
|
{
|
|
|
|
|
if (!m_Mat.empty())
|
|
|
|
|
{
|
|
|
|
|
m_Mat.getObjectPtr()->setTexture(0, NULL);
|
|
|
|
|
m_Mat.getObjectPtr()->setTexture(1, NULL);
|
|
|
|
|
m_Driver->deleteMaterial(m_Mat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete m_LeftTexU;
|
|
|
|
|
m_LeftTexU = NULL;
|
|
|
|
|
m_LeftTex = NULL; // CSmartPtr
|
|
|
|
|
|
|
|
|
|
delete m_RightTexU;
|
|
|
|
|
m_RightTexU = NULL;
|
|
|
|
|
m_RightTex = NULL; // CSmartPtr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CStereoDebugger::initTextures()
|
|
|
|
|
{
|
|
|
|
|
uint32 width, height;
|
|
|
|
|
driver->getWindowSize(width, height);
|
|
|
|
|
m_Driver->getWindowSize(width, height);
|
|
|
|
|
NL3D::IDriver *drvInternal = (static_cast<CDriverUser *>(m_Driver))->getDriver();
|
|
|
|
|
|
|
|
|
|
m_LeftTex = new CTextureBloom();
|
|
|
|
|
m_LeftTex->setRenderTarget(true);
|
|
|
|
@ -169,32 +208,31 @@ void CStereoDebugger::setDriver(NL3D::UDriver *driver)
|
|
|
|
|
drvInternal->setupTexture(*m_RightTex);
|
|
|
|
|
m_RightTexU = new CTextureUser(m_RightTex);
|
|
|
|
|
nlassert(!drvInternal->isTextureRectangle(m_RightTex)); // not allowed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_Mat = m_Driver->createMaterial();
|
|
|
|
|
m_Mat.initUnlit();
|
|
|
|
|
m_Mat.setColor(CRGBA::White);
|
|
|
|
|
m_Mat.setBlend (false);
|
|
|
|
|
m_Mat.setAlphaTest (false);
|
|
|
|
|
void CStereoDebugger::setTextures()
|
|
|
|
|
{
|
|
|
|
|
NL3D::CMaterial *mat = m_Mat.getObjectPtr();
|
|
|
|
|
mat->setShader(NL3D::CMaterial::PostProcessing);
|
|
|
|
|
mat->setBlendFunc(CMaterial::one, CMaterial::zero);
|
|
|
|
|
mat->setZWrite(false);
|
|
|
|
|
mat->setZFunc(CMaterial::always);
|
|
|
|
|
mat->setDoubleSided(true);
|
|
|
|
|
mat->setTexture(0, m_LeftTex);
|
|
|
|
|
mat->setTexture(1, m_RightTex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_QuadUV.V0 = CVector(0.f, 0.f, 0.5f);
|
|
|
|
|
m_QuadUV.V1 = CVector(1.f, 0.f, 0.5f);
|
|
|
|
|
m_QuadUV.V2 = CVector(1.f, 1.f, 0.5f);
|
|
|
|
|
m_QuadUV.V3 = CVector(0.f, 1.f, 0.5f);
|
|
|
|
|
|
|
|
|
|
m_QuadUV.Uv0 = CUV(0.f, 0.f);
|
|
|
|
|
m_QuadUV.Uv1 = CUV(1.f, 0.f);
|
|
|
|
|
m_QuadUV.Uv2 = CUV(1.f, 1.f);
|
|
|
|
|
m_QuadUV.Uv3 = CUV(0.f, 1.f);
|
|
|
|
|
void CStereoDebugger::verifyTextures()
|
|
|
|
|
{
|
|
|
|
|
if (m_Driver)
|
|
|
|
|
{
|
|
|
|
|
uint32 width, height;
|
|
|
|
|
m_Driver->getWindowSize(width, height);
|
|
|
|
|
if (m_LeftTex->getWidth() != width
|
|
|
|
|
|| m_RightTex->getWidth() != width
|
|
|
|
|
|| m_LeftTex->getHeight() != height
|
|
|
|
|
|| m_RightTex->getHeight() != height)
|
|
|
|
|
{
|
|
|
|
|
nldebug("Rebuild textures");
|
|
|
|
|
releaseTextures();
|
|
|
|
|
initTextures();
|
|
|
|
|
setTextures();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|