func:  WebGLTexture::EnsureInitializedImageData(TexImageTarget GLint level) const ImageInfo & imageInfo = ImageInfoAt ( imageTarget , level ) ; if ( ! imageInfo . HasUninitializedImageData ( ) )  if ( imageTarget == LOCAL_GL_TEXTURE_2D )  bool cleared = ClearWithTempFB ( mContext , mGLName , imageTarget , level , imageInfo . mEffectiveInternalFormat , imageInfo . mHeight , imageInfo . mWidth ) ; static ClearWithTempFB(WebGLContext* webgl, GLuint TexImageTarget texImageTarget, GLint TexInternalFormat GLsizei width, GLsizei height) switch ( baseInternalFormat . get ( ) )  mask = LOCAL_GL_COLOR_BUFFER_BIT; mask = LOCAL_GL_DEPTH_BUFFER_BIT; mask = LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT; return false ; if ( ClearByMask ( webgl , mask ) )  static ClearByMask(WebGLContext* webgl, GLbitfield mask) gl :: GLContext * gl = webgl -> GL ( ) ; GLenum status = gl -> fCheckFramebufferStatus ( LOCAL_GL_FRAMEBUFFER ) ; if ( status != LOCAL_GL_FRAMEBUFFER_COMPLETE )  return false ; return true ; return true ; if ( mask & LOCAL_GL_COLOR_BUFFER_BIT )  return false ; mask |= LOCAL_GL_COLOR_BUFFER_BIT; return ClearByMask ( webgl , mask ) ; static ClearByMask(WebGLContext* webgl, GLbitfield mask) gl :: GLContext * gl = webgl -> GL ( ) ; GLenum status = gl -> fCheckFramebufferStatus ( LOCAL_GL_FRAMEBUFFER ) ; if ( status != LOCAL_GL_FRAMEBUFFER_COMPLETE )  return false ; return true ; if ( cleared )  size_t bitspertexel = GetBitsPerTexel ( imageInfo . mEffectiveInternalFormat ) ; size_t bytespertexel = bitspertexel / 8 ; CheckedUint32 checked_byteLength = WebGLContext :: GetImageSize ( imageInfo . mHeight , imageInfo . mWidth , imageInfo . mDepth , bytespertexel , mContext -> mPixelStoreUnpackAlignment ) ; size_t byteCount = checked_byteLength . value ( ) ; UniquePtr < uint8_t > zeros ( ( uint8_t * ) calloc ( 1 , byteCount ) ) ; if ( zeros == nullptr )  gl -> fTexSubImage3D ( imageTarget . get ( ) , level , 0 , 0 , 0 , imageInfo . mWidth , imageInfo . mHeight , imageInfo . mDepth , driverFormat , driverType , zeros . get ( ) ); gl -> fTexSubImage2D ( imageTarget . get ( ) , level , 0 , 0 , imageInfo . mWidth , imageInfo . mHeight , driverFormat , driverType , zeros . get ( ) ); gl -> fTexImage2D ( imageTarget . get ( ) , level , driverInternalFormat , imageInfo . mWidth , imageInfo . mHeight , 0 , driverFormat , driverType , zeros . get ( ) ); 