OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright (c) 2011 Mozilla Foundation. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. |
| 5 --> |
| 6 <!DOCTYPE html> |
| 7 <html> |
| 8 <head> |
| 9 <meta charset="utf-8"> |
| 10 <title>WebGL shader precision format test.</title> |
| 11 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 12 <script src="../../resources/js-test-pre.js"></script> |
| 13 <script src="../resources/webgl-test.js"> </script> |
| 14 <script src="../resources/webgl-test-utils.js"> </script> |
| 15 </head> |
| 16 <body> |
| 17 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></ca
nvas> |
| 18 <div id="description"></div> |
| 19 <div id="console"></div> |
| 20 <script> |
| 21 var wtu = WebGLTestUtils; |
| 22 description(document.title); |
| 23 debug("Tests that WebGLShaderPrecisionFormat class and getShaderPrecisionFormat
work."); |
| 24 debug(""); |
| 25 var gl = create3DContext(document.getElementById("canvas")); |
| 26 |
| 27 function verifyShaderPrecisionFormat(shadertype, precisiontype) { |
| 28 shouldBeTrue('gl.getShaderPrecisionFormat(' + shadertype + ', ' + |
| 29 precisiontype + ') instanceof WebGLShaderPrecisionFormat'); |
| 30 } |
| 31 |
| 32 if (gl.getShaderPrecisionFormat == null || typeof gl.getShaderPrecisionFormat !=
'function') { |
| 33 debug("getShaderPrecisionFormat() function not found."); |
| 34 } else { |
| 35 debug(""); |
| 36 debug("Test that getShaderPrecisionFormat returns a WebGLShaderPrecisionForm
at object."); |
| 37 debug(""); |
| 38 |
| 39 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_FLOAT'); |
| 40 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_FLOAT'); |
| 41 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_FLOAT'); |
| 42 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_INT'); |
| 43 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_INT'); |
| 44 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_INT'); |
| 45 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_FLOAT'); |
| 46 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_FLOAT'); |
| 47 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_FLOAT'); |
| 48 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_INT'); |
| 49 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_INT'); |
| 50 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_INT'); |
| 51 |
| 52 debug(""); |
| 53 debug("Test that getShaderPrecisionFormat throws an error with invalid param
eters."); |
| 54 debug(""); |
| 55 |
| 56 shouldGenerateGLError(gl, gl.INVALID_ENUM, 'gl.getShaderPrecisionFormat(gl.H
IGH_INT, gl.VERTEX_SHADER)'); |
| 57 |
| 58 debug(""); |
| 59 debug("Test that WebGLShaderPrecisionFormat values are sensible."); |
| 60 debug(""); |
| 61 |
| 62 var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl
.LOW_FLOAT); |
| 63 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 0 && shaderPrecisionFormat.r
angeMin <= 128'); |
| 64 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 0 && shaderPrecisionFormat.r
angeMax <= 128'); |
| 65 shouldBeTrue('shaderPrecisionFormat.precision >= 0 && shaderPrecisionFormat.
precision <= 128'); |
| 66 |
| 67 debug(""); |
| 68 debug("Test that getShaderPrecisionFormat returns the same thing every call.
"); |
| 69 debug(""); |
| 70 |
| 71 var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, g
l.LOW_FLOAT); |
| 72 shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.range
Min'); |
| 73 shouldBeTrue('shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.range
Max'); |
| 74 shouldBeTrue('shaderPrecisionFormat.precision == shaderPrecisionFormat2.prec
ision'); |
| 75 } |
| 76 |
| 77 finishTest(); |
| 78 </script> |
| 79 |
| 80 </body> |
| 81 </html> |
| 82 |
| 83 |
OLD | NEW |