From ff904fc51ef2476600f18c088e8a0b0616752057 Mon Sep 17 00:00:00 2001 From: Joe Mattiello Date: Fri, 30 Mar 2018 08:23:55 -0400 Subject: [PATCH] Add the iOS framebuffer binder from @braindx --- .../OpenGLContext/opengl_CachedFunctions.h | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Graphics/OpenGLContext/opengl_CachedFunctions.h b/src/Graphics/OpenGLContext/opengl_CachedFunctions.h index 605f13a7..5b929d11 100644 --- a/src/Graphics/OpenGLContext/opengl_CachedFunctions.h +++ b/src/Graphics/OpenGLContext/opengl_CachedFunctions.h @@ -125,7 +125,32 @@ namespace opengl { Bind m_bind; }; - typedef CachedBind CachedBindFramebuffer; + class CachedBindFramebuffer : public Cached2 + { + public: + CachedBindFramebuffer(decltype(GET_GL_FUNCTION(glBindFramebuffer)) _bind) : m_bind(_bind) {} + + void bind(graphics::Parameter _target, graphics::ObjectHandle _name) { +#ifdef OS_IOS + if (m_defaultFramebuffer == graphics::ObjectHandle::null) { + GLint defaultFramebuffer; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFramebuffer); + m_defaultFramebuffer = graphics::ObjectHandle(defaultFramebuffer); + } + if (_name == graphics::ObjectHandle::null) { + _name = m_defaultFramebuffer; + } +#endif + if (update(_target, _name)) + m_bind(GLenum(_target), GLuint(_name)); + } + + private: + decltype(GET_GL_FUNCTION(glBindFramebuffer)) m_bind; +#ifdef OS_IOS + graphics::ObjectHandle m_defaultFramebuffer; +#endif + }; typedef CachedBind CachedBindRenderbuffer;