我有一个iPad Pro 12.9in ML0F2X / A,带有iOS 12.1.1。我正在尝试创建从Uint16Array初始化的半浮点WebGL纹理:
@IBAction func resetScoreButton(_ sender: Any) {
let batsmenOneScoreValue = 0
displayBatsmenOneScoreLabel.text = String(batsmenOneScoreValue)
}
texImage2D失败,显示INVALID_OPERATION。我已经在iPad上使用Safari,Chrome和Firefox的最新移动版本(2019年1月)进行了测试。在使用远程调试的Safari中,我可以看到日志消息:
var halfExt = gl.getExtension("OES_texture_half_float");
...
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA,
halfExt.HALF_FLOAT_OES, new Uint16Array([0, 0, 0, 0]));
如果我将Uint16Array替换为null,则在iPad上调用成功,但是我的纹理当然丢失了。
以下是代码段:
WebGL: INVALID_OPERATION: texImage2D: type HALF_FLOAT_OES but ArrayBufferView is not NULL
function log(msg) {
var div = document.createElement("div");
div.appendChild(document.createTextNode(msg));
document.body.appendChild(div);
}
function glEnum(gl, v) {
for (var key in gl) {
if (gl[key] === v) {
return key;
}
}
return "0x" + v.toString(16);
}
// Get A WebGL context
var canvas = document.getElementById("c");
var gl = canvas.getContext("webgl");
if (gl) {
function getExt(name) {
var ext = gl.getExtension(name);
log("Extension " + name + " is " + (ext ? "" : "NOT ") + "supported");
return ext;
}
function checkError(test) {
var err = gl.getError();
if (err === 0)
log(test + ": successful");
else
log(test + ": flagged error " + err + " = gl." + glEnum(gl, err));
}
var floatExt = getExt("OES_texture_float");
getExt("OES_texture_float_linear");
if (floatExt) {
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, null);
checkError("Create gl.FLOAT texture with NULL buffer");
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, new Float32Array([0, 0, 0, 0]));
checkError("Create gl.FLOAT texture with Float32Array buffer");
}
var halfExt = getExt("OES_texture_half_float");
getExt("OES_texture_half_float_linear");
if (halfExt) {
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, halfExt.HALF_FLOAT_OES, null);
checkError("Create halfExt.HALF_FLOAT_OES texture with NULL buffer");
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, halfExt.HALF_FLOAT_OES, new Uint16Array([0, 0, 0, 0]));
checkError("Create halfExt.HALF_FLOAT_OES texture with UInt16Array buffer");
}
}
在Windows 6桌面版Firefox 60.4ESR和Chrome 71.0上,所有测试均成功。在iPad上,只有最后一个失败。如何在iPad上成功拨打电话?
谢谢...
答案 0 :(得分:0)