418 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 - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...