Alexandros Frantzis | 04c9034 | 2010-07-13 13:22:05 +0300 | [diff] [blame] | 1 | /* |
Marc Ordinas i Llopis | 7689cac | 2011-08-17 19:01:31 +0200 | [diff] [blame] | 2 | * Copyright © 2008 Ben Smith |
Alexandros Frantzis | 77036b5 | 2011-01-25 17:00:12 +0200 | [diff] [blame] | 3 | * Copyright © 2010-2011 Linaro Limited |
Alexandros Frantzis | 04c9034 | 2010-07-13 13:22:05 +0300 | [diff] [blame] | 4 | * |
| 5 | * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. |
| 6 | * |
| 7 | * glmark2 is free software: you can redistribute it and/or modify it under the |
Alexandros Frantzis | 77036b5 | 2011-01-25 17:00:12 +0200 | [diff] [blame] | 8 | * terms of the GNU General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later |
| 10 | * version. |
Alexandros Frantzis | 04c9034 | 2010-07-13 13:22:05 +0300 | [diff] [blame] | 11 | * |
| 12 | * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 15 | * details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * glmark2. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * Authors: |
| 21 | * Ben Smith (original glmark benchmark) |
| 22 | * Alexandros Frantzis (glmark2) |
Marc Ordinas i Llopis | beeee45 | 2011-08-11 12:43:16 +0200 | [diff] [blame] | 23 | * Marc Ordinas i Llopis, Collabora Ltd. (pulsar scene) |
Jesse Barker | 2459b3d | 2011-11-04 14:28:13 -0400 | [diff] [blame] | 24 | * Jesse Barker (glmark2) |
Alexandros Frantzis | 04c9034 | 2010-07-13 13:22:05 +0300 | [diff] [blame] | 25 | */ |
Alexandros Frantzis | 2da7e4d | 2011-01-25 17:06:04 +0200 | [diff] [blame] | 26 | #ifndef GLMARK2_SCENE_H_ |
| 27 | #define GLMARK2_SCENE_H_ |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 28 | |
Alexandros Frantzis | c590303 | 2011-06-30 16:33:37 +0300 | [diff] [blame] | 29 | #include "gl-headers.h" |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 30 | |
| 31 | #include "mesh.h" |
Alexandros Frantzis | 8943a51 | 2011-06-17 12:39:44 +0300 | [diff] [blame] | 32 | #include "vec.h" |
Alexandros Frantzis | ee6b22d | 2011-06-17 16:16:16 +0300 | [diff] [blame] | 33 | #include "program.h" |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 34 | |
| 35 | #include <math.h> |
| 36 | |
Alexandros Frantzis | 901eab3 | 2011-06-06 14:57:03 +0300 | [diff] [blame] | 37 | #include <string> |
Alexandros Frantzis | 15deb68 | 2011-06-06 15:06:32 +0300 | [diff] [blame] | 38 | #include <map> |
Alexandros Frantzis | f76d779 | 2011-06-23 15:32:34 +0300 | [diff] [blame] | 39 | #include <list> |
Alexandros Frantzis | 3a246d5 | 2012-07-16 17:00:56 +0300 | [diff] [blame] | 40 | #include <vector> |
Jesse Barker | 2459b3d | 2011-11-04 14:28:13 -0400 | [diff] [blame] | 41 | #include "canvas.h" |
Alexandros Frantzis | 901eab3 | 2011-06-06 14:57:03 +0300 | [diff] [blame] | 42 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 43 | /** |
| 44 | * A configurable scene used for creating benchmarks. |
| 45 | */ |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 46 | class Scene |
| 47 | { |
| 48 | public: |
Alexandros Frantzis | 99429bd | 2011-08-16 10:37:52 +0300 | [diff] [blame] | 49 | virtual ~Scene(); |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 50 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 51 | /** |
| 52 | * Scene options. |
| 53 | */ |
Alexandros Frantzis | 15deb68 | 2011-06-06 15:06:32 +0300 | [diff] [blame] | 54 | struct Option { |
Alexandros Frantzis | 3a246d5 | 2012-07-16 17:00:56 +0300 | [diff] [blame] | 55 | Option(const std::string &nam, const std::string &val, const std::string &desc, |
| 56 | const std::string &values = ""); |
| 57 | |
Alexandros Frantzis | 15deb68 | 2011-06-06 15:06:32 +0300 | [diff] [blame] | 58 | Option() {} |
Jesse Barker | b711fcb | 2011-06-07 14:06:38 -0700 | [diff] [blame] | 59 | std::string name; |
| 60 | std::string value; |
| 61 | std::string default_value; |
| 62 | std::string description; |
Alexandros Frantzis | 3a246d5 | 2012-07-16 17:00:56 +0300 | [diff] [blame] | 63 | std::vector<std::string> acceptable_values; |
Alexandros Frantzis | 15bb051 | 2011-09-20 12:45:24 +0300 | [diff] [blame] | 64 | bool set; |
Alexandros Frantzis | 15deb68 | 2011-06-06 15:06:32 +0300 | [diff] [blame] | 65 | }; |
| 66 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 67 | /** |
| 68 | * The result of a validation check. |
| 69 | */ |
Alexandros Frantzis | 7a996a1 | 2011-06-15 14:24:41 +0300 | [diff] [blame] | 70 | enum ValidationResult { |
| 71 | ValidationFailure, |
| 72 | ValidationSuccess, |
| 73 | ValidationUnknown |
| 74 | }; |
| 75 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 76 | /** |
Alexandros Frantzis | 24d4339 | 2012-08-15 10:38:45 +0300 | [diff] [blame] | 77 | * Checks whether this scene (in its current configuration) is supported. |
| 78 | * |
| 79 | * @param show_errors whether to log errors about unsupported features |
| 80 | * |
| 81 | * @return whether the scene is supported |
| 82 | */ |
| 83 | virtual bool supported(bool show_errors); |
| 84 | |
| 85 | /** |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 86 | * Performs option-independent resource loading and configuration. |
| 87 | * |
| 88 | * It should be safe to call ::load() (and the corresponding ::unload()) |
| 89 | * only once per program execution, although you may choose to do so more |
| 90 | * times to better manage resource consumption. |
| 91 | * |
| 92 | * @return whether loading succeeded |
| 93 | */ |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 94 | virtual bool load(); |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Performs option-independent resource unloading. |
| 98 | */ |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 99 | virtual void unload(); |
Alexandros Frantzis | acbe24c | 2011-06-07 12:05:05 +0300 | [diff] [blame] | 100 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 101 | /** |
| 102 | * Performs option-dependent resource loading and configuration. |
| 103 | * |
| 104 | * This method also prepares a scene for a benchmark run. |
| 105 | * It should be called just before running a scene/benchmark. |
| 106 | * |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 107 | * The base Scene::setup() method also checks whether a scene |
| 108 | * configuration is supported by calling ::supported(true). |
| 109 | * |
| 110 | * @return whether setting the scene up succeeded |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 111 | */ |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 112 | virtual bool setup(); |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Performs option-dependent resource unloading. |
| 116 | * |
| 117 | * This method should be called just after running a scene/benchmark. |
| 118 | * |
| 119 | * @return the operation status |
| 120 | */ |
Alexandros Frantzis | acbe24c | 2011-06-07 12:05:05 +0300 | [diff] [blame] | 121 | virtual void teardown(); |
| 122 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 123 | /** |
| 124 | * Updates the scene state. |
| 125 | */ |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 126 | virtual void update(); |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * Draws the current scene state. |
| 130 | */ |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 131 | virtual void draw(); |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * Gets an informational string describing the scene. |
| 135 | * |
| 136 | * @param title if specified, a custom title to use, instead of the default |
| 137 | */ |
Jesse Barker | b711fcb | 2011-06-07 14:06:38 -0700 | [diff] [blame] | 138 | virtual std::string info_string(const std::string &title = ""); |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 139 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 140 | /** |
| 141 | * Sets the value of an option for this scene. |
| 142 | * |
| 143 | * @param opt the option to set |
| 144 | * @param val the value to set the option to |
| 145 | * |
| 146 | * @return whether the option value was set successfully |
| 147 | */ |
| 148 | virtual bool set_option(const std::string &opt, const std::string &val); |
| 149 | |
| 150 | /** |
| 151 | * Validates the current output of this scene. |
| 152 | * |
| 153 | * This method should be called after having called ::draw() once. |
| 154 | * |
| 155 | * @return the validation result |
| 156 | */ |
| 157 | virtual ValidationResult validate() { return ValidationUnknown; } |
| 158 | |
| 159 | /** |
| 160 | * Gets whether this scene is running. |
| 161 | * |
| 162 | * @return true if running, false otherwise |
| 163 | */ |
Alexandros Frantzis | 9f12fe5 | 2012-02-09 03:28:16 +0200 | [diff] [blame] | 164 | bool running() { return running_; } |
| 165 | |
| 166 | /** |
| 167 | * Sets whether this scene is running. |
| 168 | * |
| 169 | * @return true if running, false otherwise |
| 170 | */ |
| 171 | void running(bool r) { running_ = r; } |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 172 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 173 | /** |
| 174 | * Gets the average FPS value for this scene. |
| 175 | * |
| 176 | * @return the average FPS value |
| 177 | */ |
| 178 | unsigned average_fps(); |
| 179 | |
| 180 | /** |
| 181 | * Gets the name of the scene. |
| 182 | * @return the name of the scene |
| 183 | */ |
Jesse Barker | 3897946 | 2011-10-25 11:05:37 -0700 | [diff] [blame] | 184 | const std::string &name() { return name_; } |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 185 | |
| 186 | /** |
| 187 | * Resets all scene options to their default values. |
| 188 | */ |
Alexandros Frantzis | f89d1be | 2011-06-07 11:10:02 +0300 | [diff] [blame] | 189 | void reset_options(); |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 190 | |
| 191 | /** |
| 192 | * Sets the default value of a scene option. |
| 193 | */ |
Alexandros Frantzis | f76d779 | 2011-06-23 15:32:34 +0300 | [diff] [blame] | 194 | bool set_option_default(const std::string &opt, const std::string &val); |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 195 | |
| 196 | /** |
| 197 | * Gets the scene options. |
| 198 | * |
| 199 | * @return the scene options |
| 200 | */ |
Jesse Barker | 3897946 | 2011-10-25 11:05:37 -0700 | [diff] [blame] | 201 | const std::map<std::string, Option> &options() { return options_; } |
Alexandros Frantzis | 901eab3 | 2011-06-06 14:57:03 +0300 | [diff] [blame] | 202 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 203 | /** |
| 204 | * Gets a dummy scene object reference. |
| 205 | * |
| 206 | * @return the dummy Scene |
| 207 | */ |
Alexandros Frantzis | 01596e7 | 2011-06-09 16:07:57 +0300 | [diff] [blame] | 208 | static Scene &dummy() |
| 209 | { |
Alexandros Frantzis | 215dedb | 2011-06-30 11:38:35 +0300 | [diff] [blame] | 210 | static Scene dummy_scene(Canvas::dummy(), ""); |
Alexandros Frantzis | 01596e7 | 2011-06-09 16:07:57 +0300 | [diff] [blame] | 211 | return dummy_scene; |
| 212 | } |
| 213 | |
Alexandros Frantzis | 6826124 | 2011-11-08 23:33:18 +0200 | [diff] [blame] | 214 | /** |
| 215 | * Loads a shader program from a pair of vertex and fragment shader strings. |
| 216 | * |
| 217 | * @return whether the operation succeeded |
| 218 | */ |
Alexandros Frantzis | 2c780ae | 2011-07-04 13:46:22 +0300 | [diff] [blame] | 219 | static bool load_shaders_from_strings(Program &program, |
| 220 | const std::string &vtx_shader, |
| 221 | const std::string &frg_shader, |
| 222 | const std::string &vtx_shader_filename = "None", |
| 223 | const std::string &frg_shader_filename = "None"); |
Alexandros Frantzis | 74db09e | 2011-06-30 15:39:37 +0300 | [diff] [blame] | 224 | |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 225 | protected: |
Alexandros Frantzis | 215dedb | 2011-06-30 11:38:35 +0300 | [diff] [blame] | 226 | Scene(Canvas &pCanvas, const std::string &name); |
Jesse Barker | b711fcb | 2011-06-07 14:06:38 -0700 | [diff] [blame] | 227 | std::string construct_title(const std::string &title); |
Alexandros Frantzis | 901eab3 | 2011-06-06 14:57:03 +0300 | [diff] [blame] | 228 | |
Jesse Barker | 3897946 | 2011-10-25 11:05:37 -0700 | [diff] [blame] | 229 | Canvas &canvas_; |
| 230 | std::string name_; |
| 231 | std::map<std::string, Option> options_; |
| 232 | double startTime_; |
| 233 | double lastUpdateTime_; |
| 234 | unsigned currentFrame_; |
Jesse Barker | 3897946 | 2011-10-25 11:05:37 -0700 | [diff] [blame] | 235 | bool running_; |
| 236 | double duration_; // Duration of run in seconds |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 237 | }; |
| 238 | |
Alexandros Frantzis | f76d779 | 2011-06-23 15:32:34 +0300 | [diff] [blame] | 239 | /* |
| 240 | * Special Scene used for setting the default options |
| 241 | */ |
| 242 | class SceneDefaultOptions : public Scene |
| 243 | { |
| 244 | public: |
Alexandros Frantzis | 215dedb | 2011-06-30 11:38:35 +0300 | [diff] [blame] | 245 | SceneDefaultOptions(Canvas &pCanvas) : Scene(pCanvas, "") {} |
Alexandros Frantzis | f76d779 | 2011-06-23 15:32:34 +0300 | [diff] [blame] | 246 | bool set_option(const std::string &opt, const std::string &val); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 247 | bool setup(); |
Alexandros Frantzis | f76d779 | 2011-06-23 15:32:34 +0300 | [diff] [blame] | 248 | |
| 249 | private: |
Jesse Barker | b250935 | 2011-10-25 09:48:24 -0700 | [diff] [blame] | 250 | std::list<std::pair<std::string, std::string> > defaultOptions_; |
Alexandros Frantzis | f76d779 | 2011-06-23 15:32:34 +0300 | [diff] [blame] | 251 | }; |
| 252 | |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 253 | class SceneBuild : public Scene |
| 254 | { |
| 255 | public: |
Alexandros Frantzis | 215dedb | 2011-06-30 11:38:35 +0300 | [diff] [blame] | 256 | SceneBuild(Canvas &pCanvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 257 | bool load(); |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 258 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 259 | bool setup(); |
Alexandros Frantzis | d9441a3 | 2011-06-07 17:36:16 +0300 | [diff] [blame] | 260 | void teardown(); |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 261 | void update(); |
| 262 | void draw(); |
Alexandros Frantzis | 3ff0500 | 2011-06-15 14:44:36 +0300 | [diff] [blame] | 263 | ValidationResult validate(); |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 264 | |
Alexandros Frantzis | 1103411 | 2010-07-09 13:16:27 +0300 | [diff] [blame] | 265 | ~SceneBuild(); |
| 266 | |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 267 | protected: |
Jesse Barker | 9ee5aa9 | 2011-10-25 09:22:24 -0700 | [diff] [blame] | 268 | Program program_; |
| 269 | LibMatrix::mat4 perspective_; |
| 270 | LibMatrix::vec3 centerVec_; |
| 271 | float radius_; |
| 272 | Mesh mesh_; |
| 273 | bool orientModel_; |
| 274 | float orientationAngle_; |
| 275 | LibMatrix::vec3 orientationVec_; |
| 276 | float rotation_; |
| 277 | float rotationSpeed_; |
| 278 | bool useVbo_; |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 279 | }; |
| 280 | |
| 281 | class SceneTexture : public Scene |
| 282 | { |
| 283 | public: |
Alexandros Frantzis | 215dedb | 2011-06-30 11:38:35 +0300 | [diff] [blame] | 284 | SceneTexture(Canvas &pCanvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 285 | bool load(); |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 286 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 287 | bool setup(); |
Alexandros Frantzis | d9441a3 | 2011-06-07 17:36:16 +0300 | [diff] [blame] | 288 | void teardown(); |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 289 | void update(); |
| 290 | void draw(); |
Alexandros Frantzis | 3965159 | 2011-06-16 10:39:55 +0300 | [diff] [blame] | 291 | ValidationResult validate(); |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 292 | |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 293 | ~SceneTexture(); |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 294 | |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 295 | protected: |
Jesse Barker | 9c9a0e5 | 2011-10-25 09:52:06 -0700 | [diff] [blame] | 296 | Program program_; |
| 297 | Mesh mesh_; |
| 298 | GLuint texture_; |
Jesse Barker | 8f56efc | 2012-05-15 13:46:43 +0100 | [diff] [blame] | 299 | float radius_; |
| 300 | bool orientModel_; |
| 301 | float orientationAngle_; |
| 302 | LibMatrix::vec3 orientationVec_; |
| 303 | LibMatrix::mat4 perspective_; |
| 304 | LibMatrix::vec3 centerVec_; |
Jesse Barker | 9c9a0e5 | 2011-10-25 09:52:06 -0700 | [diff] [blame] | 305 | LibMatrix::vec3 rotation_; |
| 306 | LibMatrix::vec3 rotationSpeed_; |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 307 | }; |
| 308 | |
| 309 | class SceneShading : public Scene |
| 310 | { |
| 311 | public: |
Alexandros Frantzis | 215dedb | 2011-06-30 11:38:35 +0300 | [diff] [blame] | 312 | SceneShading(Canvas &pCanvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 313 | bool load(); |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 314 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 315 | bool setup(); |
Alexandros Frantzis | d9441a3 | 2011-06-07 17:36:16 +0300 | [diff] [blame] | 316 | void teardown(); |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 317 | void update(); |
| 318 | void draw(); |
Alexandros Frantzis | 1e3ec48 | 2011-06-16 10:43:05 +0300 | [diff] [blame] | 319 | ValidationResult validate(); |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 320 | |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 321 | ~SceneShading(); |
Alexandros Frantzis | 28e6871 | 2010-07-09 17:21:56 +0300 | [diff] [blame] | 322 | |
Alexandros Frantzis | db4ea39 | 2010-07-09 15:11:52 +0300 | [diff] [blame] | 323 | protected: |
Jesse Barker | dee36f4 | 2011-10-25 08:59:27 -0700 | [diff] [blame] | 324 | Program program_; |
| 325 | float radius_; |
| 326 | bool orientModel_; |
| 327 | float orientationAngle_; |
| 328 | LibMatrix::vec3 orientationVec_; |
| 329 | LibMatrix::vec3 centerVec_; |
| 330 | LibMatrix::mat4 perspective_; |
| 331 | Mesh mesh_; |
| 332 | float rotation_; |
| 333 | float rotationSpeed_; |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 334 | }; |
| 335 | |
Alexandros Frantzis | 66b1b9e | 2011-07-07 16:35:24 +0300 | [diff] [blame] | 336 | class SceneGrid : public Scene |
| 337 | { |
| 338 | public: |
| 339 | SceneGrid(Canvas &pCanvas, const std::string &name); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 340 | virtual bool load(); |
Alexandros Frantzis | 66b1b9e | 2011-07-07 16:35:24 +0300 | [diff] [blame] | 341 | virtual void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 342 | virtual bool setup(); |
Alexandros Frantzis | 66b1b9e | 2011-07-07 16:35:24 +0300 | [diff] [blame] | 343 | virtual void teardown(); |
| 344 | virtual void update(); |
| 345 | virtual void draw(); |
| 346 | virtual ValidationResult validate(); |
| 347 | |
| 348 | ~SceneGrid(); |
| 349 | |
| 350 | protected: |
Jesse Barker | 92cb241 | 2011-10-25 09:43:13 -0700 | [diff] [blame] | 351 | Program program_; |
| 352 | Mesh mesh_; |
| 353 | float rotation_; |
| 354 | float rotationSpeed_; |
Alexandros Frantzis | 66b1b9e | 2011-07-07 16:35:24 +0300 | [diff] [blame] | 355 | }; |
| 356 | |
Alexandros Frantzis | eec4de8 | 2011-07-07 16:45:19 +0300 | [diff] [blame] | 357 | class SceneConditionals : public SceneGrid |
Alexandros Frantzis | 3b02770 | 2011-07-04 16:22:56 +0300 | [diff] [blame] | 358 | { |
| 359 | public: |
| 360 | SceneConditionals(Canvas &pCanvas); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 361 | bool setup(); |
Alexandros Frantzis | 3495a67 | 2011-11-08 13:31:02 +0200 | [diff] [blame] | 362 | ValidationResult validate(); |
Alexandros Frantzis | 3b02770 | 2011-07-04 16:22:56 +0300 | [diff] [blame] | 363 | |
| 364 | ~SceneConditionals(); |
Alexandros Frantzis | 3b02770 | 2011-07-04 16:22:56 +0300 | [diff] [blame] | 365 | }; |
Alexandros Frantzis | 16a5762 | 2011-07-07 16:16:12 +0300 | [diff] [blame] | 366 | |
Alexandros Frantzis | 66b1b9e | 2011-07-07 16:35:24 +0300 | [diff] [blame] | 367 | class SceneFunction : public SceneGrid |
Alexandros Frantzis | 16a5762 | 2011-07-07 16:16:12 +0300 | [diff] [blame] | 368 | { |
| 369 | public: |
| 370 | SceneFunction(Canvas &pCanvas); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 371 | bool setup(); |
Alexandros Frantzis | 1bf3f8a | 2011-11-08 13:38:43 +0200 | [diff] [blame] | 372 | ValidationResult validate(); |
Alexandros Frantzis | 16a5762 | 2011-07-07 16:16:12 +0300 | [diff] [blame] | 373 | |
| 374 | ~SceneFunction(); |
Alexandros Frantzis | 16a5762 | 2011-07-07 16:16:12 +0300 | [diff] [blame] | 375 | }; |
Alexandros Frantzis | 36e215c | 2011-07-08 15:48:36 +0300 | [diff] [blame] | 376 | |
| 377 | class SceneLoop : public SceneGrid |
| 378 | { |
| 379 | public: |
| 380 | SceneLoop(Canvas &pCanvas); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 381 | bool setup(); |
Alexandros Frantzis | d4d802c | 2011-11-08 13:43:43 +0200 | [diff] [blame] | 382 | ValidationResult validate(); |
Alexandros Frantzis | 36e215c | 2011-07-08 15:48:36 +0300 | [diff] [blame] | 383 | |
| 384 | ~SceneLoop(); |
| 385 | }; |
Alexandros Frantzis | be27cc6 | 2011-07-14 14:25:43 +0300 | [diff] [blame] | 386 | |
| 387 | class SceneBump : public Scene |
| 388 | { |
| 389 | public: |
| 390 | SceneBump(Canvas &pCanvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 391 | bool load(); |
Alexandros Frantzis | be27cc6 | 2011-07-14 14:25:43 +0300 | [diff] [blame] | 392 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 393 | bool setup(); |
Alexandros Frantzis | be27cc6 | 2011-07-14 14:25:43 +0300 | [diff] [blame] | 394 | void teardown(); |
| 395 | void update(); |
| 396 | void draw(); |
| 397 | ValidationResult validate(); |
| 398 | |
| 399 | ~SceneBump(); |
| 400 | |
| 401 | protected: |
Jesse Barker | 6e8f083 | 2011-10-25 09:59:18 -0700 | [diff] [blame] | 402 | Program program_; |
| 403 | Mesh mesh_; |
| 404 | GLuint texture_; |
| 405 | float rotation_; |
| 406 | float rotationSpeed_; |
Alexandros Frantzis | be27cc6 | 2011-07-14 14:25:43 +0300 | [diff] [blame] | 407 | private: |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 408 | bool setup_model_plain(const std::string &type); |
| 409 | bool setup_model_normals(); |
| 410 | bool setup_model_normals_tangent(); |
| 411 | bool setup_model_height(); |
Alexandros Frantzis | be27cc6 | 2011-07-14 14:25:43 +0300 | [diff] [blame] | 412 | }; |
| 413 | |
Alexandros Frantzis | 61eb827 | 2011-07-28 11:44:31 +0300 | [diff] [blame] | 414 | class SceneEffect2D : public Scene |
| 415 | { |
| 416 | public: |
| 417 | SceneEffect2D(Canvas &pCanvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 418 | bool load(); |
Alexandros Frantzis | 61eb827 | 2011-07-28 11:44:31 +0300 | [diff] [blame] | 419 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 420 | bool setup(); |
Alexandros Frantzis | 61eb827 | 2011-07-28 11:44:31 +0300 | [diff] [blame] | 421 | void teardown(); |
| 422 | void update(); |
| 423 | void draw(); |
| 424 | ValidationResult validate(); |
| 425 | |
| 426 | ~SceneEffect2D(); |
| 427 | |
| 428 | protected: |
| 429 | Program program_; |
| 430 | |
| 431 | Mesh mesh_; |
| 432 | GLuint texture_; |
| 433 | }; |
Marc Ordinas i Llopis | beeee45 | 2011-08-11 12:43:16 +0200 | [diff] [blame] | 434 | |
| 435 | class ScenePulsar : public Scene |
| 436 | { |
| 437 | public: |
| 438 | ScenePulsar(Canvas &pCanvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 439 | bool load(); |
Marc Ordinas i Llopis | beeee45 | 2011-08-11 12:43:16 +0200 | [diff] [blame] | 440 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 441 | bool setup(); |
Marc Ordinas i Llopis | beeee45 | 2011-08-11 12:43:16 +0200 | [diff] [blame] | 442 | void teardown(); |
| 443 | void update(); |
| 444 | void draw(); |
| 445 | ValidationResult validate(); |
| 446 | |
| 447 | ~ScenePulsar(); |
| 448 | |
| 449 | protected: |
Jesse Barker | c12f550 | 2011-10-25 10:04:28 -0700 | [diff] [blame] | 450 | int numQuads_; |
| 451 | Program program_; |
| 452 | Mesh mesh_; |
| 453 | LibMatrix::vec3 scale_; |
| 454 | std::vector<LibMatrix::vec3> rotations_; |
| 455 | std::vector<LibMatrix::vec3> rotationSpeeds_; |
| 456 | GLuint texture_; |
Alexandros Frantzis | e7e0de7 | 2011-08-18 16:20:04 +0300 | [diff] [blame] | 457 | |
| 458 | private: |
| 459 | void create_and_setup_mesh(); |
Marc Ordinas i Llopis | beeee45 | 2011-08-11 12:43:16 +0200 | [diff] [blame] | 460 | }; |
| 461 | |
Alexandros Frantzis | 3a79068 | 2011-09-09 16:57:53 +0300 | [diff] [blame] | 462 | struct SceneDesktopPrivate; |
| 463 | |
| 464 | class SceneDesktop : public Scene |
| 465 | { |
| 466 | public: |
| 467 | SceneDesktop(Canvas &canvas); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 468 | bool load(); |
Alexandros Frantzis | 3a79068 | 2011-09-09 16:57:53 +0300 | [diff] [blame] | 469 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 470 | bool setup(); |
Alexandros Frantzis | 3a79068 | 2011-09-09 16:57:53 +0300 | [diff] [blame] | 471 | void teardown(); |
| 472 | void update(); |
| 473 | void draw(); |
| 474 | ValidationResult validate(); |
| 475 | |
| 476 | ~SceneDesktop(); |
| 477 | |
| 478 | private: |
| 479 | SceneDesktopPrivate *priv_; |
| 480 | }; |
Alexandros Frantzis | 73dd23e | 2011-10-04 18:53:47 +0300 | [diff] [blame] | 481 | |
| 482 | struct SceneBufferPrivate; |
| 483 | |
| 484 | class SceneBuffer : public Scene |
| 485 | { |
| 486 | public: |
| 487 | SceneBuffer(Canvas &canvas); |
Alexandros Frantzis | 24d4339 | 2012-08-15 10:38:45 +0300 | [diff] [blame] | 488 | bool supported(bool show_errors); |
Alexandros Frantzis | 0d6a00a | 2011-11-08 23:40:36 +0200 | [diff] [blame] | 489 | bool load(); |
Alexandros Frantzis | 73dd23e | 2011-10-04 18:53:47 +0300 | [diff] [blame] | 490 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 491 | bool setup(); |
Alexandros Frantzis | 73dd23e | 2011-10-04 18:53:47 +0300 | [diff] [blame] | 492 | void teardown(); |
| 493 | void update(); |
| 494 | void draw(); |
| 495 | ValidationResult validate(); |
| 496 | |
| 497 | ~SceneBuffer(); |
| 498 | |
| 499 | private: |
| 500 | SceneBufferPrivate *priv_; |
Alexandros Frantzis | 73dd23e | 2011-10-04 18:53:47 +0300 | [diff] [blame] | 501 | }; |
Jesse Barker | 67acfc3 | 2012-04-27 11:00:45 -0700 | [diff] [blame] | 502 | |
| 503 | class SceneIdeasPrivate; |
| 504 | |
| 505 | class SceneIdeas : public Scene |
| 506 | { |
| 507 | public: |
| 508 | SceneIdeas(Canvas &pCanvas); |
| 509 | bool load(); |
| 510 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 511 | bool setup(); |
Jesse Barker | 67acfc3 | 2012-04-27 11:00:45 -0700 | [diff] [blame] | 512 | void teardown(); |
| 513 | void update(); |
| 514 | void draw(); |
| 515 | ValidationResult validate(); |
| 516 | |
| 517 | ~SceneIdeas(); |
| 518 | |
| 519 | private: |
| 520 | SceneIdeasPrivate* priv_; |
| 521 | }; |
| 522 | |
Alexandros Frantzis | 5d0013f | 2012-06-29 15:27:16 +0300 | [diff] [blame] | 523 | class SceneTerrainPrivate; |
| 524 | |
| 525 | class SceneTerrain : public Scene |
| 526 | { |
| 527 | public: |
| 528 | SceneTerrain(Canvas &pCanvas); |
Alexandros Frantzis | 24d4339 | 2012-08-15 10:38:45 +0300 | [diff] [blame] | 529 | bool supported(bool show_errors); |
Alexandros Frantzis | 5d0013f | 2012-06-29 15:27:16 +0300 | [diff] [blame] | 530 | bool load(); |
| 531 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 532 | bool setup(); |
Alexandros Frantzis | 5d0013f | 2012-06-29 15:27:16 +0300 | [diff] [blame] | 533 | void teardown(); |
| 534 | void update(); |
| 535 | void draw(); |
| 536 | ValidationResult validate(); |
| 537 | |
| 538 | ~SceneTerrain(); |
| 539 | |
| 540 | private: |
| 541 | SceneTerrainPrivate* priv_; |
| 542 | }; |
| 543 | |
Jesse Barker | 16cfee0 | 2012-07-02 10:34:48 -0700 | [diff] [blame] | 544 | class JellyfishPrivate; |
| 545 | class SceneJellyfish : public Scene |
| 546 | { |
| 547 | JellyfishPrivate* priv_; |
| 548 | public: |
| 549 | SceneJellyfish(Canvas &pCanvas); |
| 550 | ~SceneJellyfish(); |
| 551 | bool load(); |
| 552 | void unload(); |
Alexandros Frantzis | 2b0a1f0 | 2012-08-15 12:45:06 +0300 | [diff] [blame] | 553 | bool setup(); |
Jesse Barker | 16cfee0 | 2012-07-02 10:34:48 -0700 | [diff] [blame] | 554 | void teardown(); |
| 555 | void update(); |
| 556 | void draw(); |
| 557 | ValidationResult validate(); |
| 558 | }; |
Jesse Barker | bd764cf | 2012-10-19 06:19:19 -0700 | [diff] [blame] | 559 | |
| 560 | class ShadowPrivate; |
| 561 | class SceneShadow : public Scene |
| 562 | { |
| 563 | ShadowPrivate* priv_; |
| 564 | public: |
| 565 | SceneShadow(Canvas& canvas); |
| 566 | ~SceneShadow(); |
| 567 | bool supported(bool show_errors); |
| 568 | bool load(); |
| 569 | void unload(); |
| 570 | bool setup(); |
| 571 | void teardown(); |
| 572 | void update(); |
| 573 | void draw(); |
| 574 | ValidationResult validate(); |
| 575 | }; |
| 576 | |
Jesse Barker | b00c4a2 | 2012-12-07 11:57:44 -0800 | [diff] [blame] | 577 | class RefractPrivate; |
| 578 | class SceneRefract : public Scene |
| 579 | { |
| 580 | RefractPrivate* priv_; |
| 581 | public: |
| 582 | SceneRefract(Canvas& canvas); |
Jesse Barker | b00c4a2 | 2012-12-07 11:57:44 -0800 | [diff] [blame] | 583 | bool supported(bool show_errors); |
| 584 | bool load(); |
| 585 | void unload(); |
| 586 | bool setup(); |
| 587 | void teardown(); |
| 588 | void update(); |
| 589 | void draw(); |
| 590 | ValidationResult validate(); |
| 591 | }; |
| 592 | |
Alexandros Frantzis | d268350 | 2010-07-07 13:32:18 +0300 | [diff] [blame] | 593 | #endif |