Merge lp:~linaro-graphics-wg/glmark2/options-finite-value-set into lp:glmark2/2011.11

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 233
Proposed branch: lp:~linaro-graphics-wg/glmark2/options-finite-value-set
Merge into: lp:glmark2/2011.11
Diff against target: 505 lines (+138/-57)
17 files modified
src/benchmark.cpp (+12/-1)
src/main.cpp (+16/-0)
src/scene-buffer.cpp (+6/-3)
src/scene-build.cpp (+9/-8)
src/scene-bump.cpp (+2/-1)
src/scene-conditionals.cpp (+2/-2)
src/scene-default-options.cpp (+13/-1)
src/scene-desktop.cpp (+4/-3)
src/scene-effect-2d.cpp (+2/-1)
src/scene-function.cpp (+4/-4)
src/scene-loop.cpp (+6/-4)
src/scene-pulsar.cpp (+6/-3)
src/scene-shading.cpp (+7/-7)
src/scene-terrain.cpp (+4/-2)
src/scene-texture.cpp (+14/-14)
src/scene.cpp (+26/-1)
src/scene.h (+5/-2)
To merge this branch: bzr merge lp:~linaro-graphics-wg/glmark2/options-finite-value-set
Reviewer Review Type Date Requested Status
Jesse Barker Approve
Review via email: mp+115358@code.launchpad.net

Description of the change

Add support for options that have a finite set of acceptable values.

This includes listing the values in --list-scenes, and warning the user if they use unacceptable values.

To post a comment you must log in.
Revision history for this message
Jesse Barker (jesse-barker) wrote :

Looks good. I take it this makes it easier for us to present the options in the Android UI (i.e., rather than the user having to type option values, they might be able to select them from a list/menu of some sort)?

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Yes. In fact, I already have some experimental code for Android GUI integration. It needs some cleanup, but if all goes well we can merge it in time for 2012.07.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/benchmark.cpp'
--- src/benchmark.cpp 2012-02-15 16:22:18 +0000
+++ src/benchmark.cpp 2012-07-17 14:39:31 +0000
@@ -144,7 +144,18 @@
144 iter != options_.end();144 iter != options_.end();
145 iter++)145 iter++)
146 {146 {
147 scene_.set_option(iter->first, iter->second);147 if (!scene_.set_option(iter->first, iter->second)) {
148 map<string, Scene::Option>::const_iterator opt_iter = scene_.options().find(iter->first);
149
150 if (opt_iter == scene_.options().end()) {
151 Log::info("Warning: Scene '%s' doesn't accept option '%s'\n",
152 scene_.name().c_str(), iter->first.c_str());
153 }
154 else {
155 Log::info("Warning: Scene '%s' doesn't accept value '%s' for option '%s'\n",
156 scene_.name().c_str(), iter->second.c_str(), iter->first.c_str());
157 }
158 }
148 }159 }
149}160}
150161
151162
=== modified file 'src/main.cpp'
--- src/main.cpp 2012-07-09 15:54:30 +0000
+++ src/main.cpp 2012-07-17 14:39:31 +0000
@@ -99,6 +99,22 @@
99 opt.name.c_str(),99 opt.name.c_str(),
100 opt.description.c_str(),100 opt.description.c_str(),
101 opt.default_value.c_str());101 opt.default_value.c_str());
102
103 /* Display list of acceptable values (if defined) */
104 if (!opt.acceptable_values.empty()) {
105 Log::info(" Acceptable Values: ");
106 for (vector<string>::const_iterator val_iter = opt.acceptable_values.begin();
107 val_iter != opt.acceptable_values.end();
108 val_iter++)
109 {
110 std::string format_value(Log::continuation_prefix + "%s");
111 if (val_iter + 1 != opt.acceptable_values.end())
112 format_value += ",";
113 else
114 format_value += "\n";
115 Log::info(format_value.c_str(), val_iter->c_str());
116 }
117 }
102 }118 }
103 }119 }
104}120}
105121
=== modified file 'src/scene-buffer.cpp'
--- src/scene-buffer.cpp 2012-01-13 13:50:31 +0000
+++ src/scene-buffer.cpp 2012-07-17 14:39:31 +0000
@@ -303,9 +303,11 @@
303{303{
304 priv_ = new SceneBufferPrivate();304 priv_ = new SceneBufferPrivate();
305 options_["interleave"] = Scene::Option("interleave", "false",305 options_["interleave"] = Scene::Option("interleave", "false",
306 "Whether to interleave vertex attribute data [true,false]");306 "Whether to interleave vertex attribute data",
307 "false,true");
307 options_["update-method"] = Scene::Option("update-method", "map",308 options_["update-method"] = Scene::Option("update-method", "map",
308 "[map,subdata]");309 "Which method to use to update vertex data",
310 "map,subdata");
309 options_["update-fraction"] = Scene::Option("update-fraction", "1.0",311 options_["update-fraction"] = Scene::Option("update-fraction", "1.0",
310 "The fraction of the mesh length that is updated at every iteration (0.0-1.0)");312 "The fraction of the mesh length that is updated at every iteration (0.0-1.0)");
311 options_["update-dispersion"] = Scene::Option("update-dispersion", "0.0",313 options_["update-dispersion"] = Scene::Option("update-dispersion", "0.0",
@@ -315,7 +317,8 @@
315 options_["rows"] = Scene::Option("rows", "20",317 options_["rows"] = Scene::Option("rows", "20",
316 "The number of mesh subdisivisions width-wise");318 "The number of mesh subdisivisions width-wise");
317 options_["buffer-usage"] = Scene::Option("buffer-usage", "static",319 options_["buffer-usage"] = Scene::Option("buffer-usage", "static",
318 "How the buffer will be used [static,stream,dynamic]");320 "How the buffer will be used",
321 "static,stream,dynamic");
319}322}
320323
321SceneBuffer::~SceneBuffer()324SceneBuffer::~SceneBuffer()
322325
=== modified file 'src/scene-build.cpp'
--- src/scene-build.cpp 2012-05-22 08:46:33 +0000
+++ src/scene-build.cpp 2012-07-17 14:39:31 +0000
@@ -36,7 +36,7 @@
36 orientModel_(false)36 orientModel_(false)
37{37{
38 const ModelMap& modelMap = Model::find_models();38 const ModelMap& modelMap = Model::find_models();
39 std::string optionDesc("Which model to use [");39 std::string optionValues;
40 for (ModelMap::const_iterator modelIt = modelMap.begin();40 for (ModelMap::const_iterator modelIt = modelMap.begin();
41 modelIt != modelMap.end();41 modelIt != modelMap.end();
42 modelIt++)42 modelIt++)
@@ -44,19 +44,20 @@
44 static bool doSeparator(false);44 static bool doSeparator(false);
45 if (doSeparator)45 if (doSeparator)
46 {46 {
47 optionDesc += ", ";47 optionValues += ",";
48 }48 }
49 const std::string& curName = modelIt->first;49 const std::string& curName = modelIt->first;
50 optionDesc += curName;50 optionValues += curName;
51 doSeparator = true;51 doSeparator = true;
52 }52 }
53 optionDesc += "]";
54 options_["use-vbo"] = Scene::Option("use-vbo", "true",53 options_["use-vbo"] = Scene::Option("use-vbo", "true",
55 "Whether to use VBOs for rendering [true,false]");54 "Whether to use VBOs for rendering",
55 "false,true");
56 options_["interleave"] = Scene::Option("interleave", "false",56 options_["interleave"] = Scene::Option("interleave", "false",
57 "Whether to interleave vertex attribute data [true,false]");57 "Whether to interleave vertex attribute data",
58 options_["model"] = Scene::Option("model", "horse",58 "false,true");
59 optionDesc);59 options_["model"] = Scene::Option("model", "horse", "Which model to use",
60 optionValues);
60}61}
6162
62SceneBuild::~SceneBuild()63SceneBuild::~SceneBuild()
6364
=== modified file 'src/scene-bump.cpp'
--- src/scene-bump.cpp 2012-05-15 18:38:47 +0000
+++ src/scene-bump.cpp 2012-07-17 14:39:31 +0000
@@ -35,7 +35,8 @@
35 texture_(0), rotation_(0.0f), rotationSpeed_(0.0f)35 texture_(0), rotation_(0.0f), rotationSpeed_(0.0f)
36{36{
37 options_["bump-render"] = Scene::Option("bump-render", "off",37 options_["bump-render"] = Scene::Option("bump-render", "off",
38 "How to render bumps [off, normals, normals-tangent, height, high-poly]");38 "How to render bumps",
39 "off,normals,normals-tangent,height,high-poly");
39}40}
4041
41SceneBump::~SceneBump()42SceneBump::~SceneBump()
4243
=== modified file 'src/scene-conditionals.cpp'
--- src/scene-conditionals.cpp 2011-11-11 11:07:15 +0000
+++ src/scene-conditionals.cpp 2012-07-17 14:39:31 +0000
@@ -42,11 +42,11 @@
42 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",42 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",
43 "The number of computational steps in the fragment shader");43 "The number of computational steps in the fragment shader");
44 options_["fragment-conditionals"] = Scene::Option("fragment-conditionals", "true",44 options_["fragment-conditionals"] = Scene::Option("fragment-conditionals", "true",
45 "Whether each computational step includes an if-else clause");45 "Whether each computational step includes an if-else clause", "false,true");
46 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",46 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",
47 "The number of computational steps in the vertex shader");47 "The number of computational steps in the vertex shader");
48 options_["vertex-conditionals"] = Scene::Option("vertex-conditionals", "true",48 options_["vertex-conditionals"] = Scene::Option("vertex-conditionals", "true",
49 "Whether each computational step includes an if-else clause");49 "Whether each computational step includes an if-else clause", "false,true");
50}50}
5151
52SceneConditionals::~SceneConditionals()52SceneConditionals::~SceneConditionals()
5353
=== modified file 'src/scene-default-options.cpp'
--- src/scene-default-options.cpp 2011-10-26 14:09:17 +0000
+++ src/scene-default-options.cpp 2012-07-17 14:39:31 +0000
@@ -21,6 +21,7 @@
21 */21 */
22#include "scene.h"22#include "scene.h"
23#include "benchmark.h"23#include "benchmark.h"
24#include "log.h"
2425
25void26void
26SceneDefaultOptions::setup()27SceneDefaultOptions::setup()
@@ -35,7 +36,18 @@
35 scene_iter != scenes.end();36 scene_iter != scenes.end();
36 scene_iter++)37 scene_iter++)
37 {38 {
38 scene_iter->second->set_option_default(iter->first, iter->second);39 Scene &scene(*(scene_iter->second));
40
41 /*
42 * Display warning only if the option value is unsupported, not if
43 * the scene doesn't support the option at all.
44 */
45 if (!scene.set_option_default(iter->first, iter->second) &&
46 scene.options().find(iter->first) != scene.options().end())
47 {
48 Log::info("Warning: Scene '%s' doesn't accept default value '%s' for option '%s'\n",
49 scene.name().c_str(), iter->second.c_str(), iter->first.c_str());
50 }
39 }51 }
40 }52 }
41}53}
4254
=== modified file 'src/scene-desktop.cpp'
--- src/scene-desktop.cpp 2012-05-15 18:38:47 +0000
+++ src/scene-desktop.cpp 2012-07-17 14:39:31 +0000
@@ -759,8 +759,8 @@
759 Scene(canvas, "desktop")759 Scene(canvas, "desktop")
760{760{
761 priv_ = new SceneDesktopPrivate(canvas);761 priv_ = new SceneDesktopPrivate(canvas);
762 options_["effect"] = Scene::Option("effect", "blur",762 options_["effect"] = Scene::Option("effect", "blur", "The effect to use",
763 "the effect to use [blur]");763 "blur,shadow");
764 options_["windows"] = Scene::Option("windows", "4",764 options_["windows"] = Scene::Option("windows", "4",
765 "the number of windows");765 "the number of windows");
766 options_["window-size"] = Scene::Option("window-size", "0.35",766 options_["window-size"] = Scene::Option("window-size", "0.35",
@@ -770,7 +770,8 @@
770 options_["blur-radius"] = Scene::Option("blur-radius", "5",770 options_["blur-radius"] = Scene::Option("blur-radius", "5",
771 "the blur effect radius (in pixels)");771 "the blur effect radius (in pixels)");
772 options_["separable"] = Scene::Option("separable", "true",772 options_["separable"] = Scene::Option("separable", "true",
773 "use separable convolution for the blur effect");773 "use separable convolution for the blur effect",
774 "false,true");
774 options_["shadow-size"] = Scene::Option("shadow-size", "20",775 options_["shadow-size"] = Scene::Option("shadow-size", "20",
775 "the size of the shadow (in pixels)");776 "the size of the shadow (in pixels)");
776}777}
777778
=== modified file 'src/scene-effect-2d.cpp'
--- src/scene-effect-2d.cpp 2012-05-15 18:38:47 +0000
+++ src/scene-effect-2d.cpp 2012-07-17 14:39:31 +0000
@@ -41,7 +41,8 @@
41 "0,0,0;0,1,0;0,0,0",41 "0,0,0;0,1,0;0,0,0",
42 "The convolution kernel matrix to use [format: \"a,b,c...;d,e,f...\"");;42 "The convolution kernel matrix to use [format: \"a,b,c...;d,e,f...\"");;
43 options_["normalize"] = Scene::Option("normalize", "true",43 options_["normalize"] = Scene::Option("normalize", "true",
44 "Whether to normalize the supplied convolution kernel matrix [true,false]");44 "Whether to normalize the supplied convolution kernel matrix",
45 "false,true");
45}46}
4647
47SceneEffect2D::~SceneEffect2D()48SceneEffect2D::~SceneEffect2D()
4849
=== modified file 'src/scene-function.cpp'
--- src/scene-function.cpp 2011-11-11 11:07:15 +0000
+++ src/scene-function.cpp 2012-07-17 14:39:31 +0000
@@ -43,15 +43,15 @@
43 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",43 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",
44 "The number of computational steps in the fragment shader");44 "The number of computational steps in the fragment shader");
45 options_["fragment-function"] = Scene::Option("fragment-function", "true",45 options_["fragment-function"] = Scene::Option("fragment-function", "true",
46 "Whether each computational step includes a function call");46 "Whether each computational step includes a function call", "false,true");
47 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",47 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",
48 "The number of computational steps in the vertex shader");48 "The number of computational steps in the vertex shader");
49 options_["vertex-function"] = Scene::Option("vertex-function", "true",49 options_["vertex-function"] = Scene::Option("vertex-function", "true",
50 "Whether each computational step includes an if-else clause");50 "Whether each computational step includes an if-else clause", "false,true");
51 options_["vertex-complexity"] = Scene::Option("vertex-complexity", "low",51 options_["vertex-complexity"] = Scene::Option("vertex-complexity", "low",
52 "The complexity of each computational step in the vertex shader");52 "The complexity of each computational step in the vertex shader", "low,medium");
53 options_["fragment-complexity"] = Scene::Option("fragment-complexity", "low",53 options_["fragment-complexity"] = Scene::Option("fragment-complexity", "low",
54 "The complexity of each computational step in the fragment shader");54 "The complexity of each computational step in the fragment shader", "low,medium");
55}55}
5656
57SceneFunction::~SceneFunction()57SceneFunction::~SceneFunction()
5858
=== modified file 'src/scene-loop.cpp'
--- src/scene-loop.cpp 2011-11-11 11:07:15 +0000
+++ src/scene-loop.cpp 2012-07-17 14:39:31 +0000
@@ -42,15 +42,17 @@
42 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",42 options_["fragment-steps"] = Scene::Option("fragment-steps", "1",
43 "The number of computational steps in the fragment shader");43 "The number of computational steps in the fragment shader");
44 options_["fragment-loop"] = Scene::Option("fragment-function", "true",44 options_["fragment-loop"] = Scene::Option("fragment-function", "true",
45 "Whether to execute the steps in the vertex shader using a for loop");45 "Whether to execute the steps in the vertex shader using a for loop", "false,true");
46 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",46 options_["vertex-steps"] = Scene::Option("vertex-steps", "1",
47 "The number of computational steps in the vertex shader");47 "The number of computational steps in the vertex shader");
48 options_["vertex-loop"] = Scene::Option("vertex-function", "true",48 options_["vertex-loop"] = Scene::Option("vertex-function", "true",
49 "Whether to execute the steps in the vertex shader using a for loop");49 "Whether to execute the steps in the vertex shader using a for loop", "false,true");
50 options_["vertex-uniform"] = Scene::Option("vertex-uniform", "true",50 options_["vertex-uniform"] = Scene::Option("vertex-uniform", "true",
51 "Whether to use a uniform in the vertex shader for the number of loop iterations to perform (i.e. vertex-steps)");51 "Whether to use a uniform in the vertex shader for the number of loop iterations to perform (i.e. vertex-steps)",
52 "false,true");
52 options_["fragment-uniform"] = Scene::Option("fragment-uniform", "true",53 options_["fragment-uniform"] = Scene::Option("fragment-uniform", "true",
53 "Whether to use a uniform in the fragment shader for the number of loop iterations to perform (i.e. fragment-steps)");54 "Whether to use a uniform in the fragment shader for the number of loop iterations to perform (i.e. fragment-steps)",
55 "false,true");
54}56}
5557
56SceneLoop::~SceneLoop()58SceneLoop::~SceneLoop()
5759
=== modified file 'src/scene-pulsar.cpp'
--- src/scene-pulsar.cpp 2012-05-15 18:38:47 +0000
+++ src/scene-pulsar.cpp 2012-07-17 14:39:31 +0000
@@ -46,9 +46,12 @@
46 texture_(0)46 texture_(0)
47{47{
48 options_["quads"] = Scene::Option("quads", "5", "Number of quads to render");48 options_["quads"] = Scene::Option("quads", "5", "Number of quads to render");
49 options_["texture"] = Scene::Option("texture", "false", "Enable texturing");49 options_["texture"] = Scene::Option("texture", "false", "Enable texturing",
50 options_["light"] = Scene::Option("light", "false", "Enable lighting");50 "false,true");
51 options_["random"] = Scene::Option("random", "false", "Enable random rotation speeds");51 options_["light"] = Scene::Option("light", "false", "Enable lighting",
52 "false,true");
53 options_["random"] = Scene::Option("random", "false", "Enable random rotation speeds",
54 "false,true");
52}55}
5356
54ScenePulsar::~ScenePulsar()57ScenePulsar::~ScenePulsar()
5558
=== modified file 'src/scene-shading.cpp'
--- src/scene-shading.cpp 2012-05-22 08:46:33 +0000
+++ src/scene-shading.cpp 2012-07-17 14:39:31 +0000
@@ -43,7 +43,7 @@
43 orientModel_(false)43 orientModel_(false)
44{44{
45 const ModelMap& modelMap = Model::find_models();45 const ModelMap& modelMap = Model::find_models();
46 std::string optionDesc("Which model to use [");46 std::string optionValues;
47 for (ModelMap::const_iterator modelIt = modelMap.begin();47 for (ModelMap::const_iterator modelIt = modelMap.begin();
48 modelIt != modelMap.end();48 modelIt != modelMap.end();
49 modelIt++)49 modelIt++)
@@ -51,19 +51,19 @@
51 static bool doSeparator(false);51 static bool doSeparator(false);
52 if (doSeparator)52 if (doSeparator)
53 {53 {
54 optionDesc += ", ";54 optionValues += ",";
55 }55 }
56 const std::string& curName = modelIt->first;56 const std::string& curName = modelIt->first;
57 optionDesc += curName;57 optionValues += curName;
58 doSeparator = true;58 doSeparator = true;
59 }59 }
60 optionDesc += "]";
61 options_["shading"] = Scene::Option("shading", "gouraud",60 options_["shading"] = Scene::Option("shading", "gouraud",
62 "[gouraud, blinn-phong-inf, phong]");61 "Which shading method to use",
62 "gouraud,blinn-phong-inf,phong");
63 options_["num-lights"] = Scene::Option("num-lights", "1",63 options_["num-lights"] = Scene::Option("num-lights", "1",
64 "The number of lights applied to the scene (phong only)");64 "The number of lights applied to the scene (phong only)");
65 options_["model"] = Scene::Option("model", "cat",65 options_["model"] = Scene::Option("model", "cat", "Which model to use",
66 optionDesc);66 optionValues);
67}67}
6868
69SceneShading::~SceneShading()69SceneShading::~SceneShading()
7070
=== modified file 'src/scene-terrain.cpp'
--- src/scene-terrain.cpp 2012-07-03 09:56:14 +0000
+++ src/scene-terrain.cpp 2012-07-17 14:39:31 +0000
@@ -218,9 +218,11 @@
218 options_["repeat-overlay"] = Scene::Option("repeat-overlay", "6.0",218 options_["repeat-overlay"] = Scene::Option("repeat-overlay", "6.0",
219 "How many times to repeat the terrain texture on the terrain plane (per side)");219 "How many times to repeat the terrain texture on the terrain plane (per side)");
220 options_["bloom"] = Scene::Option("bloom", "true",220 options_["bloom"] = Scene::Option("bloom", "true",
221 "Use bloom post-processing effect [true,false]");221 "Use bloom post-processing effect",
222 "false,true");
222 options_["tilt-shift"] = Scene::Option("tilt-shift", "true",223 options_["tilt-shift"] = Scene::Option("tilt-shift", "true",
223 "Use tilt-shift post-processing effect [true,false]");224 "Use tilt-shift post-processing effect",
225 "false,true");
224}226}
225227
226SceneTerrain::~SceneTerrain()228SceneTerrain::~SceneTerrain()
227229
=== modified file 'src/scene-texture.cpp'
--- src/scene-texture.cpp 2012-07-04 10:07:42 +0000
+++ src/scene-texture.cpp 2012-07-17 14:39:31 +0000
@@ -42,7 +42,7 @@
42 orientModel_(false), orientationAngle_(0.0)42 orientModel_(false), orientationAngle_(0.0)
43{43{
44 const ModelMap& modelMap = Model::find_models();44 const ModelMap& modelMap = Model::find_models();
45 string optionDesc("Which model to use [");45 string optionValues;
46 for (ModelMap::const_iterator modelIt = modelMap.begin();46 for (ModelMap::const_iterator modelIt = modelMap.begin();
47 modelIt != modelMap.end();47 modelIt != modelMap.end();
48 modelIt++)48 modelIt++)
@@ -50,18 +50,18 @@
50 static bool doSeparator(false);50 static bool doSeparator(false);
51 if (doSeparator)51 if (doSeparator)
52 {52 {
53 optionDesc += ", ";53 optionValues += ",";
54 }54 }
55 const std::string& curName = modelIt->first;55 const std::string& curName = modelIt->first;
56 optionDesc += curName;56 optionValues += curName;
57 doSeparator = true;57 doSeparator = true;
58 }58 }
59 optionDesc += "]";59 options_["model"] = Scene::Option("model", "cube", "Which model to use",
60 options_["model"] = Scene::Option("model", "cube",60 optionValues);
61 optionDesc);
62 options_["texture-filter"] = Scene::Option("texture-filter", "nearest",61 options_["texture-filter"] = Scene::Option("texture-filter", "nearest",
63 "[nearest, linear, linear-shader, mipmap]");62 "The texture filter to use",
64 optionDesc = "Which texture to use [";63 "nearest,linear,linear-shader,mipmap");
64 optionValues = "";
65 const TextureMap& textureMap = Texture::find_textures();65 const TextureMap& textureMap = Texture::find_textures();
66 for (TextureMap::const_iterator textureIt = textureMap.begin();66 for (TextureMap::const_iterator textureIt = textureMap.begin();
67 textureIt != textureMap.end();67 textureIt != textureMap.end();
@@ -70,17 +70,17 @@
70 static bool doSeparator(false);70 static bool doSeparator(false);
71 if (doSeparator)71 if (doSeparator)
72 {72 {
73 optionDesc += ", ";73 optionValues += ",";
74 }74 }
75 const std::string& curName = textureIt->first;75 const std::string& curName = textureIt->first;
76 optionDesc += curName;76 optionValues += curName;
77 doSeparator = true;77 doSeparator = true;
78 }78 }
79 optionDesc += "]";79 options_["texture"] = Scene::Option("texture", "crate-base", "Which texture to use",
80 options_["texture"] = Scene::Option("texture", "crate-base",80 optionValues);
81 optionDesc);
82 options_["texgen"] = Scene::Option("texgen", "false",81 options_["texgen"] = Scene::Option("texgen", "false",
83 "Whether to generate texcoords in the shader");82 "Whether to generate texcoords in the shader",
83 "false,true");
84}84}
8585
86SceneTexture::~SceneTexture()86SceneTexture::~SceneTexture()
8787
=== modified file 'src/scene.cpp'
--- src/scene.cpp 2012-02-15 16:22:18 +0000
+++ src/scene.cpp 2012-07-17 14:39:31 +0000
@@ -28,11 +28,19 @@
28#include "util.h"28#include "util.h"
29#include <sstream>29#include <sstream>
30#include <cmath>30#include <cmath>
31#include <algorithm>
3132
32using std::stringstream;33using std::stringstream;
33using std::string;34using std::string;
34using std::map;35using std::map;
3536
37Scene::Option::Option(const std::string &nam, const std::string &val, const std::string &desc,
38 const std::string &values) :
39name(nam), value(val), default_value(val), description(desc), set(false)
40{
41 Util::split(values, ',', acceptable_values);
42}
43
36Scene::Scene(Canvas &pCanvas, const string &name) :44Scene::Scene(Canvas &pCanvas, const string &name) :
37 canvas_(pCanvas), name_(name),45 canvas_(pCanvas), name_(name),
38 startTime_(0), lastUpdateTime_(0), currentFrame_(0),46 startTime_(0), lastUpdateTime_(0), currentFrame_(0),
@@ -48,7 +56,8 @@
48 "The precision values for the fragment shader (\"int,float,sampler2d,samplercube\")");56 "The precision values for the fragment shader (\"int,float,sampler2d,samplercube\")");
49 /* FPS options */57 /* FPS options */
50 options_["show-fps"] = Scene::Option("show-fps", "false",58 options_["show-fps"] = Scene::Option("show-fps", "false",
51 "Show live FPS counter");59 "Show live FPS counter",
60 "false,true");
52 options_["fps-pos"] = Scene::Option("fps-pos", "-1.0,-1.0",61 options_["fps-pos"] = Scene::Option("fps-pos", "-1.0,-1.0",
53 "The position on screen where to show FPS");62 "The position on screen where to show FPS");
54 options_["fps-size"] = Scene::Option("fps-size", "0.03",63 options_["fps-size"] = Scene::Option("fps-size", "0.03",
@@ -143,6 +152,14 @@
143 if (iter == options_.end())152 if (iter == options_.end())
144 return false;153 return false;
145154
155 std::vector<std::string> &values(iter->second.acceptable_values);
156
157 if (!values.empty() &&
158 std::find(values.begin(), values.end(), val) == values.end())
159 {
160 return false;
161 }
162
146 iter->second.value = val;163 iter->second.value = val;
147 iter->second.set = true;164 iter->second.set = true;
148165
@@ -171,6 +188,14 @@
171 if (iter == options_.end())188 if (iter == options_.end())
172 return false;189 return false;
173190
191 std::vector<std::string> &values(iter->second.acceptable_values);
192
193 if (!values.empty() &&
194 std::find(values.begin(), values.end(), val) == values.end())
195 {
196 return false;
197 }
198
174 iter->second.default_value = val;199 iter->second.default_value = val;
175200
176 return true;201 return true;
177202
=== modified file 'src/scene.h'
--- src/scene.h 2012-07-09 15:54:30 +0000
+++ src/scene.h 2012-07-17 14:39:31 +0000
@@ -37,6 +37,7 @@
37#include <string>37#include <string>
38#include <map>38#include <map>
39#include <list>39#include <list>
40#include <vector>
40#include "canvas.h"41#include "canvas.h"
4142
42/**43/**
@@ -51,13 +52,15 @@
51 * Scene options.52 * Scene options.
52 */53 */
53 struct Option {54 struct Option {
54 Option(const std::string &nam, const std::string &val, const std::string &desc) :55 Option(const std::string &nam, const std::string &val, const std::string &desc,
55 name(nam), value(val), default_value(val), description(desc), set(false) {}56 const std::string &values = "");
57
56 Option() {}58 Option() {}
57 std::string name;59 std::string name;
58 std::string value;60 std::string value;
59 std::string default_value;61 std::string default_value;
60 std::string description;62 std::string description;
63 std::vector<std::string> acceptable_values;
61 bool set;64 bool set;
62 };65 };
6366

Subscribers

People subscribed via source and target branches