Skip to content

Commit

Permalink
Samples: range loop refactoring (#3083)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joilnen authored Apr 16, 2024
1 parent 6bcf1d7 commit a98c9ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
29 changes: 13 additions & 16 deletions Samples/Common/include/SampleContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2014 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down Expand Up @@ -80,24 +80,21 @@ namespace OgreBites
if (s)
{
// retrieve sample's required plugins and currently installed plugins
Ogre::Root::PluginInstanceList ip = mRoot->getInstalledPlugins();
Ogre::StringVector rp = s->getRequiredPlugins();

for (Ogre::StringVector::iterator j = rp.begin(); j != rp.end(); j++)
for (const auto& p : s->getRequiredPlugins())
{
bool found = false;
// try to find the required plugin in the current installed plugins
for (Ogre::Root::PluginInstanceList::iterator k = ip.begin(); k != ip.end(); k++)
for (const auto *i : mRoot->getInstalledPlugins())
{
if ((*k)->getName() == *j)
if (i->getName() == p)
{
found = true;
break;
}
}
if (!found) // throw an exception if a plugin is not found
{
OGRE_EXCEPT(Ogre::Exception::ERR_NOT_IMPLEMENTED, "Sample requires plugin: " + *j);
OGRE_EXCEPT(Ogre::Exception::ERR_NOT_IMPLEMENTED, "Sample requires plugin: " + p);
}
}

Expand Down Expand Up @@ -139,7 +136,7 @@ namespace OgreBites
#endif

loadStartUpSample();

if (mRoot->getRenderSystem() != NULL)
{
mRoot->startRendering(); // start the render loop
Expand Down Expand Up @@ -176,7 +173,7 @@ namespace OgreBites
mCurrentSample->unpaused();
}
}

/*-----------------------------------------------------------------------------
| Processes frame started events.
-----------------------------------------------------------------------------*/
Expand All @@ -187,7 +184,7 @@ namespace OgreBites
// manually call sample callback to ensure correct order
return !isCurrentSamplePaused() ? mCurrentSample->frameStarted(evt) : true;
}

/*-----------------------------------------------------------------------------
| Processes rendering queued events.
-----------------------------------------------------------------------------*/
Expand All @@ -196,7 +193,7 @@ namespace OgreBites
// manually call sample callback to ensure correct order
return !isCurrentSamplePaused() ? mCurrentSample->frameRenderingQueued(evt) : true;
}

/*-----------------------------------------------------------------------------
| Processes frame ended events.
-----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -262,7 +259,7 @@ namespace OgreBites

ApplicationContext::shutdown();
}

Sample* mCurrentSample; // The active sample (0 if none is active)
bool mSamplePaused; // whether current sample is paused
bool mLastRun; // whether or not this is the final run
Expand Down
11 changes: 3 additions & 8 deletions Samples/Compositor/src/HelperLogics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ void HDRListener::notifyViewportSize(int width, int height)
void HDRListener::notifyCompositor(Ogre::CompositorInstance* instance)
{
// Get some RTT dimensions for later calculations
const Ogre::CompositionTechnique::TextureDefinitions& defs =
instance->getTechnique()->getTextureDefinitions();
Ogre::CompositionTechnique::TextureDefinitions::const_iterator defIter;
for (defIter = defs.begin(); defIter != defs.end(); ++defIter)
for (const auto *t : instance->getTechnique()->getTextureDefinitions())
{
Ogre::CompositionTechnique::TextureDefinition* def = *defIter;
if(def->name == "rt_bloom0")
if(t->name == "rt_bloom0")
{
mBloomSize = (int)def->width; // should be square
mBloomSize = (int)t->width; // should be square
// Calculate gaussian texture offsets & weights
float deviation = 3.0f;
float texelSize = 1.0f / (float)mBloomSize;
Expand Down Expand Up @@ -205,7 +201,6 @@ void HDRListener::notifyCompositor(Ogre::CompositorInstance* instance)
mBloomTexOffsetsVert[i][0] = 0.0f;
mBloomTexOffsetsVert[i][1] = -mBloomTexOffsetsVert[i - 7][1];
}

}
}
}
Expand Down

0 comments on commit a98c9ee

Please sign in to comment.