glReadPixels()
関数を使用して、シーンのスクリーンショットを作成したいと考えています。マルチサンプリングを使用しない場合は、うまく機能します。しかし、もしそうなら、私はGL_INVALID_OPERATION
入りglResolveMultisampleFramebufferAPPLE()
ます。この問題を解決する方法はありますか?
私の保存機能:
var wid = GLint()
var hei = GLint()
glGetRenderbufferParameteriv(GLenum(GL_RENDERBUFFER), GLenum(GL_RENDERBUFFER_WIDTH), &wid)
glGetRenderbufferParameteriv(GLenum(GL_RENDERBUFFER), GLenum(GL_RENDERBUFFER_HEIGHT), &hei)
let byteLength = Int(hei * wid) * 4
let bytes = UnsafeMutablePointer<GLubyte>.alloc(byteLength)
// init non-multisampled frame buffer
var framebuffer: GLuint = 0
var colorRenderbuffer: GLuint = 0
glGenFramebuffersOES(1, &framebuffer)
glBindFramebufferOES(GLenum(GL_FRAMEBUFFER_OES), framebuffer)
glGenRenderbuffersOES(1, &colorRenderbuffer)
glBindRenderbufferOES(GLenum(GL_RENDERBUFFER_OES), colorRenderbuffer)
glRenderbufferStorageOES(GLenum(GL_RENDERBUFFER_OES), GLenum(GL_RGBA8_OES), wid, hei)
glFramebufferRenderbufferOES(GLenum(GL_FRAMEBUFFER_OES), GLenum(GL_COLOR_ATTACHMENT0_OES), GLenum(GL_RENDERBUFFER_OES), colorRenderbuffer)
glBindFramebufferOES(GLenum(GL_DRAW_FRAMEBUFFER_APPLE), framebuffer)
var default: GLint = 0
glGetIntegerv(GLenum(GL_FRAMEBUFFER_BINDING_OES), &default)
glBindFramebufferOES(GLenum(GL_READ_FRAMEBUFFER_APPLE), GLuint(default));
myglGetError() // OK
glResolveMultisampleFramebufferAPPLE()
myglGetError() // GL_INVALID_OPERATION
glBindFramebuffer(GLenum(GL_FRAMEBUFFER), framebuffer)
glReadPixels(0, 0, GLsizei(wid), GLsizei(hei), GLenum(GL_RGBA), GLenum(GL_UNSIGNED_BYTE), bytes)
glBindFramebuffer(GLenum(GL_FRAMEBUFFER), GLuint(default));
glDeleteFramebuffers(1, &framebuffer)
で初期化されたデフォルトのフレームバッファを使用しGLKit
ますglkView.drawableMultisample = GLKViewDrawableMultisample.Multisample4X