OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 |
| 28 <!DOCTYPE html> |
| 29 <html> |
| 30 <head> |
| 31 <meta charset="utf-8"> |
| 32 <title>WebGL WebGL_debug_shaders Conformance Tests</title> |
| 33 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 34 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></s
cript> |
| 35 <script src="../../resources/js-test-pre.js"></script> |
| 36 <script src="../resources/webgl-test.js"></script> |
| 37 <script src="../resources/webgl-test-utils.js"></script> |
| 38 </head> |
| 39 <body> |
| 40 <div id="description"></div> |
| 41 <canvas id="canvas" style="width: 1px; height: 1px;"> </canvas> |
| 42 <div id="console"></div> |
| 43 <!-- Shaders for testing standard derivatives --> |
| 44 |
| 45 <script> |
| 46 description("This test verifies the functionality of the WEBGL_debug_shaders ext
ension, if it is available."); |
| 47 |
| 48 debug(""); |
| 49 |
| 50 var wtu = WebGLTestUtils; |
| 51 var gl = wtu.create3DContext("canvas"); |
| 52 var ext = null; |
| 53 var shader = null; |
| 54 |
| 55 if (!gl) { |
| 56 testFailed("WebGL context does not exist"); |
| 57 } else { |
| 58 testPassed("WebGL context exists"); |
| 59 |
| 60 // Query the extension and store globally so shouldBe can access it |
| 61 ext = gl.getExtension("WEBGL_debug_shaders"); |
| 62 if (!ext) { |
| 63 testPassed("No WEBGL_debug_shaders support -- this is legal"); |
| 64 |
| 65 runSupportedTest(false); |
| 66 } else { |
| 67 testPassed("Successfully enabled WEBGL_debug_shaders extension"); |
| 68 |
| 69 runSupportedTest(true); |
| 70 runTestEnabled(); |
| 71 } |
| 72 } |
| 73 |
| 74 function runSupportedTest(extensionEnabled) { |
| 75 var supported = gl.getSupportedExtensions(); |
| 76 if (supported.indexOf("WEBGL_debug_shaders") >= 0) { |
| 77 if (extensionEnabled) { |
| 78 testPassed("WEBGL_debug_shaders listed as supported and getExtension
succeeded"); |
| 79 } else { |
| 80 testFailed("WEBGL_debug_shaders listed as supported but getExtension
failed"); |
| 81 } |
| 82 } else { |
| 83 if (extensionEnabled) { |
| 84 testFailed("WEBGL_debug_shaders not listed as supported but getExten
sion succeeded"); |
| 85 } else { |
| 86 testPassed("WEBGL_debug_shaders not listed as supported and getExten
sion failed -- this is legal"); |
| 87 } |
| 88 } |
| 89 } |
| 90 |
| 91 function runTestEnabled() { |
| 92 debug("Testing function with extension enabled"); |
| 93 |
| 94 var source = "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }"; |
| 95 |
| 96 shader = gl.createShader(gl.FRAGMENT_SHADER); |
| 97 |
| 98 // if no source has been defined or compileShader() has not been called, |
| 99 // getTranslatedShaderSource() should return an empty string. |
| 100 shouldBeNull("ext.getTranslatedShaderSource(shader)"); |
| 101 gl.shaderSource(shader, source); |
| 102 shouldBeNull("ext.getTranslatedShaderSource(shader)"); |
| 103 gl.compileShader(shader); |
| 104 shouldBeTrue("gl.getShaderParameter(shader, gl.COMPILE_STATUS)"); |
| 105 var translatedSource = ext.getTranslatedShaderSource(shader); |
| 106 glErrorShouldBe(gl, gl.NO_ERROR, "No gl error should occur"); |
| 107 if (translatedSource.length > 0) |
| 108 testPassed("Successfully called getTranslatedShaderSource()"); |
| 109 else |
| 110 testFailed("Calling getTranslatedShaderSource() failed"); |
| 111 } |
| 112 |
| 113 debug(""); |
| 114 successfullyParsed = true; |
| 115 </script> |
| 116 <script src="../../resources/js-test-post.js"></script> |
| 117 |
| 118 </body> |
| 119 </html> |
OLD | NEW |