content/canvas/test/webgl-mochitest/test_noprog_draw.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 <!DOCTYPE HTML>
     2 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
     4 <title>WebGL test: Drawing with a null program</title>
     6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
     7 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
     8 <script src="driver-info.js"></script>
     9 <script src="webgl-util.js"></script>
    12 <script id="vs" type="x-shader/x-vertex">
    14 void main(void) {
    15   gl_PointSize = 16.0;
    16   gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
    17 }
    19 </script>
    20 <script id="fs" type="x-shader/x-fragment">
    22 precision mediump float;
    24 void main(void) {
    25   gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
    26 }
    28 </script>
    29 <body>
    30 <canvas id="c" width="64" height="64"></canvas>
    31 <script>
    33 // Give ourselves a scope to return early from:
    34 (function() {
    35   var gl = WebGLUtil.getWebGL('c');
    36   if (!gl) {
    37     todo(false, 'WebGL is unavailable.');
    38     return;
    39   }
    41   function errorFunc(str) {
    42     ok(false, 'Error: ' + str);
    43   }
    44   WebGLUtil.setErrorFunc(errorFunc);
    45   WebGLUtil.setWarningFunc(errorFunc);
    47   gl.disable(gl.DEPTH_TEST);
    49   var prog   = WebGLUtil.createProgramByIds(gl, 'vs', 'fs');
    50   if (!prog) {
    51     ok(false, 'Program linking should succeed.');
    52     return;
    53   }
    55   function checkGLError(func, info, refValue) {
    56     if (!refValue)
    57       refValue = 0;
    59     var error = gl.getError();
    60     func(error == refValue,
    61          '[' + info + '] gl.getError should be 0x' + refValue.toString(16) +
    62                                         ', was 0x' + error.toString(16) + '.');
    63   }
    65   // Start drawing
    66   checkGLError(ok, 'after setup');
    68   gl.useProgram(prog);
    69   gl.drawArrays(gl.POINTS, 0, 1);
    70   checkGLError(ok, 'after non-null-program DrawArrays');
    72   gl.useProgram(null);
    73   gl.drawArrays(gl.POINTS, 0, 1);
    74   checkGLError(ok, 'after null-program DrawArrays', gl.INVALID_OPERATION);
    76   ok(true, 'Test complete.');
    77 })();
    79 </script>

mercurial