OpenGL:仅使用一个帧缓冲区并切换目标纹理 [英] OpenGL: Using only one framebuffer and switching target textures

查看:130
本文介绍了OpenGL:仅使用一个帧缓冲区并切换目标纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了使用多个帧缓冲对象外,我还可以只创建一个并通过在需要时切换其目标纹理来达到相同的结果吗?

Instead of using multiple framebuffer objects, can I also create only one and achieve the same results by switching it's target texture when needed?

  • 在所有情况下这都是一个坏主意吗?如果是,为什么?

我已经在程序的API中实现了功能render.SetTargetTexture(),从逻辑上讲,如果在后台使用了更多的帧缓冲区,它将无法正常工作.然后,我必须完全公开帧缓冲区.

I've been implementing a function render.SetTargetTexture() in my program's API, and logically it wouldn't work if there were more framebuffers used behind the scenes. I'd have to fully expose framebuffers then.

推荐答案

FBO本身只是一些逻辑构造,由实现维护,并且只会消耗其参数所需的少量内存. FBO的主要目的是拥有一个保持一致状态的对象.

A FBO itself is just some logical construct, maintained by the implementation and it will consume only the little memory that its parameters require. The main purpose of a FBO is to have an object that maintains a consistent state.

无论何时更改FBO的结构,实施都必须检查有效性和完整性. OpenGL规范没有说明此操作的复杂性,但是可以安全地假设对FBO结构的更改大约是最耗时的操作(也许有很大的余量).

Whenever you do changes to a FBO's structure, the implementation must check for validity and completeness. The OpenGL specification doesn't say anything about the complexity of this operation, but it's safe to assume that changes to a FBO's structure is about the most time consuming operation (maybe by a large margin).

由于FBO本身不消耗值得注意的内存,因此只有附件占用内存,它们是独立的对象,分配多个FBO并切断它们是我的建议.

Since the FBO itself does not consume noteworthy memory, only the attachments take memory, which are independent objects, allocating multiple FBOs and swithing those is what I recommend.

这篇关于OpenGL:仅使用一个帧缓冲区并切换目标纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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