├── Star.png
├── sicp.jpg
├── vertex.glsl
├── timing.png
├── dinosaur.jpg
├── fragment.glsl
├── vertex2.glsl
├── .gitignore
├── fragment2.glsl
├── index.html
├── debug.js
├── test.js
├── README.md
├── webGLShaderLoader.js
└── LICENSE
/Star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nickdesaulniers/webgl-shader-loader/HEAD/Star.png
--------------------------------------------------------------------------------
/sicp.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nickdesaulniers/webgl-shader-loader/HEAD/sicp.jpg
--------------------------------------------------------------------------------
/vertex.glsl:
--------------------------------------------------------------------------------
1 | void main () {
2 | gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/timing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nickdesaulniers/webgl-shader-loader/HEAD/timing.png
--------------------------------------------------------------------------------
/dinosaur.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nickdesaulniers/webgl-shader-loader/HEAD/dinosaur.jpg
--------------------------------------------------------------------------------
/fragment.glsl:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 | void main () {
3 | gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/vertex2.glsl:
--------------------------------------------------------------------------------
1 | uniform mat4 uMVP;
2 | attribute vec4 aPosition;
3 | varying vec4 vPosition;
4 | void main () {
5 | gl_Position = uMVP * aPosition;
6 | vPosition = aPosition;
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | lib-cov
2 | *.seed
3 | *.log
4 | *.csv
5 | *.dat
6 | *.out
7 | *.pid
8 | *.gz
9 | *.swp
10 |
11 | pids
12 | logs
13 | results
14 |
15 | npm-debug.log
16 | node_modules
17 |
--------------------------------------------------------------------------------
/fragment2.glsl:
--------------------------------------------------------------------------------
1 | precision mediump float;
2 | uniform vec4 uColor;
3 | varying vec4 vPosition;
4 | void main () {
5 | gl_FragColor = uColor * normalize(dot(vPosition, vec4(0, 0, 0, 1)));
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/debug.js:
--------------------------------------------------------------------------------
1 | function debugTriangle (a, b, c) {
2 | var str = "(";
3 | for (var i = 0; i < arguments.length; ++i) {
4 | str += "(";
5 | for (var j = 0; j < arguments[i].length; ++j) {
6 | str += arguments[i][j];
7 | if (j !== arguments[i].length - 1) {
8 | str += ", ";
9 | }
10 | }
11 | str += ")";
12 | }
13 | str += ")";
14 | console.log(str);
15 | };
16 |
17 |
--------------------------------------------------------------------------------
/test.js:
--------------------------------------------------------------------------------
1 | var gl = document.createElement("canvas").getContext("webgl");
2 |
3 | var vertexShaderStr =
4 | "void main () { gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }";
5 |
6 | var fragmentShaderStr =
7 | "precision mediump float; void main () { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }";
8 |
9 | var loader = new WebGLShaderLoader(gl);
10 |
11 | loader.loadFromStr(vertexShaderStr, fragmentShaderStr, function (errors, program) {
12 | if (errors.length > 0) {
13 | console.error.apply(console, errors);
14 | return;
15 | }
16 |
17 | console.log(program);
18 | });
19 |
20 | var vertexShaderPath = "vertex.glsl";
21 | var fragmentShaderPath = "fragment.glsl";
22 |
23 | loader.loadFromXHR(vertexShaderPath, fragmentShaderPath, function (errors, program) {
24 | if (errors.length > 0) {
25 | console.error.apply(console, errors);
26 | return;
27 | }
28 |
29 | console.log(program);
30 | });
31 |
32 | var shaderUrls = ['vertex2.glsl', 'fragment2.glsl', 'vertex.glsl', 'fragment.glsl'];
33 | var imgUrls = ['Star.png', 'sicp.jpg', 'dinosaur.jpg'];
34 | WebGLShaderLoader.load(gl, shaderUrls, imgUrls, function (e, gl, p, i) {
35 | console.log(arguments);
36 | });
37 |
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | webgl-shader-loader
2 | ===================
3 |
4 | Asynchronous load, compile, and link webgl shader programs
5 |
6 | ```html
7 |
8 | ```
9 |
10 | 
11 |
12 | Shaders can be fetched and compiled independently. Images used for textures
13 | can also be fetched asynchronously. This library helps you load, compile,
14 | and link shaders and images without waiting for each other, other than a
15 | vertex or fragment shader waiting to link with its compiled other half.
16 |
17 | ##Load WebGL Programs From Shader URL Pairs And Images From URLs
18 | ```javascript
19 | var shaderUrls = ['vertex1.glsl', 'frag1.glsl', 'vertex2.glsl', 'frag2.glsl'];
20 | var imgUrls = ['texture1.jpg', 'texture2.jpg', 'texture3.jpg'];
21 |
22 | WebGLShaderLoader.load($gl, shaderUrls, imgUrls, function (errors, gl, programs, images) {
23 | if (errors.length) return console.error.apply(console, errors);
24 |
25 | console.log(programs, images);
26 | gl.useProgram(programs[0].program);
27 | gl.uniform1f(programs[0].uniforms.uTime, 42.0)
28 | });
29 | ```
30 | `$gl` can be an existing webGL context or a canvas element (in the DOM or not).
31 |
32 | `shaderUrls` is an array of strings of URLs to shaders. Expects pairs of atleast one,
33 | alternating vertexShaderURL, fragmentShaderURL.
34 |
35 | `imgUrls` is an array of strings of URLs to `
`s. May be empty or null.
36 |
37 | `errors` is a possibly empty array of strings.
38 |
39 | `gl` is a webGL context, regardless of `$gl`.
40 |
41 | `programs` is an array of objects, in order of the pairs. The objects contain
42 | the keys `attributes`, `program`, and `uniforms`. `program` is the
43 | WebGLProgram, ready for use. The `attributes` and `uniforms` keys point to
44 | objects whose keys are the identifiers and values are the locations.
45 |
46 | `images` is a possibly empty array of img elements ready to be sampled.
47 |
48 | ##Load WebGL Program From Shader String Literals
49 | ```javascript
50 | var loader = new WebGLShaderLoader(gl);
51 | loader.loadFromStr(vertexShaderStr, fragmentShaderStr, function (errors, program) {
52 | if (errors.length > 0) {
53 | console.error.apply(console, errors);
54 | return;
55 | }
56 |
57 | console.log(program);
58 | });
59 | ```
60 |
61 | ##Load WebGL Program From XHR'd Files
62 | ```javascript
63 | var loader = new WebGLShaderLoader(gl);
64 | loader.loadFromXHR(vertexShaderPath, fragmentShaderPath, function (errors, program) {
65 | if (errors.length > 0) {
66 | console.error.apply(console, errors);
67 | return;
68 | }
69 |
70 | console.log(program);
71 | });
72 | ```
73 |
74 | ###Notes
75 | * Look at test.js for further usage/example
76 | * errors is an array of strings of usage, compilation, and linkage errors, it's up to you to check these.
77 |
78 | ###License
79 | "THE BEER-WARE LICENSE" (Revision 42):
80 | wrote this file. As long as you retain this notice you
81 | can do whatever you want with this stuff. If we meet some day, and you think
82 | this stuff is worth it, you can buy me a beer in return. Nick Desaulniers
83 |
84 |
--------------------------------------------------------------------------------
/webGLShaderLoader.js:
--------------------------------------------------------------------------------
1 | var WebGLShaderLoader = (function () {
2 | var vertexShaderType = WebGLRenderingContext.prototype.VERTEX_SHADER;
3 | var fragmentShaderType = WebGLRenderingContext.prototype.FRAGMENT_SHADER;
4 |
5 | function WebGLShaderLoader (gl) {
6 | this.errors = [];
7 | this.vertexShader = this.fragmentShader = null;
8 | this.gl = getContext(gl);
9 | if (!this.gl) this.errors.push("webgl unsupported");
10 | };
11 |
12 | WebGLShaderLoader.prototype = {
13 | loadFromStr: function (vertexShaderStr, fragmentShaderStr, cb) {
14 | if (typeof vertexShaderStr !== "string" ||
15 | typeof fragmentShaderStr !== "string" ||
16 | typeof cb !== "function") {
17 | this.errors.push("Usage: loaderInstance.loadFromStr('', '', function (errors, program));");
18 | cb(this.errors, null, this.gl);
19 | } else if (vertexShaderStr.length === 0 ||
20 | fragmentShaderStr.length === 0) {
21 | this.errors.push("empty shader string");
22 | cb(this.errors, null, this.gl);
23 | } else {
24 | this.vertexShader = this.compile(vertexShaderType, vertexShaderStr);
25 | this.fragmentShader = this.compile(fragmentShaderType, fragmentShaderStr);
26 |
27 | cb(this.errors, this.link(), this.gl);
28 | }
29 | },
30 | loadFromXHR: function (vertexShaderPath, fragmentShaderPath, cb) {
31 | if (typeof vertexShaderPath !== "string" ||
32 | typeof fragmentShaderPath !== "string" ||
33 | typeof cb !== "function") {
34 | this.errors.push("Usage: loaderInstance.loadFromXHR('', '', function (errors, program));");
35 | cb(this.errors, null, this.gl);
36 | return;
37 | }
38 |
39 | if (vertexShaderPath.length === 0 || fragmentShaderPath.length === 0) {
40 | this.errors.push("empty shader path");
41 | cb(this.errors, null, this.gl);
42 | return;
43 | }
44 |
45 | var numShadersLoaded = 0;
46 | var onload = function (shader, shaderType) {
47 | return function (twoHundredResponse, shaderStr) {
48 | if (!twoHundredResponse) {
49 | this.errors.push("xhr non 200 response code");
50 | cb(this.errors, null, this.gl);
51 | return;
52 | }
53 |
54 | this[shader] = this.compile(shaderType, shaderStr);
55 |
56 | if (++numShadersLoaded > 1) {
57 | cb(this.errors, this.link(), this.gl);
58 | }
59 | }.bind(this);
60 | }.bind(this);
61 | this.fetch(vertexShaderPath, onload("vertexShader", vertexShaderType));
62 | this.fetch(fragmentShaderPath, onload("fragmentShader", fragmentShaderType));
63 | },
64 | compile: function (type, shaderStr) {
65 | var shader = this.gl.createShader(type);
66 | this.gl.shaderSource(shader, shaderStr);
67 | this.gl.compileShader(shader);
68 |
69 | if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) {
70 | this.errors.push(this.gl.getShaderInfoLog(shader));
71 | }
72 |
73 | return shader;
74 | },
75 | link: function () {
76 | var program = this.gl.createProgram();
77 | this.gl.attachShader(program, this.vertexShader);
78 | this.gl.attachShader(program, this.fragmentShader);
79 | this.gl.linkProgram(program);
80 |
81 | if (!this.gl.getProgramParameter(program, this.gl.LINK_STATUS)) {
82 | this.errors.push(this.gl.getProgramInfoLog(program));
83 | }
84 |
85 | return program;
86 | },
87 | fetch: function (path, cb) {
88 | var xhr = new XMLHttpRequest;
89 | xhr.open("GET", path);
90 | xhr.onload = function () {
91 | cb(xhr.status === 200, xhr.response);
92 | };
93 | xhr.send();
94 | },
95 | };
96 |
97 | function getContext (glOrCanvas) {
98 | if (glOrCanvas instanceof HTMLCanvasElement) {
99 | return glOrCanvas.getContext('webgl') || glOrCanvas.getContext('experimental-webgl');
100 | } else {
101 | return glOrCanvas;
102 | }
103 | };
104 |
105 | function loadImages (imgSrcs, cb) {
106 | var len = imgSrcs.length;
107 | var images = [];
108 | var errors = [];
109 | var loaded = 0;
110 | function onLoad () { if (++loaded === len) cb(errors, images); };
111 | function onError (e) {
112 | errors.push("Failed to load " + e.target.src);
113 | onLoad();
114 | };
115 | for (var i = 0; i < len; ++i) {
116 | images[i] = new Image;
117 | images[i].onload = onLoad;
118 | images[i].onerror = onError;
119 | images[i].src = imgSrcs[i];
120 | }
121 | };
122 |
123 | function getQualifiersPartial(parameter, storage) {
124 | var getActive = "getActive" + storage;
125 | var getLocation = "get" + storage + "Location";
126 | return function (gl, program) {
127 | var len = gl.getProgramParameter(program, parameter);
128 | var qualifiers = {};
129 | var qualifier = null;
130 | for (var i = 0; i < len; ++i) {
131 | qualifier = gl[getActive](program, i).name;
132 | qualifiers[qualifier] = gl[getLocation](program, qualifier);
133 | }
134 | return qualifiers;
135 | };
136 | };
137 |
138 | var webGLProto = WebGLRenderingContext.prototype;
139 | var getAttributes = getQualifiersPartial(webGLProto.ACTIVE_ATTRIBUTES, "Attrib");
140 | var getUniforms = getQualifiersPartial(webGLProto.ACTIVE_UNIFORMS, "Uniform");
141 |
142 | WebGLShaderLoader.prototype.getAttributes = getAttributes;
143 | WebGLShaderLoader.prototype.getUniforms = getUniforms;
144 |
145 | // call with:
146 | // load(gl, ['a.vert', 'b.frag', 'c.vert', 'd.frag'], ['a.jpg', 'b.jpg'],
147 | // function (errors, gl, programs, imgs) { ... });
148 | WebGLShaderLoader.load = function (_gl, shaderUrls, imgUrls, cb) {
149 | imgUrls = imgUrls || [];
150 | var programsDone = 0;
151 | var shadersComplete = false;
152 | var imgsComplete = !imgUrls.length;
153 | var totalShaders = shaderUrls.length;
154 | var errors = [];
155 | var programs = [];
156 | var images = [];
157 |
158 | var gl = getContext(_gl);
159 | if (!gl) errors.push("webgl unsupported");
160 |
161 | if (!imgsComplete) {
162 | loadImages(imgUrls, function (e, imgs) {
163 | if (e.length) errors.concat(e);
164 | images = imgs;
165 | imgsComplete = true;
166 | if (shadersComplete) cb(errors, gl, programs, images);
167 | });
168 | }
169 |
170 | shaderUrls.forEach(function (shaderUrl, i) {
171 | if (i % 2 === 1) return;
172 | var loader = new WebGLShaderLoader(gl);
173 | loader.loadFromXHR(shaderUrls[i], shaderUrls[i + 1], function (e, program, _) {
174 | if (e.length) errors.concat(e);
175 | programs[i / 2] = {
176 | attributes: getAttributes(gl, program),
177 | program: program,
178 | uniforms: getUniforms(gl, program),
179 | };
180 | if (++programsDone === totalShaders / 2) {
181 | shadersComplete = true;
182 | if (imgsComplete) cb(errors, gl, programs, images);
183 | }
184 | });
185 | });
186 | };
187 |
188 | return WebGLShaderLoader;
189 | })();
190 |
191 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | /*
2 | * ----------------------------------------------------------------------------
3 | * "THE BEER-WARE LICENSE" (Revision 42):
4 | * wrote this file. As long as you retain this notice you
5 | * can do whatever you want with this stuff. If we meet some day, and you think
6 | * this stuff is worth it, you can buy me a beer in return Nick Desaulniers
7 | * ----------------------------------------------------------------------------
8 | */
9 |
10 | Mozilla Public License, version 2.0
11 |
12 | 1. Definitions
13 |
14 | 1.1. “Contributor”
15 |
16 | means each individual or legal entity that creates, contributes to the
17 | creation of, or owns Covered Software.
18 |
19 | 1.2. “Contributor Version”
20 |
21 | means the combination of the Contributions of others (if any) used by a
22 | Contributor and that particular Contributor’s Contribution.
23 |
24 | 1.3. “Contribution”
25 |
26 | means Covered Software of a particular Contributor.
27 |
28 | 1.4. “Covered Software”
29 |
30 | means Source Code Form to which the initial Contributor has attached the
31 | notice in Exhibit A, the Executable Form of such Source Code Form, and
32 | Modifications of such Source Code Form, in each case including portions
33 | thereof.
34 |
35 | 1.5. “Incompatible With Secondary Licenses”
36 | means
37 |
38 | a. that the initial Contributor has attached the notice described in
39 | Exhibit B to the Covered Software; or
40 |
41 | b. that the Covered Software was made available under the terms of version
42 | 1.1 or earlier of the License, but not also under the terms of a
43 | Secondary License.
44 |
45 | 1.6. “Executable Form”
46 |
47 | means any form of the work other than Source Code Form.
48 |
49 | 1.7. “Larger Work”
50 |
51 | means a work that combines Covered Software with other material, in a separate
52 | file or files, that is not Covered Software.
53 |
54 | 1.8. “License”
55 |
56 | means this document.
57 |
58 | 1.9. “Licensable”
59 |
60 | means having the right to grant, to the maximum extent possible, whether at the
61 | time of the initial grant or subsequently, any and all of the rights conveyed by
62 | this License.
63 |
64 | 1.10. “Modifications”
65 |
66 | means any of the following:
67 |
68 | a. any file in Source Code Form that results from an addition to, deletion
69 | from, or modification of the contents of Covered Software; or
70 |
71 | b. any new file in Source Code Form that contains any Covered Software.
72 |
73 | 1.11. “Patent Claims” of a Contributor
74 |
75 | means any patent claim(s), including without limitation, method, process,
76 | and apparatus claims, in any patent Licensable by such Contributor that
77 | would be infringed, but for the grant of the License, by the making,
78 | using, selling, offering for sale, having made, import, or transfer of
79 | either its Contributions or its Contributor Version.
80 |
81 | 1.12. “Secondary License”
82 |
83 | means either the GNU General Public License, Version 2.0, the GNU Lesser
84 | General Public License, Version 2.1, the GNU Affero General Public
85 | License, Version 3.0, or any later versions of those licenses.
86 |
87 | 1.13. “Source Code Form”
88 |
89 | means the form of the work preferred for making modifications.
90 |
91 | 1.14. “You” (or “Your”)
92 |
93 | means an individual or a legal entity exercising rights under this
94 | License. For legal entities, “You” includes any entity that controls, is
95 | controlled by, or is under common control with You. For purposes of this
96 | definition, “control” means (a) the power, direct or indirect, to cause
97 | the direction or management of such entity, whether by contract or
98 | otherwise, or (b) ownership of more than fifty percent (50%) of the
99 | outstanding shares or beneficial ownership of such entity.
100 |
101 |
102 | 2. License Grants and Conditions
103 |
104 | 2.1. Grants
105 |
106 | Each Contributor hereby grants You a world-wide, royalty-free,
107 | non-exclusive license:
108 |
109 | a. under intellectual property rights (other than patent or trademark)
110 | Licensable by such Contributor to use, reproduce, make available,
111 | modify, display, perform, distribute, and otherwise exploit its
112 | Contributions, either on an unmodified basis, with Modifications, or as
113 | part of a Larger Work; and
114 |
115 | b. under Patent Claims of such Contributor to make, use, sell, offer for
116 | sale, have made, import, and otherwise transfer either its Contributions
117 | or its Contributor Version.
118 |
119 | 2.2. Effective Date
120 |
121 | The licenses granted in Section 2.1 with respect to any Contribution become
122 | effective for each Contribution on the date the Contributor first distributes
123 | such Contribution.
124 |
125 | 2.3. Limitations on Grant Scope
126 |
127 | The licenses granted in this Section 2 are the only rights granted under this
128 | License. No additional rights or licenses will be implied from the distribution
129 | or licensing of Covered Software under this License. Notwithstanding Section
130 | 2.1(b) above, no patent license is granted by a Contributor:
131 |
132 | a. for any code that a Contributor has removed from Covered Software; or
133 |
134 | b. for infringements caused by: (i) Your and any other third party’s
135 | modifications of Covered Software, or (ii) the combination of its
136 | Contributions with other software (except as part of its Contributor
137 | Version); or
138 |
139 | c. under Patent Claims infringed by Covered Software in the absence of its
140 | Contributions.
141 |
142 | This License does not grant any rights in the trademarks, service marks, or
143 | logos of any Contributor (except as may be necessary to comply with the
144 | notice requirements in Section 3.4).
145 |
146 | 2.4. Subsequent Licenses
147 |
148 | No Contributor makes additional grants as a result of Your choice to
149 | distribute the Covered Software under a subsequent version of this License
150 | (see Section 10.2) or under the terms of a Secondary License (if permitted
151 | under the terms of Section 3.3).
152 |
153 | 2.5. Representation
154 |
155 | Each Contributor represents that the Contributor believes its Contributions
156 | are its original creation(s) or it has sufficient rights to grant the
157 | rights to its Contributions conveyed by this License.
158 |
159 | 2.6. Fair Use
160 |
161 | This License is not intended to limit any rights You have under applicable
162 | copyright doctrines of fair use, fair dealing, or other equivalents.
163 |
164 | 2.7. Conditions
165 |
166 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
167 | Section 2.1.
168 |
169 |
170 | 3. Responsibilities
171 |
172 | 3.1. Distribution of Source Form
173 |
174 | All distribution of Covered Software in Source Code Form, including any
175 | Modifications that You create or to which You contribute, must be under the
176 | terms of this License. You must inform recipients that the Source Code Form
177 | of the Covered Software is governed by the terms of this License, and how
178 | they can obtain a copy of this License. You may not attempt to alter or
179 | restrict the recipients’ rights in the Source Code Form.
180 |
181 | 3.2. Distribution of Executable Form
182 |
183 | If You distribute Covered Software in Executable Form then:
184 |
185 | a. such Covered Software must also be made available in Source Code Form,
186 | as described in Section 3.1, and You must inform recipients of the
187 | Executable Form how they can obtain a copy of such Source Code Form by
188 | reasonable means in a timely manner, at a charge no more than the cost
189 | of distribution to the recipient; and
190 |
191 | b. You may distribute such Executable Form under the terms of this License,
192 | or sublicense it under different terms, provided that the license for
193 | the Executable Form does not attempt to limit or alter the recipients’
194 | rights in the Source Code Form under this License.
195 |
196 | 3.3. Distribution of a Larger Work
197 |
198 | You may create and distribute a Larger Work under terms of Your choice,
199 | provided that You also comply with the requirements of this License for the
200 | Covered Software. If the Larger Work is a combination of Covered Software
201 | with a work governed by one or more Secondary Licenses, and the Covered
202 | Software is not Incompatible With Secondary Licenses, this License permits
203 | You to additionally distribute such Covered Software under the terms of
204 | such Secondary License(s), so that the recipient of the Larger Work may, at
205 | their option, further distribute the Covered Software under the terms of
206 | either this License or such Secondary License(s).
207 |
208 | 3.4. Notices
209 |
210 | You may not remove or alter the substance of any license notices (including
211 | copyright notices, patent notices, disclaimers of warranty, or limitations
212 | of liability) contained within the Source Code Form of the Covered
213 | Software, except that You may alter any license notices to the extent
214 | required to remedy known factual inaccuracies.
215 |
216 | 3.5. Application of Additional Terms
217 |
218 | You may choose to offer, and to charge a fee for, warranty, support,
219 | indemnity or liability obligations to one or more recipients of Covered
220 | Software. However, You may do so only on Your own behalf, and not on behalf
221 | of any Contributor. You must make it absolutely clear that any such
222 | warranty, support, indemnity, or liability obligation is offered by You
223 | alone, and You hereby agree to indemnify every Contributor for any
224 | liability incurred by such Contributor as a result of warranty, support,
225 | indemnity or liability terms You offer. You may include additional
226 | disclaimers of warranty and limitations of liability specific to any
227 | jurisdiction.
228 |
229 | 4. Inability to Comply Due to Statute or Regulation
230 |
231 | If it is impossible for You to comply with any of the terms of this License
232 | with respect to some or all of the Covered Software due to statute, judicial
233 | order, or regulation then You must: (a) comply with the terms of this License
234 | to the maximum extent possible; and (b) describe the limitations and the code
235 | they affect. Such description must be placed in a text file included with all
236 | distributions of the Covered Software under this License. Except to the
237 | extent prohibited by statute or regulation, such description must be
238 | sufficiently detailed for a recipient of ordinary skill to be able to
239 | understand it.
240 |
241 | 5. Termination
242 |
243 | 5.1. The rights granted under this License will terminate automatically if You
244 | fail to comply with any of its terms. However, if You become compliant,
245 | then the rights granted under this License from a particular Contributor
246 | are reinstated (a) provisionally, unless and until such Contributor
247 | explicitly and finally terminates Your grants, and (b) on an ongoing basis,
248 | if such Contributor fails to notify You of the non-compliance by some
249 | reasonable means prior to 60 days after You have come back into compliance.
250 | Moreover, Your grants from a particular Contributor are reinstated on an
251 | ongoing basis if such Contributor notifies You of the non-compliance by
252 | some reasonable means, this is the first time You have received notice of
253 | non-compliance with this License from such Contributor, and You become
254 | compliant prior to 30 days after Your receipt of the notice.
255 |
256 | 5.2. If You initiate litigation against any entity by asserting a patent
257 | infringement claim (excluding declaratory judgment actions, counter-claims,
258 | and cross-claims) alleging that a Contributor Version directly or
259 | indirectly infringes any patent, then the rights granted to You by any and
260 | all Contributors for the Covered Software under Section 2.1 of this License
261 | shall terminate.
262 |
263 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
264 | license agreements (excluding distributors and resellers) which have been
265 | validly granted by You or Your distributors under this License prior to
266 | termination shall survive termination.
267 |
268 | 6. Disclaimer of Warranty
269 |
270 | Covered Software is provided under this License on an “as is” basis, without
271 | warranty of any kind, either expressed, implied, or statutory, including,
272 | without limitation, warranties that the Covered Software is free of defects,
273 | merchantable, fit for a particular purpose or non-infringing. The entire
274 | risk as to the quality and performance of the Covered Software is with You.
275 | Should any Covered Software prove defective in any respect, You (not any
276 | Contributor) assume the cost of any necessary servicing, repair, or
277 | correction. This disclaimer of warranty constitutes an essential part of this
278 | License. No use of any Covered Software is authorized under this License
279 | except under this disclaimer.
280 |
281 | 7. Limitation of Liability
282 |
283 | Under no circumstances and under no legal theory, whether tort (including
284 | negligence), contract, or otherwise, shall any Contributor, or anyone who
285 | distributes Covered Software as permitted above, be liable to You for any
286 | direct, indirect, special, incidental, or consequential damages of any
287 | character including, without limitation, damages for lost profits, loss of
288 | goodwill, work stoppage, computer failure or malfunction, or any and all
289 | other commercial damages or losses, even if such party shall have been
290 | informed of the possibility of such damages. This limitation of liability
291 | shall not apply to liability for death or personal injury resulting from such
292 | party’s negligence to the extent applicable law prohibits such limitation.
293 | Some jurisdictions do not allow the exclusion or limitation of incidental or
294 | consequential damages, so this exclusion and limitation may not apply to You.
295 |
296 | 8. Litigation
297 |
298 | Any litigation relating to this License may be brought only in the courts of
299 | a jurisdiction where the defendant maintains its principal place of business
300 | and such litigation shall be governed by laws of that jurisdiction, without
301 | reference to its conflict-of-law provisions. Nothing in this Section shall
302 | prevent a party’s ability to bring cross-claims or counter-claims.
303 |
304 | 9. Miscellaneous
305 |
306 | This License represents the complete agreement concerning the subject matter
307 | hereof. If any provision of this License is held to be unenforceable, such
308 | provision shall be reformed only to the extent necessary to make it
309 | enforceable. Any law or regulation which provides that the language of a
310 | contract shall be construed against the drafter shall not be used to construe
311 | this License against a Contributor.
312 |
313 |
314 | 10. Versions of the License
315 |
316 | 10.1. New Versions
317 |
318 | Mozilla Foundation is the license steward. Except as provided in Section
319 | 10.3, no one other than the license steward has the right to modify or
320 | publish new versions of this License. Each version will be given a
321 | distinguishing version number.
322 |
323 | 10.2. Effect of New Versions
324 |
325 | You may distribute the Covered Software under the terms of the version of
326 | the License under which You originally received the Covered Software, or
327 | under the terms of any subsequent version published by the license
328 | steward.
329 |
330 | 10.3. Modified Versions
331 |
332 | If you create software not governed by this License, and you want to
333 | create a new license for such software, you may create and use a modified
334 | version of this License if you rename the license and remove any
335 | references to the name of the license steward (except to note that such
336 | modified license differs from this License).
337 |
338 | 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
339 | If You choose to distribute Source Code Form that is Incompatible With
340 | Secondary Licenses under the terms of this version of the License, the
341 | notice described in Exhibit B of this License must be attached.
342 |
343 | Exhibit A - Source Code Form License Notice
344 |
345 | This Source Code Form is subject to the
346 | terms of the Mozilla Public License, v.
347 | 2.0. If a copy of the MPL was not
348 | distributed with this file, You can
349 | obtain one at
350 | http://mozilla.org/MPL/2.0/.
351 |
352 | If it is not possible or desirable to put the notice in a particular file, then
353 | You may include the notice in a location (such as a LICENSE file in a relevant
354 | directory) where a recipient would be likely to look for such a notice.
355 |
356 | You may add additional accurate notices of copyright ownership.
357 |
358 | Exhibit B - “Incompatible With Secondary Licenses” Notice
359 |
360 | This Source Code Form is “Incompatible
361 | With Secondary Licenses”, as defined by
362 | the Mozilla Public License, v. 2.0.
363 |
364 |
--------------------------------------------------------------------------------