=== modified file 'src/main.cpp'
@@ -26,6 +26,7 @@
#include "benchmark.h"
#include "options.h"
#include "log.h"
+#include "util.h"
#include <iostream>
@@ -82,6 +83,28 @@
}
}
+void
+add_and_register_scenes(vector<Scene*>& scenes, Canvas& canvas)
+{
+ scenes.push_back(new SceneDefaultOptions(canvas));
+ scenes.push_back(new SceneBuild(canvas));
+ scenes.push_back(new SceneTexture(canvas));
+ scenes.push_back(new SceneShading(canvas));
+ scenes.push_back(new SceneConditionals(canvas));
+ scenes.push_back(new SceneFunction(canvas));
+ scenes.push_back(new SceneLoop(canvas));
+ scenes.push_back(new SceneBump(canvas));
+ scenes.push_back(new SceneEffect2D(canvas));
+ scenes.push_back(new ScenePulsar(canvas));
+
+ for (vector<Scene*>::const_iterator iter = scenes.begin();
+ iter != scenes.end();
+ iter++)
+ {
+ Benchmark::register_scene(**iter);
+ }
+}
+
static void
list_scenes()
{
@@ -220,17 +243,10 @@
CanvasX11EGL canvas(Options::size.first, Options::size.second);
#endif
- // Register the scenes, so they can be looked-up by name
- Benchmark::register_scene(*new SceneDefaultOptions(canvas));
- Benchmark::register_scene(*new SceneBuild(canvas));
- Benchmark::register_scene(*new SceneTexture(canvas));
- Benchmark::register_scene(*new SceneShading(canvas));
- Benchmark::register_scene(*new SceneConditionals(canvas));
- Benchmark::register_scene(*new SceneFunction(canvas));
- Benchmark::register_scene(*new SceneLoop(canvas));
- Benchmark::register_scene(*new SceneBump(canvas));
- Benchmark::register_scene(*new SceneEffect2D(canvas));
- Benchmark::register_scene(*new ScenePulsar(canvas));
+ vector<Scene*> scenes;
+
+ // Register the scenes, so they can be looked up by name
+ add_and_register_scenes(scenes, canvas);
if (Options::list_scenes) {
list_scenes();
@@ -263,5 +279,8 @@
else
do_benchmark(canvas, benchmarks);
+ Util::dispose_pointer_vector(benchmarks);
+ Util::dispose_pointer_vector(scenes);
+
return 0;
}
=== modified file 'src/util.h'
@@ -35,6 +35,18 @@
struct Util {
static void split(const std::string &s, char delim, std::vector<std::string> &elems);
static std::istream *get_resource(const std::string &path);
+ template <class T> static void dispose_pointer_vector(std::vector<T*> &vec)
+ {
+ for (typename std::vector<T*>::const_iterator iter = vec.begin();
+ iter != vec.end();
+ iter++)
+ {
+ delete *iter;
+ }
+
+ vec.clear();
+ }
+
#ifdef ANDROID
static void android_set_asset_manager(AAssetManager *asset_manager);
private: