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); } }
fast/canvas/tex-sub-image-2d.html covers the case where pixels set to null.