mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
131 lines
3.9 KiB
HTML
131 lines
3.9 KiB
HTML
|
<!--
|
||
|
Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
||
|
Use of this source code is governed by a BSD-style license that can be
|
||
|
found in the LICENSE file.
|
||
|
-->
|
||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>WebGL "Texture Complete" texture conformance test.</title>
|
||
|
<link rel="stylesheet" href="../resources/js-test-style.css"/>
|
||
|
<script src="../resources/js-test-pre.js"></script>
|
||
|
<script src="resources/webgl-test.js"> </script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas>
|
||
|
<canvas id="canvas2d" width="16" height="16" style="width: 40px; height: 40px;"></canvas>
|
||
|
<div id="description"></div>
|
||
|
<div id="console"></div>
|
||
|
<script id="vshader" type="x-shader/x-vertex">
|
||
|
attribute vec4 vPosition;
|
||
|
attribute vec2 texCoord0;
|
||
|
varying vec2 texCoord;
|
||
|
void main()
|
||
|
{
|
||
|
gl_Position = vPosition;
|
||
|
texCoord = texCoord0;
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<script id="fshader" type="x-shader/x-fragment">
|
||
|
uniform sampler2D tex;
|
||
|
varying vec2 texCoord;
|
||
|
void main()
|
||
|
{
|
||
|
gl_FragColor = texture2D(tex, texCoord);
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<script>
|
||
|
function init()
|
||
|
{
|
||
|
if (window.layoutTestController) {
|
||
|
layoutTestController.overridePreference("WebKitWebGLEnabled", "1");
|
||
|
layoutTestController.dumpAsText();
|
||
|
}
|
||
|
|
||
|
debug("Checks that a texture that is not -texture-complete- does not draw if"+
|
||
|
" filtering needs mips");
|
||
|
debug("");
|
||
|
|
||
|
var canvas2d = document.getElementById("canvas2d");
|
||
|
var ctx2d = canvas2d.getContext("2d");
|
||
|
ctx2d.fillStyle = "rgba(0,192,128,255)";
|
||
|
ctx2d.fillRect(0, 0, 16, 16);
|
||
|
|
||
|
gl = initWebGL("example", "vshader", "fshader", [ "vPosition", "texCoord0"],
|
||
|
[ 0, 0, 0, 1 ], 1);
|
||
|
|
||
|
gl.disable(gl.DEPTH_TEST);
|
||
|
gl.disable(gl.BLEND);
|
||
|
|
||
|
var vertexObject = gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
|
||
|
gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray([ -1,1,0, 1,1,0, -1,-1,0,
|
||
|
-1,-1,0, 1,1,0, 1,-1,0
|
||
|
]), gl.STATIC_DRAW);
|
||
|
gl.enableVertexAttribArray(0);
|
||
|
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
|
||
|
|
||
|
var vertexObject = gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
|
||
|
gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray([ 0,0, 1,0, 0,1,
|
||
|
0,1, 1,0, 1,1
|
||
|
]), gl.STATIC_DRAW);
|
||
|
gl.enableVertexAttribArray(1);
|
||
|
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
|
||
|
|
||
|
var tex = gl.createTexture();
|
||
|
gl.bindTexture(gl.TEXTURE_2D, tex);
|
||
|
// 16x16 texture no mips
|
||
|
gl.texImage2D(gl.TEXTURE_2D,
|
||
|
0, // level
|
||
|
canvas2d);
|
||
|
|
||
|
var loc = gl.getUniformLocation(gl.program, "tex");
|
||
|
gl.uniform1i(loc, 0);
|
||
|
|
||
|
checkBuffer(0,0,0,1,
|
||
|
"texture that is not -texture-complete- when " +
|
||
|
"TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,1");
|
||
|
|
||
|
function checkBuffer(r, g, b, a, msg) {
|
||
|
gl.clearColor(1,1,1,1);
|
||
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||
|
gl.flush();
|
||
|
var buf = gl.readPixels(0, 0, 4, 4, gl.RGBA, gl.UNSIGNED_BYTE);
|
||
|
for (var i = 0; i < 4 * 4; ++i) {
|
||
|
var offset = i * 4;
|
||
|
if (buf[offset + 0] != r ||
|
||
|
buf[offset + 1] != g ||
|
||
|
buf[offset + 2] != b ||
|
||
|
buf[offset + 3] != a) {
|
||
|
debug('expected: ' + r + ', ' + g + ', ' + b + ', ' + a +
|
||
|
' was: ' +
|
||
|
buf[offset + 0] + ', ' +
|
||
|
buf[offset + 1] + ', ' +
|
||
|
buf[offset + 2] + ', ' +
|
||
|
buf[offset + 3]);
|
||
|
testFailed(msg);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
testPassed(msg);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
init();
|
||
|
successfullyParsed = true;
|
||
|
</script>
|
||
|
</body>
|
||
|
<script src="../resources/js-test-post.js"></script>
|
||
|
|
||
|
<script>
|
||
|
</script>
|
||
|
|
||
|
</body>
|
||
|
</html>
|
||
|
|