PDA

View Full Version : readPixels returning undefined



pjsmith88
04-19-2011, 06:05 AM
Both:

var pixel = gl.readPixels(1,1,1,1,gl.RGBA,gl.UNSIGNED_BYTE);

and:

var pixel;
gl.readPixels(1,1,1,1,gl.RGBA,gl.UNSIGNED_BYTE, pixel);

evaluate pixel to "undefined"

I am trying to implement color-based picking. This occurs on both Webkit Nightly and Chrome.

Anyone got any information on this? Or if I need to use it differently?

Jens1
04-19-2011, 09:39 AM
pixel needs to be an allocated array-object:

var pixel = new Uint8Array(4);
that should work