iPhone上的屏幕外FBO(Offscreen FBO on iPhone)

编程入门 行业动态 更新时间:2024-10-26 16:34:17
iPhone上的屏幕外FBO(Offscreen FBO on iPhone)

我正在开发iPhone 4,iOS 6.0.1。 我正在创建一个与主要FBO不同大小的屏幕外FBO。 我使用以下代码来做到这一点,其中cxFBO和cyFBO的大小是主FBO的两倍:

glGenRenderbuffers(1, &_colorRenderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, cxFBO, cyFBO); glGenFramebuffers(1, &_frameBufferID); glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferID); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderBuffer); glGenTextures(1, &_fboTextureID); glBindTexture(GL_TEXTURE_2D, _fboTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cxFBO, cyFBO, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _fboTextureID, 0);

然后我在调用glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferID)后绘制它。 我不想使用着色器发布整个绘图例程。 我想我没有做任何特别的事情,但如果你认为这很重要,我会发一个简短的例子。 问题是只有四分之一的纹理填充了顶点,其他glClearColor()三是由glClearColor()设置的颜色。

我究竟做错了什么? 我对格式有点困惑,即GL_RGBA 。 我应该使用GL_RGBA_OES吗? 到处?

I'm working on an iPhone 4, iOS 6.0.1. I'm creating an offscreen FBO with a different size than the main FBO. I use the following code to do that, where cxFBO and cyFBO are twice the size of the main FBO:

glGenRenderbuffers(1, &_colorRenderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, cxFBO, cyFBO); glGenFramebuffers(1, &_frameBufferID); glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferID); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderBuffer); glGenTextures(1, &_fboTextureID); glBindTexture(GL_TEXTURE_2D, _fboTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cxFBO, cyFBO, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _fboTextureID, 0);

I'm then drawing to it after calling glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferID). I don't want to post the entire drawing routine with shaders. I think I'm not doing anything special, but if you think it matters, I will post a short example. The problem is that only one quarter of the texture is filled with vertices, the other 3 quarters are the color set by glClearColor().

What am I doing wrong? I'm especially a bit confused about the formats, i.e. GL_RGBA. Should I rather use GL_RGBA_OES? Everywhere?

最满意答案

问题是我忘了调用glViewPort()。 如果你想的话,有点明显;-)

The problem was that I forgot to call glViewPort(). Kind of obvious if you think about it ;-)

更多推荐

本文发布于:2023-07-22 12:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219908.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:屏幕   iPhone   Offscreen   FBO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!