Skip to content

Commit

Permalink
Main: Compositor - simplify creation of global textures
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Sep 2, 2024
1 parent 553be5c commit acc64b7
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions OgreMain/src/OgreCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ CompositionTechnique* Compositor::getSupportedTechnique(const String& schemeName
return 0;

}

static TexturePtr createTexture(const String& name, const CompositionTechnique::TextureDefinition* def, PixelFormat pf)
{
bool hwGamma = def->hwGammaWrite && !PixelUtil::isFloatingPoint(pf);
return TextureManager::getSingleton().createManual(name, RGN_INTERNAL, def->type, def->width, def->height, 0, pf,
TU_RENDERTARGET, 0, hwGamma, def->fsaa);
}

//-----------------------------------------------------------------------
void Compositor::createGlobalTextures()
{
Expand Down Expand Up @@ -192,19 +200,12 @@ void Compositor::createGlobalTextures()
mGlobalMRTs[def->name] = mrt;

// create and bind individual surfaces
size_t atch = 0;
for (PixelFormatList::iterator p = def->formatList.begin();
p != def->formatList.end(); ++p, ++atch)
uint8 atch = 0;
for (auto p : def->formatList)
{

String texname = StringUtil::format("mrt%zu.%s", atch, baseName.c_str());
TexturePtr tex;

tex = TextureManager::getSingleton().createManual(
texname,
ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, TEX_TYPE_2D,
(uint)def->width, (uint)def->height, 0, *p, TU_RENDERTARGET, 0,
def->hwGammaWrite && !PixelUtil::isFloatingPoint(*p), def->fsaa);
String texname = StringUtil::format("mrt%d.%s", atch, baseName.c_str());
TexturePtr tex = createTexture(texname, def, p);

RenderTexture* rt = tex->getBuffer()->getRenderTarget();
rt->setAutoUpdated(false);
Expand All @@ -213,7 +214,7 @@ void Compositor::createGlobalTextures()
// Also add to local textures so we can look up
String mrtLocalName = CompositorInstance::getMRTTexLocalName(def->name, atch);
mGlobalTextures[mrtLocalName] = tex;

atch++;
}

rendTarget = mrt;
Expand All @@ -226,14 +227,7 @@ void Compositor::createGlobalTextures()
// this is an auto generated name - so no spaces can't hart us.
std::replace( texName.begin(), texName.end(), ' ', '_' );

TexturePtr tex;
tex = TextureManager::getSingleton().createManual(
texName,
ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, TEX_TYPE_2D,
(uint)def->width, (uint)def->height, 0, def->formatList[0], TU_RENDERTARGET, 0,
def->hwGammaWrite && !PixelUtil::isFloatingPoint(def->formatList[0]), def->fsaa);


TexturePtr tex = createTexture(texName, def, def->formatList[0]);
rendTarget = tex->getBuffer()->getRenderTarget();
mGlobalTextures[def->name] = tex;
}
Expand Down

0 comments on commit acc64b7

Please sign in to comment.