regl icon indicating copy to clipboard operation
regl copied to clipboard

website API docs have a bogus regl.texture() example

Open tomjakubowski opened this issue 7 years ago • 2 comments

http://regl.party/api#textures

// From an image element
var image = new Image()
image.src = 'http://mydomain.com/myimage.png'
var imageTexture = regl.texture(image)

Trying this (with a real src) resulted in this exception being thrown (regl 1.3.0):

Error: (regl) invalid texture shape

Meanwhile, API.md as of now lists a similar example which does work:

// From an image element
var image = new Image()
image.src = 'http://mydomain.com/myimage.png'
image.onload = function () {
  var imageTexture = regl.texture(image)
}

Now, it would be pretty cool if regl.texture() could somehow gracefully handle a "load in progress" Image object, but it doesn't (probably for a good reason I can't think of), so I think the API doc on the website should be updated to reflect the existing behavior.

tomjakubowski avatar Sep 24 '17 05:09 tomjakubowski

This doesn't address the completeness of the docs, but checkout resl if you haven't already. https://github.com/regl-project/resl

Maybe a note about a loading strategy being required would help with confusion in the docs.

neiltron avatar Sep 29 '17 19:09 neiltron

This might be a bug, according to the docs:

If an image element is specified and not yet loaded, then regl will upload a temporary image and hook a callback on the image

milcktoast avatar Nov 14 '17 23:11 milcktoast