gpt4 book ai didi

ios - GLKView,如何 blitFrameBuffer,如果可能的话

转载 作者:行者123 更新时间:2023-11-29 00:13:14 25 4
gpt4 key购买 nike

这是我的设置,宽度和高度是GLKView的边界*缩放

private func initFrameBuffer() -> GLuint {
var framebuffer_id: GLuint = 0
glGenFramebuffers(1, &framebuffer_id)
glBindFramebuffer(GLenum(GL_FRAMEBUFFER), framebuffer_id)
return framebuffer_id
}

private func initRenderBuffer(_ width: GLsizei, _ height: GLsizei) -> GLuint {
var renderBuffer_id: GLuint = 0
glGenRenderbuffers(1, &renderBuffer_id)
glBindRenderbuffer(GLenum(GL_RENDERBUFFER), renderBuffer_id)
glRenderbufferStorage(GLenum(GL_RENDERBUFFER), GLenum(GL_RGBA8), width, height)
glFramebufferRenderbuffer(GLenum(GL_FRAMEBUFFER), GLenum(GL_COLOR_ATTACHMENT0), GLenum(GL_RENDERBUFFER), renderBuffer_id)
return renderBuffer_id
}

func blitz() {
glBindFramebuffer(GLenum(GL_FRAMEBUFFER), frameBuffer)
bindDrawable()
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GLbitfield(GL_COLOR_BUFFER_BIT), GLenum(GL_LINEAR))
}

我在draw(_ rect)中调用blitz(),但没有任何反应,所以当我检查错误时,它给了我一个GL_INVALID_OPERATION.

我还尝试获取 ios FBO 的 id 并手动绑定(bind)它来代替调用 bindDrawble(),这也失败了。

最佳答案

glBlitFramebuffer 从当前绑定(bind)的 GL_READ_FRAMEBUFFER 复制到当前绑定(bind)的 GL_DRAW_FRAMEBUFFER。绑定(bind)到目标 GL_FRAMEBUFFER 是将 FBO 同时绑定(bind)到 both GL_READ_FRAMEBUFFERGL_DRAW_FRAMEBUFFER 的快捷方式,所以你的blit是从framebufferframebuffer,这是不允许的。

关于ios - GLKView,如何 blitFrameBuffer,如果可能的话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45833862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com