如何在webgl中获取纹理?没有Canvas.toDataUrl() [英] how to get texture in webgl?without Canvas.toDataUrl()

查看:354
本文介绍了如何在webgl中获取纹理?没有Canvas.toDataUrl()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从webgl获取纹理,就像在画布上下文为2d时可以使用getImageData()一样.
如何获取纹理形式的webgl上下文?

I want to get texture from webgl just like i can use getImageData()when the canvas context is 2d.
how can i get texture form webgl context?

推荐答案

我知道三种可能性.重要的! 对于所有这些方法,必须使用webgl设置prepareDrawingBuffer = true .

I know three possibilities. Important! For all these methods you must set preserveDrawingBuffer = true with webgl.

至数据网址

第一个是toDataURL的高级方法,其来源是javascript

canvas.toDataURL(type, encoderOptions);

例如,如果您想允许客户做一些应用程序的截屏",则可以使用它

You can use this for example if you want to allow your client to do some app "screenshot"

以下两种方法是低级的,其起源是webgl.如果要例如修改纹理或计算新纹理(阴影),则可以使用它们.

Following two methods are low level and its origin is webgl. You can use them if you want to for example modify texture or calculate new texture (shadows).

5.14.12回读像素

当前帧缓冲区中的像素可以读回到ArrayBufferView对象中.

Pixels in the current framebuffer can be read back into an ArrayBufferView object.

void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels)

5.14.8纹理对象

纹理对象为纹理操作提供存储和状态...

Texture objects provide storage and state for texturing operations ...

void texImage2D(GLenum target, GLint level, GLenum internalformat, GLint border, GLenum format, GLenum type, HTMLCanvasElement element)

这篇关于如何在webgl中获取纹理?没有Canvas.toDataUrl()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆