GLKit并返回默认帧缓冲区

GLKit并返回默认帧缓冲区

本文介绍了iOS GLKit并返回默认帧缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行XCode为iOS的OpenGL项目创建的样板代码OpenGL示例代码。这将设置一个简单的ViewController,并使用GLKit来处理剩下的工作。

I am running the boiler plate OpenGL example code that XCode creates for an OpenGL project for iOS. This sets up a simple ViewController and uses GLKit to handle the rest of the work.

应用程序的所有更新/绘制功能都是用C ++编写的。它是跨平台的。

All the update/draw functionality of the application is in C++. It is cross platform.

有很多帧缓冲器正在创建。绘制阶段渲染到几个帧缓冲区,然后尝试将其设置回默认帧缓冲区。

There is a lot of framebuffer creation going on. The draw phase renders to a few frame buffers and then tries to set it back to the default framebuffer.

glBindFramebuffer(GL_FRAMEBUFFER, 0);

这会生成GL_INVALID_ENUM。只在iOS上。

This generates an GL_INVALID_ENUM. Only on iOS.

我完全不知道为什么。代码在除iOS之外的所有主要平台上运行良好。我想责怪GLKit。任何不使用GLKit的iOS OpenGL设置示例?

I am completely stumped as to why. The code runs fine on all major platforms except iOS. I'm wanting to blame GLKit. Any examples of iOS OpenGL setup that do not use GLKit?

UPDATE

以下代码片段让我查看GLKit正在使用的默认帧缓冲区。出于某种原因,它出现为2。果然,如果我在所有glBindFrameBuffer调用中使用2,它就可以工作。这非常令人沮丧。

The following snippet of code lets me see the default framebuffer that GLKit is using. For some reason it comes out as "2". Sure enough if I use "2" in all my glBindFrameBuffer calls it works. This is very frustrating.

[view bindDrawable ];

GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &defaultFBO);
LOGI("DEFAULT FBO: %d", defaultFBO);

究竟是什么原因会导致GLKit在0时不生成内部帧缓冲?这是OpenGL使用的所有其他实现的语义,0是默认的FBO。

What reason on earth would cause GLKit to not generate its internal framebuffer at 0? This is the semantic all other implementations of OpenGL use, 0 is the default FBO.

推荐答案

在iOS上没有默认的帧缓冲区。参见。我对GLKit了解不多,但是在iOS上要在屏幕上渲染一些东西你需要创建framebuffer,并附加到它渲染缓冲区,并通知Core Animation Layer这个渲染缓冲区将是屏幕或默认帧缓冲区来绘制至。含义 - 您将绘制到此帧缓冲区的所有内容都将显示在屏幕上。参见。

On iOS there is no default framebuffer. See Framebuffer Objects are the Only Rendering Target on iOS. I don't know much about GLKit, but on iOS to render something on screen you need to create framebuffer, and attach to it renderbuffer, and inform Core Animation Layer that this renderbuffer will be the "screen" or "default framebuffer" to draw to. Meaning - everything you'll draw to this framebuffer, will appear on screen. See Rendering to a Core Animation Layer.

这篇关于iOS GLKit并返回默认帧缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:22