RESOLVED FIXED31948
texImage2D should allow null pixel data
https://bugs.webkit.org/show_bug.cgi?id=31948
Summary texImage2D should allow null pixel data
Ben Vanik
Reported 2009-11-27 19:41:41 PST
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
Zhenyao Mo
Comment 1 2010-06-03 17:04:00 PDT
fast/canvas/tex-sub-image-2d.html covers the case where pixels set to null.
Note You need to log in before you can comment on or make changes to this bug.