BeepBoop BeepBoop - 6 months ago 38
iOS Question

GLKView, how to blitFrameBuffer, if its possible

Here is my set up, width and height are GLKView's bounds * scaling

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)
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GLbitfield(GL_COLOR_BUFFER_BIT), GLenum(GL_LINEAR))

I am calling
draw(_ rect)
, and nothing happens, so when I check for error, it gives me a

I also tried getting the ios FBO's id and binding it manually in place of calling
, this also fails.

Answer Source

glBlitFramebuffer copies from the currently bound GL_READ_FRAMEBUFFER to the currently bound GL_DRAW_FRAMEBUFFER. Binding to target GL_FRAMEBUFFER is an shortcut for binding an FBO to both GL_READ_FRAMEBUFFER and GL_DRAW_FRAMEBUFFER at the same time, so your blit is from framebuffer to framebuffer, which is not allowed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download