简体   繁体   English

GLSurfaceView作为纹理

[英]GLSurfaceView as Texture

I've been trying to render a GLSurfaceView on the surface of a OpenGL Cube as a Texture. 我一直在尝试在OpenGL多维数据集的表面上将GLSurfaceView渲染为纹理。 Is it possible? 可能吗? How to go about it? 怎么做呢?

The usual approach is to render to a framebuffer object (FBO) backed by a texture, and then render from that. 通常的方法是渲染到具有纹理支持的帧缓冲对象(FBO),然后从该对象进行渲染。

You can google for examples of FBO usage in GLES2 (the setup is a bit complicated). 您可以在GLES2中Google搜索FBO用法的示例(设置有点复杂)。 One example showing it in practice is the "record GL app" activity in Grafika , which is using FBOs (and a couple of other approaches) to record GLES rendering. 在实践中展示它的一个示例是Grafika中的“ record GL app”活动,该活动正在使用FBO(和其他几种方法)来记录GLES渲染。 The last "else" clause in doFrame() renders to an FBO, then renders that texture twice, once on-screen, once to a video recorder. doFrame()的最后一个“ else”子句渲染为FBO,然后将该纹理渲染两次,一次在屏幕上,一次渲染到录像机。

You may want to switch from GLSurfaceView to plain SurfaceView to get more control over the rendering process. 您可能希望从GLSurfaceView切换到纯SurfaceView,以更好地控制渲染过程。 Most of the code in Grafika uses SurfaceView or TextureView. Grafika中的大多数代码都使用SurfaceView或TextureView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM