OgreRTTexture::OgreRTTexture(Ogre::TexturePtr _texture) : mViewport(nullptr), mSaveViewport(nullptr), mTexture(_texture) { mProjectMatrix = Ogre::Matrix4::IDENTITY; Ogre::Root* root = Ogre::Root::getSingletonPtr(); if (root != nullptr) { Ogre::RenderSystem* system = root->getRenderSystem(); if (system != nullptr) { size_t width = mTexture->getWidth(); size_t height = mTexture->getHeight(); mRenderTargetInfo.maximumDepth = system->getMaximumDepthInputValue(); mRenderTargetInfo.hOffset = system->getHorizontalTexelOffset() / float(width); mRenderTargetInfo.vOffset = system->getVerticalTexelOffset() / float(height); mRenderTargetInfo.aspectCoef = float(height) / float(width); mRenderTargetInfo.pixScaleX = 1.0f / float(width); mRenderTargetInfo.pixScaleY = 1.0f / float(height); } if (mTexture->getBuffer()->getRenderTarget()->requiresTextureFlipping()) { mProjectMatrix[1][0] = -mProjectMatrix[1][0]; mProjectMatrix[1][1] = -mProjectMatrix[1][1]; mProjectMatrix[1][2] = -mProjectMatrix[1][2]; mProjectMatrix[1][3] = -mProjectMatrix[1][3]; } } }
void updateRenderInfo() { if (mRenderSystem != nullptr) { mInfo.maximumDepth = mRenderSystem->getMaximumDepthInputValue(); mInfo.hOffset = mRenderSystem->getHorizontalTexelOffset() / float(mViewSize.width); mInfo.vOffset = mRenderSystem->getVerticalTexelOffset() / float(mViewSize.height); mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width); mInfo.pixScaleX = 1.0f / float(mViewSize.width); mInfo.pixScaleY = 1.0f / float(mViewSize.height); } }