81 views
in GUI Development by
Hi,

From what I got from the forum and the document there is no common way to get the value of specific pixel.

I want to know is it possible to access the framebuffer on WebGL and how?

 

Kind Regard,

John

1 Answer

+1 vote
by
 
Best answer

Hello John,

the question is more related to Web development than to Embedded Wizard itself. From technical point of view, the WebGL context provides a method to read pixel data:

WebGLRenderingContext: readPixels() method

Assuming you plan to implement the read operation in Embedded Wizard project, following could be an example. Note the usage of native statement to envelope the JavaScript code. You should also note that the expected performance when reading data from the WebGL frame buffer can be disappointing. From our experience this interface is very slow.

$if $platform == *.WebGL.*
native
{
  var gl     = _app._Context;
  var x      = 0;
  var y      = 0;
  var w      = 1;
  var h      = 1;
  var pixels = new Uint8Array( w * h * 4 );

  gl.readPixels( x, y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels );
  console.log(pixels);
}
$endif

I hope it helps you further.

Best regards

Paul Banach

by
Hi Paul,
 

Thank you very much! It works.
 

Kind Regrads,
John

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...