1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 11:09:41 +00:00

Bug #618: Make local map textures static in an attempt to fix the disappearing maps with D3D.

Also removed problematic DISCARDABLE flag for fog of war textures.
This commit is contained in:
scrawl 2014-05-11 02:38:39 +02:00
parent c98bea2a88
commit c39a0368cf
2 changed files with 30 additions and 18 deletions

View file

@ -44,6 +44,24 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManag
mLight->setDirection (Ogre::Vector3(0.3, 0.3, -0.7)); mLight->setDirection (Ogre::Vector3(0.3, 0.3, -0.7));
mLight->setVisible (false); mLight->setVisible (false);
mLight->setDiffuseColour (ColourValue(0.7,0.7,0.7)); mLight->setDiffuseColour (ColourValue(0.7,0.7,0.7));
mRenderTexture = TextureManager::getSingleton().createManual(
"localmap/rtt",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
sMapResolution, sMapResolution,
0,
PF_R8G8B8,
TU_RENDERTARGET);
mRenderTarget = mRenderTexture->getBuffer()->getRenderTarget();
mRenderTarget->setAutoUpdated(false);
Viewport* vp = mRenderTarget->addViewport(mCellCamera);
vp->setOverlaysEnabled(false);
vp->setShadowsEnabled(false);
vp->setBackgroundColour(ColourValue(0, 0, 0));
vp->setVisibilityMask(RV_Map);
vp->setMaterialScheme("local_map");
} }
LocalMap::~LocalMap() LocalMap::~LocalMap()
@ -318,7 +336,7 @@ Ogre::TexturePtr LocalMap::createFogOfWarTexture(const std::string &texName)
sFogOfWarResolution, sFogOfWarResolution, sFogOfWarResolution, sFogOfWarResolution,
0, 0,
PF_A8R8G8B8, PF_A8R8G8B8,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); TU_DYNAMIC_WRITE_ONLY);
} }
else else
tex->unload(); tex->unload();
@ -378,26 +396,17 @@ void LocalMap::render(const float x, const float y,
if (tex.isNull()) if (tex.isNull())
{ {
// render // render
tex = TextureManager::getSingleton().createManual( mRenderTarget->update();
// create a new texture and blit to it
Ogre::TexturePtr tex = TextureManager::getSingleton().createManual(
texture, texture,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, TEX_TYPE_2D,
xw*sMapResolution/sSize, yw*sMapResolution/sSize, sMapResolution, sMapResolution,
0, 0,
PF_R8G8B8, PF_R8G8B8);
TU_RENDERTARGET); tex->getBuffer()->blit(mRenderTexture->getBuffer());
RenderTarget* rtt = tex->getBuffer()->getRenderTarget();
rtt->setAutoUpdated(false);
Viewport* vp = rtt->addViewport(mCellCamera);
vp->setOverlaysEnabled(false);
vp->setShadowsEnabled(false);
vp->setBackgroundColour(ColourValue(0, 0, 0));
vp->setVisibilityMask(RV_Map);
vp->setMaterialScheme("local_map");
rtt->update();
} }
mRenderingManager->enableLights(true); mRenderingManager->enableLights(true);

View file

@ -84,7 +84,6 @@ namespace MWRender
OEngine::Render::OgreRenderer* mRendering; OEngine::Render::OgreRenderer* mRendering;
MWRender::RenderingManager* mRenderingManager; MWRender::RenderingManager* mRenderingManager;
// 1024*1024 pixels for a cell
static const int sMapResolution = 512; static const int sMapResolution = 512;
// the dynamic texture is a bottleneck, so don't set this too high // the dynamic texture is a bottleneck, so don't set this too high
@ -126,6 +125,10 @@ namespace MWRender
// Both interior and exterior maps are possibly divided into multiple textures. // Both interior and exterior maps are possibly divided into multiple textures.
std::map <std::string, std::vector<Ogre::uint32> > mBuffers; std::map <std::string, std::vector<Ogre::uint32> > mBuffers;
// The render texture we will use to create the map images
Ogre::TexturePtr mRenderTexture;
Ogre::RenderTarget* mRenderTarget;
bool mInterior; bool mInterior;
int mCellX, mCellY; int mCellX, mCellY;
Ogre::AxisAlignedBox mBounds; Ogre::AxisAlignedBox mBounds;