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