Skip to content

Commit a98c9ee

Browse files
authored
Samples: range loop refactoring (#3083)
1 parent 6bcf1d7 commit a98c9ee

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

Samples/Common/include/SampleContext.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
This source file is part of OGRE
44
(Object-oriented Graphics Rendering Engine)
55
For the latest info, see http://www.ogre3d.org/
6-
6+
77
Copyright (c) 2000-2014 Torus Knot Software Ltd
8-
8+
99
Permission is hereby granted, free of charge, to any person obtaining a copy
1010
of this software and associated documentation files (the "Software"), to deal
1111
in the Software without restriction, including without limitation the rights
1212
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1313
copies of the Software, and to permit persons to whom the Software is
1414
furnished to do so, subject to the following conditions:
15-
15+
1616
The above copyright notice and this permission notice shall be included in
1717
all copies or substantial portions of the Software.
18-
18+
1919
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2020
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2121
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -80,24 +80,21 @@ namespace OgreBites
8080
if (s)
8181
{
8282
// retrieve sample's required plugins and currently installed plugins
83-
Ogre::Root::PluginInstanceList ip = mRoot->getInstalledPlugins();
84-
Ogre::StringVector rp = s->getRequiredPlugins();
85-
86-
for (Ogre::StringVector::iterator j = rp.begin(); j != rp.end(); j++)
83+
for (const auto& p : s->getRequiredPlugins())
8784
{
8885
bool found = false;
8986
// try to find the required plugin in the current installed plugins
90-
for (Ogre::Root::PluginInstanceList::iterator k = ip.begin(); k != ip.end(); k++)
87+
for (const auto *i : mRoot->getInstalledPlugins())
9188
{
92-
if ((*k)->getName() == *j)
89+
if (i->getName() == p)
9390
{
9491
found = true;
9592
break;
9693
}
9794
}
9895
if (!found) // throw an exception if a plugin is not found
9996
{
100-
OGRE_EXCEPT(Ogre::Exception::ERR_NOT_IMPLEMENTED, "Sample requires plugin: " + *j);
97+
OGRE_EXCEPT(Ogre::Exception::ERR_NOT_IMPLEMENTED, "Sample requires plugin: " + p);
10198
}
10299
}
103100

@@ -139,7 +136,7 @@ namespace OgreBites
139136
#endif
140137

141138
loadStartUpSample();
142-
139+
143140
if (mRoot->getRenderSystem() != NULL)
144141
{
145142
mRoot->startRendering(); // start the render loop
@@ -176,7 +173,7 @@ namespace OgreBites
176173
mCurrentSample->unpaused();
177174
}
178175
}
179-
176+
180177
/*-----------------------------------------------------------------------------
181178
| Processes frame started events.
182179
-----------------------------------------------------------------------------*/
@@ -187,7 +184,7 @@ namespace OgreBites
187184
// manually call sample callback to ensure correct order
188185
return !isCurrentSamplePaused() ? mCurrentSample->frameStarted(evt) : true;
189186
}
190-
187+
191188
/*-----------------------------------------------------------------------------
192189
| Processes rendering queued events.
193190
-----------------------------------------------------------------------------*/
@@ -196,7 +193,7 @@ namespace OgreBites
196193
// manually call sample callback to ensure correct order
197194
return !isCurrentSamplePaused() ? mCurrentSample->frameRenderingQueued(evt) : true;
198195
}
199-
196+
200197
/*-----------------------------------------------------------------------------
201198
| Processes frame ended events.
202199
-----------------------------------------------------------------------------*/
@@ -262,7 +259,7 @@ namespace OgreBites
262259

263260
ApplicationContext::shutdown();
264261
}
265-
262+
266263
Sample* mCurrentSample; // The active sample (0 if none is active)
267264
bool mSamplePaused; // whether current sample is paused
268265
bool mLastRun; // whether or not this is the final run

Samples/Compositor/src/HelperLogics.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,11 @@ void HDRListener::notifyViewportSize(int width, int height)
160160
void HDRListener::notifyCompositor(Ogre::CompositorInstance* instance)
161161
{
162162
// Get some RTT dimensions for later calculations
163-
const Ogre::CompositionTechnique::TextureDefinitions& defs =
164-
instance->getTechnique()->getTextureDefinitions();
165-
Ogre::CompositionTechnique::TextureDefinitions::const_iterator defIter;
166-
for (defIter = defs.begin(); defIter != defs.end(); ++defIter)
163+
for (const auto *t : instance->getTechnique()->getTextureDefinitions())
167164
{
168-
Ogre::CompositionTechnique::TextureDefinition* def = *defIter;
169-
if(def->name == "rt_bloom0")
165+
if(t->name == "rt_bloom0")
170166
{
171-
mBloomSize = (int)def->width; // should be square
167+
mBloomSize = (int)t->width; // should be square
172168
// Calculate gaussian texture offsets & weights
173169
float deviation = 3.0f;
174170
float texelSize = 1.0f / (float)mBloomSize;
@@ -205,7 +201,6 @@ void HDRListener::notifyCompositor(Ogre::CompositorInstance* instance)
205201
mBloomTexOffsetsVert[i][0] = 0.0f;
206202
mBloomTexOffsetsVert[i][1] = -mBloomTexOffsetsVert[i - 7][1];
207203
}
208-
209204
}
210205
}
211206
}

0 commit comments

Comments
 (0)