简体   繁体   English

从GLKView / GLKit获取默认帧缓冲区ID

[英]Getting default frame buffer id from GLKView/GLKit

I use GLkit/GLKView in my IOS OpenGL ES 2.0 project to manage default FBO/life cycle of my app. 我在我的IOS OpenGL ES 2.0项目中使用GLkit / GLKView来管理我的应用程序的默认FBO /生命周期。

In desktop OpenGL in order to bind default FBO (the front buffer) I can just call glBindFrameBuffer(GL_FRAMEBUFFER,0) but this is not the case in IOS app since you have to create the default FBO yourself and it will have a unique ID; 在桌面OpenGL中为了绑定默认FBO(前缓冲区),我可以调用glBindFrameBuffer(GL_FRAMEBUFFER,0),但在IOS应用程序中不是这种情况,因为您必须自己创建默认FBO并且它将具有唯一ID;

The problem is GLKit/GLKView coding style force me to use GLKView's "bindDrawable" function to activate default FBO which make the design of my cross platform rendering system a little ugly (have to store GLKView pointer as void* in my c++ engine class and bridge cast it every time I want to perform default FBO binding) 问题是GLKit / GLKView编码风格迫使我使用GLKView的“bindDrawable”函数激活默认FBO,这使得我的跨平台渲染系统的设计有点难看(必须在我的c ++引擎类和桥中将GLKView指针存储为void *每次我想执行默认的FBO绑定时都抛出它)

Are there any way to get the default FBO ID that GLKit/GLKView create so that I can store and use it to bind default frame buffer any where in my code ? 有没有办法获得GLKit / GLKView创建的默认FBO ID,以便我可以存储并使用它来绑定我的代码中的任何位置的默认帧缓冲区?

At worst I can revert back to create the default FBO myself and dissing GLKit/GLKView but it such a nice framework that I would like to continue using it. 在最坏的情况下,我可以恢复自己创建默认的FBO并消除GLKit / GLKView,但它是一个很好的框架,我想继续使用它。

Sorry for my bad english and thank in advance for any reply. 抱歉我的英文不好,并提前感谢您的回复。

Perhaps you can get the "current" framebuffer ID just after your bindDrawable call, by calling something like: 也许您可以在bindDrawable调用之后获取“当前”帧缓冲区ID,方法是:

GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &defaultFBO);

The answer that is given is definitely the proper solution, however it does not address the error in your understanding of the conceptual difference between standard openGL and openGL for embedded systems. 给出的答案肯定是正确的解决方案,但是它没有解决您对嵌入式系统的标准openGL和openGL之间的概念差异的理解中的错误。 //----------------------------------------------- I feel it's necessary to point out here that the call to glBindFramebuffer(GL_FRAMEBUFFER, 0) does not return rendering to the main framebuffer although it would appear to be so for machines that run Windows, Unix(Mac) or Linux. // - - - - - - - - - - - - - - - - - - - - - - - - 一世我觉得有必要在这里指出,对glBindFramebuffer(GL_FRAMEBUFFER,0)的调用不会将渲染返回到主帧缓冲区,尽管对于运行Windows,Unix(Mac)或Linux的机器来说似乎是这样。 Desktops and laptops have no concept of a main default system framebuffer. 台式机和笔记本电脑没有主要默认系统帧缓冲的概念。 This idea started with handheld devices. 这个想法始于手持设备。 When you make an openGL bind call with zero as the parameter then what you are doing is setting this function to NULL. 当您使用零作为参数进行openGL绑定调用时,您正在做的是将此函数设置为NULL。 It's how you disable this function. 这是你禁用这个功能的方法。 It's the same with glBindTexture(GL_TEXTURE_2D, 0); 与glBindTexture(GL_TEXTURE_2D,0)相同; It is possible that on some handheld devices that the driver automatically activates the main system framebuffer when you set the framebuffer to NULL without activating another. 在某些手持设备上,当您将帧缓冲区设置为NULL而不激活另一个帧缓冲区时,驱动程序可能会自动激活主系统帧缓冲区。 This would be a choice made by the manufacturer and is not something that you should count on, this is not part of the openGL ES spec. 这将是制造商做出的选择,而不是您应该依赖的东西,这不是openGL ES规范的一部分。 For desktops and laptops, this is absolutely necessary since disabling the framebuffer is required to return to normal openGL rendering. 对于台式机和笔记本电脑,这是绝对必要的,因为需要禁用帧缓冲区才能恢复正常的openGL渲染。 But remember! 但要记住! this is not a return to any main framebuffer, you are shutting down the activated frame buffer. 这不是返回任何主帧缓冲区,而是关闭激活的帧缓冲区。

The proper way to bind default framebuffer in GLKit is to call bindDrawable method on GLKview . 到默认的帧缓冲结合在GLKit的正确方法是调用bindDrawable方法上GLKview

[self bindDrawable] or [myglkview bindDrawable] depending on the context. [self bindDrawable][myglkview bindDrawable]取决于上下文。

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

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