Bug 31948
| Summary: | texImage2D should allow null pixel data | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ben Vanik <ben.vanik> |
| Component: | WebGL | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | zmo |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
Ben Vanik
As per the spec of glTexImage2D, the last argument (data) is allowed to be NULL to indicate that an empty texture should be created.
It looks like right now GraphicsContext3D::texImage2D does no checking on pixels, which may be NULL so an error is thrown if you try.
Spec: http://www.khronos.org/opengles/sdk/docs/man/glTexImage2D.xml
Workaround:
function emptyTexImage2D(gl, internalFormat, width, height, format, type) {
try {
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, null);
} catch (e) {
console.warn("browser texImage2D does not accept null - sending up a real blank texture");
var pixels = new WebGLUnsignedByteArray(width * height * ( internalFormat == gl.RGBA ? 4 : 3 ) );
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, pixels);
}
}
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Zhenyao Mo
fast/canvas/tex-sub-image-2d.html covers the case where pixels set to null.