在 WebGL 上访问图像/纹理数据(纹素)
我在 WebGL 上有以下代码片段:
var texture = gl.createTexture();
texture.image = new Image();
texture.image.onload = function() {
.... // I want to read the pixels once the image has been loaded
};
texture.image.src = urlImage;
我想在加载纹理贴图后获取其内容(RGBA)。类似地,readPixels() 能够获取绘图缓冲区的内容。
是否可以?如果是这样,最好做什么?
我正在使用 Chrome Canary 构建进行开发。
预先感谢您的帮助。
注意:在 http://www.khronos.org/ 上交叉发布message_boards/viewtopic.php?f=43&t=3439
I have the following code snippet on WebGL:
var texture = gl.createTexture();
texture.image = new Image();
texture.image.onload = function() {
.... // I want to read the pixels once the image has been loaded
};
texture.image.src = urlImage;
I want to obtain the contents (RGBA) of the texture map once it has been loaded. Similar, capability of readPixels() to obtain the contents of the drawing buffer.
Is it possible? If so, what's the best to do it?
I am using Chrome Canary build for my development.
Thanks in advance for your help.
Note: Cross post on http://www.khronos.org/message_boards/viewtopic.php?f=43&t=3439
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以创建一个由纹理支持的 framebuffer,然后使用 framebuffer。 javascripture.com/WebGLRenderingContext#readPixels" rel="noreferrer">readPixels() 获取原始 RGBA 数据。
You can create a framebuffer backed by the texture and then use readPixels() to get the raw RGBA data.
我使用 HTML5 来读取带有以下代码片段的纹素:
它完成了我想做的事情。如果有更好的方法请告诉我
I use HTML5 to read the texels with the following code snippets:
It does what I want to do. Please let me know if there is a better way