summaryrefslogtreecommitdiffstats
path: root/devtools/client/shadereditor/test/doc_shader-order.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/shadereditor/test/doc_shader-order.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/shadereditor/test/doc_shader-order.html')
-rw-r--r--devtools/client/shadereditor/test/doc_shader-order.html83
1 files changed, 83 insertions, 0 deletions
diff --git a/devtools/client/shadereditor/test/doc_shader-order.html b/devtools/client/shadereditor/test/doc_shader-order.html
new file mode 100644
index 000000000..a7cec53aa
--- /dev/null
+++ b/devtools/client/shadereditor/test/doc_shader-order.html
@@ -0,0 +1,83 @@
+<!-- Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!doctype html>
+
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <title>WebGL editor test page</title>
+
+ <script id="shader-vs" type="x-shader/x-vertex">
+ precision lowp float;
+
+ void main(void) {
+ gl_Position = vec4(0, 0, 0, 1); // I'm a vertex shader!
+ }
+ </script>
+
+ <script id="shader-fs" type="x-shader/x-fragment">
+ precision lowp float;
+ varying vec3 vFragmentColor;
+
+ void main(void) {
+ gl_FragColor = vec4(1, 0, 0, 1); // I'm a fragment shader!
+ }
+ </script>
+ </head>
+
+ <body>
+ <canvas width="512" height="512"></canvas>
+
+ <script type="text/javascript;version=1.8">
+ "use strict";
+
+ let canvas, gl;
+
+ window.onload = function() {
+ canvas = document.querySelector("canvas");
+ gl = canvas.getContext("webgl", { preserveDrawingBuffer: true });
+
+ let shaderProgram = gl.createProgram();
+ let vertexShader, fragmentShader;
+
+ // Compile and attach the shaders in a random order. The test will
+ // ensure that the correct vertex and fragment source is retrieved
+ // regardless of this crazyness.
+ if (Math.random() > 0.5) {
+ vertexShader = getShader(gl, "shader-vs");
+ fragmentShader = getShader(gl, "shader-fs");
+ } else {
+ fragmentShader = getShader(gl, "shader-fs");
+ vertexShader = getShader(gl, "shader-vs");
+ }
+ if (Math.random() > 0.5) {
+ gl.attachShader(shaderProgram, vertexShader);
+ gl.attachShader(shaderProgram, fragmentShader);
+ } else {
+ gl.attachShader(shaderProgram, fragmentShader);
+ gl.attachShader(shaderProgram, vertexShader);
+ }
+
+ gl.linkProgram(shaderProgram);
+ }
+
+ function getShader(gl, id) {
+ let script = document.getElementById(id);
+ let source = script.textContent;
+ let shader;
+
+ if (script.type == "x-shader/x-fragment") {
+ shader = gl.createShader(gl.FRAGMENT_SHADER);
+ } else if (script.type == "x-shader/x-vertex") {
+ shader = gl.createShader(gl.VERTEX_SHADER);
+ }
+
+ gl.shaderSource(shader, source);
+ gl.compileShader(shader);
+
+ return shader;
+ }
+ </script>
+ </body>
+
+</html>