diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/runtime.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/runtime.js | 446 |
1 files changed, 223 insertions, 223 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/runtime.js b/js/helper-classes/RDGE/src/core/script/runtime.js index 2660e26a..5e6203fb 100755 --- a/js/helper-classes/RDGE/src/core/script/runtime.js +++ b/js/helper-classes/RDGE/src/core/script/runtime.js | |||
@@ -1,223 +1,223 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | BSD License. |
5 | 5 | ||
6 | Redistribution and use in source and binary forms, with or without | 6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 7 | modification, are permitted provided that the following conditions are met: |
8 | 8 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 9 | - Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 10 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | - Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the | 12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. | 13 | documentation and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | - Neither the name of Motorola Mobility nor the names of its contributors |
15 | may be used to endorse or promote products derived from this software | 15 | may be used to endorse or promote products derived from this software |
16 | without specific prior written permission. | 16 | without specific prior written permission. |
17 | 17 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | // RDGE namespaces | 31 | // RDGE namespaces |
32 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
33 | RDGE.core = RDGE.core || {}; | 33 | RDGE.core = RDGE.core || {}; |
34 | RDGE.utilities = RDGE.utilities || {}; | 34 | RDGE.utilities = RDGE.utilities || {}; |
35 | 35 | ||
36 | // runtime globals | 36 | // runtime globals |
37 | RDGE.globals = (function () { | 37 | RDGE.globals = (function () { |
38 | return { | 38 | return { |
39 | engine: new RDGE.Engine(), | 39 | engine: new RDGE.Engine(), |
40 | width: 0, | 40 | width: 0, |
41 | height: 0, | 41 | height: 0, |
42 | cam: null, | 42 | cam: null, |
43 | shaderMan: null, | 43 | shaderMan: null, |
44 | meshMan: null, | 44 | meshMan: null, |
45 | poolList: [], | 45 | poolList: [], |
46 | gl: null | 46 | gl: null |
47 | }; | 47 | }; |
48 | })(); | 48 | })(); |
49 | 49 | ||
50 | // new code is above | 50 | // new code is above |
51 | /***************************************************************************************************************/ | 51 | /***************************************************************************************************************/ |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * RDGEState a RDGEstate is an interface that is defined by the user and called by the engine | 54 | * RDGEState a RDGEstate is an interface that is defined by the user and called by the engine |
55 | */ | 55 | */ |
56 | RDGE.core.RDGEState = function RDGEState() { }; | 56 | RDGE.core.RDGEState = function RDGEState() { }; |
57 | RDGE.core.RDGEState.prototype.init = function () { }; | 57 | RDGE.core.RDGEState.prototype.init = function () { }; |
58 | RDGE.core.RDGEState.prototype.update = function () { }; | 58 | RDGE.core.RDGEState.prototype.update = function () { }; |
59 | RDGE.core.RDGEState.prototype.draw = function () { }; | 59 | RDGE.core.RDGEState.prototype.draw = function () { }; |
60 | RDGE.core.RDGEState.prototype.resize = function () { }; | 60 | RDGE.core.RDGEState.prototype.resize = function () { }; |
61 | RDGE.core.RDGEState.prototype.shutdown = function () { }; | 61 | RDGE.core.RDGEState.prototype.shutdown = function () { }; |
62 | RDGE.core.RDGEState.prototype.onComplete = function () { }; | 62 | RDGE.core.RDGEState.prototype.onComplete = function () { }; |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Calling this makes sure the passed in run state has all the functions | 65 | * Calling this makes sure the passed in run state has all the functions |
66 | * that are required, adding dummy functions where needed | 66 | * that are required, adding dummy functions where needed |
67 | */ | 67 | */ |
68 | RDGE.utilities.validateUserState = function (userState) { | 68 | RDGE.utilities.validateUserState = function (userState) { |
69 | if (!userState.init) { | 69 | if (!userState.init) { |
70 | userState.init = function () { }; | 70 | userState.init = function () { }; |
71 | } | 71 | } |
72 | if (!userState.update) { | 72 | if (!userState.update) { |
73 | userState.update = function (dt) { | 73 | userState.update = function (dt) { |
74 | var currentScene = RDGE.globals.engine.getContext().currentScene; | 74 | var currentScene = RDGE.globals.engine.getContext().currentScene; |
75 | currentScene = RDGE.globals.engine.getScene(currentScene); | 75 | currentScene = RDGE.globals.engine.getScene(currentScene); |
76 | 76 | ||
77 | if (currentScene != null) | 77 | if (currentScene != null) |
78 | currentScene.update(dt); | 78 | currentScene.update(dt); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | if (!userState.draw) { | 81 | if (!userState.draw) { |
82 | userState.draw = function () { | 82 | userState.draw = function () { |
83 | var currentScene = RDGE.globals.engine.getContext().currentScene; | 83 | var currentScene = RDGE.globals.engine.getContext().currentScene; |
84 | currentScene = RDGE.globals.engine.getScene(currentScene); | 84 | currentScene = RDGE.globals.engine.getScene(currentScene); |
85 | 85 | ||
86 | if (currentScene == null) | 86 | if (currentScene == null) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | currentScene.render(); | 89 | currentScene.render(); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | if (!userState.resize) { | 92 | if (!userState.resize) { |
93 | userState.resize = function () { }; | 93 | userState.resize = function () { }; |
94 | } | 94 | } |
95 | if (!userState.shutdown) { | 95 | if (!userState.shutdown) { |
96 | userState.shutdown = function () { }; | 96 | userState.shutdown = function () { }; |
97 | } | 97 | } |
98 | if (!userState.onComplete) { | 98 | if (!userState.onComplete) { |
99 | userState.onComplete = function () { }; | 99 | userState.onComplete = function () { }; |
100 | } | 100 | } |
101 | }; | 101 | }; |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Used to start the RDGE engine, pass the initState and runState, both of which are RDGEState objects | 104 | * Used to start the RDGE engine, pass the initState and runState, both of which are RDGEState objects |
105 | * initState is used to asynchronously load scene data while allowing you to render and update if needed | 105 | * initState is used to asynchronously load scene data while allowing you to render and update if needed |
106 | * runState is used clear the execution path for regular rendering and updating once loading is complete | 106 | * runState is used clear the execution path for regular rendering and updating once loading is complete |
107 | * @param initState - the initialization state, false if you don't want to use one | 107 | * @param initState - the initialization state, false if you don't want to use one |
108 | * @param runState - the run state | 108 | * @param runState - the run state |
109 | */ | 109 | */ |
110 | RDGE.RDGEStart = function (canvasOrID) { | 110 | RDGE.RDGEStart = function (canvasOrID) { |
111 | var canvas = canvasOrID; | 111 | var canvas = canvasOrID; |
112 | 112 | ||
113 | if (typeof (canvasOrID) === "string") | 113 | if (typeof (canvasOrID) === "string") |
114 | canvas = document.getElementById(canvasOrID); | 114 | canvas = document.getElementById(canvasOrID); |
115 | 115 | ||
116 | if (!canvas) | 116 | if (!canvas) |
117 | return; | 117 | return; |
118 | 118 | ||
119 | RDGE.globals.engine.registerCanvas(canvas); | 119 | RDGE.globals.engine.registerCanvas(canvas); |
120 | 120 | ||
121 | if (!canvas.task) | 121 | if (!canvas.task) |
122 | { | 122 | { |
123 | //canvas.task = new RDGE.RDGETask(canvas, true); | 123 | //canvas.task = new RDGE.RDGETask(canvas, true); |
124 | canvas.task = new RDGE.RDGETask(canvas, false); | 124 | canvas.task = new RDGE.RDGETask(canvas, false); |
125 | } | 125 | } |
126 | 126 | ||
127 | if (!RDGE.globals.shaderMan) | 127 | if (!RDGE.globals.shaderMan) |
128 | RDGE.globals.shaderMan = new RDGE.ShaderManager(); | 128 | RDGE.globals.shaderMan = new RDGE.ShaderManager(); |