From 7d34a54a3b2ddd37ac107003b952bf1d45d61d52 Mon Sep 17 00:00:00 2001 From: "John W. Terrell" Date: Thu, 14 Nov 2019 11:18:34 -0800 Subject: [PATCH] thogarth - added ovr_multiview support to FrameBufferObject and const to camera to enable the extension on attachments --- include/osg/Camera | 1 + include/osg/GLExtensions | 1 + src/osg/Camera.cpp | 1 + src/osg/FrameBufferObject.cpp | 7 +++++++ src/osg/GLExtensions.cpp | 2 ++ 5 files changed, 12 insertions(+) diff --git a/include/osg/Camera b/include/osg/Camera index b1cfc95dc..1050ee5e3 100644 --- a/include/osg/Camera +++ b/include/osg/Camera @@ -347,6 +347,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings }; static const unsigned int FACE_CONTROLLED_BY_GEOMETRY_SHADER; + static const unsigned int FACE_CONTROLLED_BY_MULTIVIEW_SHADER; /** Attach a buffer with specified OpenGL internal format.*/ void attach(BufferComponent buffer, GLenum internalFormat); diff --git a/include/osg/GLExtensions b/include/osg/GLExtensions index aa868e9cf..b25174198 100644 --- a/include/osg/GLExtensions +++ b/include/osg/GLExtensions @@ -680,6 +680,7 @@ class OSG_EXPORT GLExtensions : public osg::Referenced void (GL_APIENTRY * glFramebufferTexture) (GLenum, GLenum, GLint, GLint); void (GL_APIENTRY * glFramebufferTextureLayer) (GLenum, GLenum, GLuint, GLint, GLint); void (GL_APIENTRY * glFramebufferTextureFace)( GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face ); + void (GL_APIENTRY * glFramebufferTextureMultiviewOVR) (GLenum, GLenum, GLenum, GLuint, GLint, GLint); void (GL_APIENTRY * glFramebufferRenderbuffer) (GLenum, GLenum, GLenum, GLuint); void (GL_APIENTRY * glGenerateMipmap) (GLenum); diff --git a/src/osg/Camera.cpp b/src/osg/Camera.cpp index 640efc165..024a1c22d 100644 --- a/src/osg/Camera.cpp +++ b/src/osg/Camera.cpp @@ -23,6 +23,7 @@ using namespace osg; const unsigned int Camera::FACE_CONTROLLED_BY_GEOMETRY_SHADER = 0xffffffff; +const unsigned int Camera::FACE_CONTROLLED_BY_MULTIVIEW_SHADER = 0xfffffff0; Camera::Camera(): _view(0), diff --git a/src/osg/FrameBufferObject.cpp b/src/osg/FrameBufferObject.cpp index c3988e067..c5bde7cc0 100644 --- a/src/osg/FrameBufferObject.cpp +++ b/src/osg/FrameBufferObject.cpp @@ -492,6 +492,13 @@ void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachmen case Pimpl::TEXTURE2DARRAY: if (_ximpl->zoffset == Camera::FACE_CONTROLLED_BY_GEOMETRY_SHADER) ext->glFramebufferTexture(target, attachment_point, tobj->id(), _ximpl->level); + else if(_ximpl->zoffset == Camera::FACE_CONTROLLED_BY_MULTIVIEW_SHADER) + { + if (ext->glFramebufferTextureMultiviewOVR) + { + ext->glFramebufferTextureMultiviewOVR(target, attachment_point, tobj->id(), _ximpl->level, 0, 2); + } + } else ext->glFramebufferTextureLayer(target, attachment_point, tobj->id(), _ximpl->level, _ximpl->zoffset); break; diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 375ba86be..c361a421f 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -1099,6 +1099,8 @@ GLExtensions::GLExtensions(unsigned int in_contextID): setGLExtensionFuncPtr(glFramebufferTextureLayer, "glFramebufferTextureLayer", "glFramebufferTextureLayerEXT", "glFramebufferTextureLayerOES", validContext); setGLExtensionFuncPtr(glFramebufferTextureFace, "glFramebufferTextureFace", "glFramebufferTextureFaceEXT", "glFramebufferTextureFaceOES" , validContext); setGLExtensionFuncPtr(glFramebufferRenderbuffer, "glFramebufferRenderbuffer", "glFramebufferRenderbufferEXT", "glFramebufferRenderbufferOES", validContext); + setGLExtensionFuncPtr(glFramebufferTextureMultiviewOVR, "glFramebufferTextureMultiviewOVR", validContext); + //ARB_framebuffer_no_attachments //OpenGL 4.3 setGLExtensionFuncPtr(glFramebufferParameteri, "glFramebufferParameteri", "glFramebufferParameteriARB", "glFramebufferParameteriOES", validContext);