GFXTextureObject* ReflectionManager::getRefractTex( bool forceUpdate ) { GFXTarget *target = GFX->getActiveRenderTarget(); GFXFormat targetFormat = target->getFormat(); const Point2I &targetSize = target->getSize(); #if defined(TORQUE_OS_XENON) // On the Xbox360, it needs to do a resolveTo from the active target, so this // may as well be the full size of the active target const U32 desWidth = targetSize.x; const U32 desHeight = targetSize.y; #else const U32 desWidth = mFloor( (F32)targetSize.x * smRefractTexScale ); const U32 desHeight = mFloor( ( F32)targetSize.y * smRefractTexScale ); #endif if ( mRefractTex.isNull() || mRefractTex->getWidth() != desWidth || mRefractTex->getHeight() != desHeight || mRefractTex->getFormat() != targetFormat ) { mRefractTex.set( desWidth, desHeight, targetFormat, &RefractTextureProfile, "mRefractTex" ); mUpdateRefract = true; } if ( forceUpdate || mUpdateRefract ) { target->resolveTo( mRefractTex ); mUpdateRefract = false; } return mRefractTex; }
GFXTextureObject *RenderPassManager::getDepthTargetTexture() { // If this is OpenGL, or something else has set the depth buffer, return the pointer if( mDepthBuff.isValid() ) { // If this is OpenGL, make sure the depth target matches up // with the active render target. Otherwise recreate. if( GFX->getAdapterType() == OpenGL ) { GFXTarget* activeRT = GFX->getActiveRenderTarget(); AssertFatal( activeRT, "Must be an active render target to call 'getDepthTargetTexture'" ); Point2I activeRTSize = activeRT->getSize(); if( mDepthBuff.getWidth() == activeRTSize.x && mDepthBuff.getHeight() == activeRTSize.y ) return mDepthBuff.getPointer(); } else return mDepthBuff.getPointer(); } if(GFX->getAdapterType() == OpenGL) { AssertFatal(GFX->getActiveRenderTarget(), "Must be an active render target to call 'getDepthTargetTexture'"); const Point2I rtSize = GFX->getActiveRenderTarget()->getSize(); mDepthBuff.set(rtSize.x, rtSize.y, GFXFormatD24S8, &GFXDefaultZTargetProfile, avar("%s() - mDepthBuff (line %d)", __FUNCTION__, __LINE__)); return mDepthBuff.getPointer(); } // Default return value return GFXTextureTarget::sDefaultDepthStencil; }
GFXTextureObject* ReflectionManager::getRefractTex() { GFXTarget *target = GFX->getActiveRenderTarget(); GFXFormat targetFormat = target->getFormat(); const Point2I &targetSize = target->getSize(); const U32 desWidth = mFloor( (F32)targetSize.x * mRefractTexScale ); const U32 desHeight = mFloor( ( F32)targetSize.y * mRefractTexScale ); if ( mRefractTex.isNull() || mRefractTex->getWidth() != desWidth || mRefractTex->getHeight() != desHeight || mRefractTex->getFormat() != targetFormat ) { mRefractTex.set( desWidth, desHeight, targetFormat, &RefractTextureProfile, "mRefractTex" ); mUpdateRefract = true; } if ( mUpdateRefract ) { target->resolveTo( mRefractTex ); mUpdateRefract = false; } return mRefractTex; }