Пример #1
0
            internal FramebufferHelper(GraphicsDevice graphicsDevice)
            {
                if (graphicsDevice._extensions.Contains("GL_EXT_discard_framebuffer"))
                {
                    this.SupportsInvalidateFramebuffer = true;
                }

                if (graphicsDevice._extensions.Contains("GL_APPLE_framebuffer_multisample"))
                {
                    this.GLRenderbufferStorageMultisample = new GLRenderbufferStorageMultisampleDelegate(GLRenderbufferStorageMultisampleApple);
                    this.GLBlitFramebuffer  = new GLBlitFramebufferDelegate(GLBlitFramebufferApple);
                    this.AllReadFramebuffer = AllReadFramebufferApple;
                    this.AllDrawFramebuffer = AllDrawFramebufferApple;
                }
                if (graphicsDevice._extensions.Contains("GL_EXT_multisampled_render_to_texture"))
                {
                    this.GLRenderbufferStorageMultisample  = new GLRenderbufferStorageMultisampleDelegate(GLRenderbufferStorageMultisampleExt);
                    this.GLFramebufferTexture2DMultisample = new GLFramebufferTexture2DMultisampleDelegate(GLFramebufferTexture2DMultisampleExt);
                }
                else if (graphicsDevice._extensions.Contains("GL_IMG_multisampled_render_to_texture"))
                {
                    this.GLRenderbufferStorageMultisample  = new GLRenderbufferStorageMultisampleDelegate(GLRenderbufferStorageMultisampleImg);
                    this.GLFramebufferTexture2DMultisample = new GLFramebufferTexture2DMultisampleDelegate(GLFramebufferTexture2DMultisampleImg);
                }

                this.SupportsBlitFramebuffer = this.GLBlitFramebuffer != null;
            }
Пример #2
0
        public AndroidGLFramebufferHelper(IGLExtensionLookup lookup, IGLErrorHandler errHandler)
        {
            mErrHandler = errHandler;
            // eglGetProcAddress doesn't guarantied returning NULL if the entry point doesn't exist. The returned address *should* be the same for all invalid entry point
            var invalidFuncPtr = EGLGetProcAddress("InvalidFunctionName");

            if (lookup.HasExtension("GL_EXT_discard_framebuffer"))
            {
                var glDiscardFramebufferEXTPtr = EGLGetProcAddress("glDiscardFramebufferEXT");
                if (glDiscardFramebufferEXTPtr != invalidFuncPtr)
                {
                    this.GLInvalidateFramebuffer       = Marshal.GetDelegateForFunctionPointer <GLInvalidateFramebufferDelegate>(glDiscardFramebufferEXTPtr);
                    this.SupportsInvalidateFramebuffer = true;
                }
            }
            if (lookup.HasExtension("GL_EXT_multisampled_render_to_texture"))
            {
                var glRenderbufferStorageMultisampleEXTPtr  = EGLGetProcAddress("glRenderbufferStorageMultisampleEXT");
                var glFramebufferTexture2DMultisampleEXTPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleEXT");
                if (glRenderbufferStorageMultisampleEXTPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleEXTPtr != invalidFuncPtr)
                {
                    this.GLRenderbufferStorageMultisample  = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleEXTPtr);
                    this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer <GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleEXTPtr);
                }
            }
            else if (lookup.HasExtension("GL_IMG_multisampled_render_to_texture"))
            {
                var glRenderbufferStorageMultisampleIMGPtr  = EGLGetProcAddress("glRenderbufferStorageMultisampleIMG");
                var glFramebufferTexture2DMultisampleIMGPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleIMG");
                if (glRenderbufferStorageMultisampleIMGPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleIMGPtr != invalidFuncPtr)
                {
                    this.GLRenderbufferStorageMultisample  = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleIMGPtr);
                    this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer <GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleIMGPtr);
                }
            }
            else if (lookup.HasExtension("GL_NV_framebuffer_multisample"))
            {
                var glRenderbufferStorageMultisampleNVPtr = EGLGetProcAddress("glRenderbufferStorageMultisampleNV");
                var glBlitFramebufferNVPtr = EGLGetProcAddress("glBlitFramebufferNV");
                if (glRenderbufferStorageMultisampleNVPtr != invalidFuncPtr && glBlitFramebufferNVPtr != invalidFuncPtr)
                {
                    this.GLRenderbufferStorageMultisample = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleNVPtr);
                    this.GLBlitFramebuffer  = Marshal.GetDelegateForFunctionPointer <GLBlitFramebufferDelegate>(glBlitFramebufferNVPtr);
                    this.AllReadFramebuffer = AllReadFramebufferNV;
                    this.AllDrawFramebuffer = AllDrawFramebufferNV;
                }
            }

            this.SupportsBlitFramebuffer = this.GLBlitFramebuffer != null;
        }
            internal FramebufferHelper(GraphicsDevice graphicsDevice)
            {
#if IOS
                if (graphicsDevice._extensions.Contains("GL_EXT_discard_framebuffer"))
                {
                    this.GLInvalidateFramebuffer       = new GLInvalidateFramebufferDelegate(GLDiscardFramebufferExt);
                    this.SupportsInvalidateFramebuffer = true;
                }

                if (graphicsDevice._extensions.Contains("GL_APPLE_framebuffer_multisample"))
                {
                    this.GLRenderbufferStorageMultisample = new GLRenderbufferStorageMultisampleDelegate(GLRenderbufferStorageMultisampleApple);
                    this.GLBlitFramebuffer  = new GLBlitFramebufferDelegate(GLBlitFramebufferApple);
                    this.AllReadFramebuffer = AllReadFramebufferApple;
                    this.AllDrawFramebuffer = AllDrawFramebufferApple;
                }
#elif ANDROID
                // eglGetProcAddress doesn't guarantied returning NULL if the entry point doesn't exist. The returned address *should* be the same for all invalid entry point
                var invalidFuncPtr = EGLGetProcAddress("InvalidFunctionName");

                if (graphicsDevice._extensions.Contains("GL_EXT_discard_framebuffer"))
                {
                    var glDiscardFramebufferEXTPtr = EGLGetProcAddress("glDiscardFramebufferEXT");
                    if (glDiscardFramebufferEXTPtr != invalidFuncPtr)
                    {
                        this.GLInvalidateFramebuffer       = Marshal.GetDelegateForFunctionPointer <GLInvalidateFramebufferDelegate>(glDiscardFramebufferEXTPtr);
                        this.SupportsInvalidateFramebuffer = true;
                    }
                }
                if (graphicsDevice._extensions.Contains("GL_EXT_multisampled_render_to_texture"))
                {
                    var glRenderbufferStorageMultisampleEXTPtr  = EGLGetProcAddress("glRenderbufferStorageMultisampleEXT");
                    var glFramebufferTexture2DMultisampleEXTPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleEXT");
                    if (glRenderbufferStorageMultisampleEXTPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleEXTPtr != invalidFuncPtr)
                    {
                        this.GLRenderbufferStorageMultisample  = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleEXTPtr);
                        this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer <GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleEXTPtr);
                    }
                }
                else if (graphicsDevice._extensions.Contains("GL_IMG_multisampled_render_to_texture"))
                {
                    var glRenderbufferStorageMultisampleIMGPtr  = EGLGetProcAddress("glRenderbufferStorageMultisampleIMG");
                    var glFramebufferTexture2DMultisampleIMGPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleIMG");
                    if (glRenderbufferStorageMultisampleIMGPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleIMGPtr != invalidFuncPtr)
                    {
                        this.GLRenderbufferStorageMultisample  = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleIMGPtr);
                        this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer <GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleIMGPtr);
                    }
                }
                else if (graphicsDevice._extensions.Contains("GL_NV_framebuffer_multisample"))
                {
                    var glRenderbufferStorageMultisampleNVPtr = EGLGetProcAddress("glRenderbufferStorageMultisampleNV");
                    var glBlitFramebufferNVPtr = EGLGetProcAddress("glBlitFramebufferNV");
                    if (glRenderbufferStorageMultisampleNVPtr != invalidFuncPtr && glBlitFramebufferNVPtr != invalidFuncPtr)
                    {
                        this.GLRenderbufferStorageMultisample = Marshal.GetDelegateForFunctionPointer <GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleNVPtr);
                        this.GLBlitFramebuffer  = Marshal.GetDelegateForFunctionPointer <GLBlitFramebufferDelegate>(glBlitFramebufferNVPtr);
                        this.AllReadFramebuffer = AllReadFramebufferNV;
                        this.AllDrawFramebuffer = AllDrawFramebufferNV;
                    }
                }
#endif

                this.SupportsBlitFramebuffer = this.GLBlitFramebuffer != null;
            }
            internal FramebufferHelper(GraphicsDevice graphicsDevice)
            {
                #if IOS
                if (graphicsDevice._extensions.Contains("GL_EXT_discard_framebuffer"))
                {
                    this.GLInvalidateFramebuffer = new GLInvalidateFramebufferDelegate(GLDiscardFramebufferExt);
                    this.SupportsInvalidateFramebuffer = true;
                }

                if (graphicsDevice._extensions.Contains("GL_APPLE_framebuffer_multisample"))
                {
                    this.GLRenderbufferStorageMultisample = new GLRenderbufferStorageMultisampleDelegate(GLRenderbufferStorageMultisampleApple);
                    this.GLBlitFramebuffer = new GLBlitFramebufferDelegate(GLBlitFramebufferApple);
                    this.AllReadFramebuffer = AllReadFramebufferApple;
                    this.AllDrawFramebuffer = AllDrawFramebufferApple;
                }
                #elif ANDROID
                // eglGetProcAddress doesn't guarantied returning NULL if the entry point doesn't exist. The returned address *should* be the same for all invalid entry point
                var invalidFuncPtr = EGLGetProcAddress("InvalidFunctionName");

                if (graphicsDevice._extensions.Contains("GL_EXT_discard_framebuffer"))
                {
                    var glDiscardFramebufferEXTPtr = EGLGetProcAddress("glDiscardFramebufferEXT");
                    if (glDiscardFramebufferEXTPtr != invalidFuncPtr)
                    {
                        this.GLInvalidateFramebuffer = Marshal.GetDelegateForFunctionPointer<GLInvalidateFramebufferDelegate>(glDiscardFramebufferEXTPtr);
                        this.SupportsInvalidateFramebuffer = true;
                    }
                }
                if (graphicsDevice._extensions.Contains("GL_EXT_multisampled_render_to_texture"))
                {
                    var glRenderbufferStorageMultisampleEXTPtr = EGLGetProcAddress("glRenderbufferStorageMultisampleEXT");
                    var glFramebufferTexture2DMultisampleEXTPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleEXT");
                    if (glRenderbufferStorageMultisampleEXTPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleEXTPtr != invalidFuncPtr)
                    {
                        this.GLRenderbufferStorageMultisample = Marshal.GetDelegateForFunctionPointer<GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleEXTPtr);
                        this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer<GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleEXTPtr);
                    }
                }
                else if (graphicsDevice._extensions.Contains("GL_IMG_multisampled_render_to_texture"))
                {
                    var glRenderbufferStorageMultisampleIMGPtr = EGLGetProcAddress("glRenderbufferStorageMultisampleIMG");
                    var glFramebufferTexture2DMultisampleIMGPtr = EGLGetProcAddress("glFramebufferTexture2DMultisampleIMG");
                    if (glRenderbufferStorageMultisampleIMGPtr != invalidFuncPtr && glFramebufferTexture2DMultisampleIMGPtr != invalidFuncPtr)
                    {
                        this.GLRenderbufferStorageMultisample = Marshal.GetDelegateForFunctionPointer<GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleIMGPtr);
                        this.GLFramebufferTexture2DMultisample = Marshal.GetDelegateForFunctionPointer<GLFramebufferTexture2DMultisampleDelegate>(glFramebufferTexture2DMultisampleIMGPtr);
                    }
                }
                else if (graphicsDevice._extensions.Contains("GL_NV_framebuffer_multisample"))
                {
                    var glRenderbufferStorageMultisampleNVPtr = EGLGetProcAddress("glRenderbufferStorageMultisampleNV");
                    var glBlitFramebufferNVPtr = EGLGetProcAddress("glBlitFramebufferNV");
                    if (glRenderbufferStorageMultisampleNVPtr != invalidFuncPtr && glBlitFramebufferNVPtr != invalidFuncPtr)
                    {
                        this.GLRenderbufferStorageMultisample = Marshal.GetDelegateForFunctionPointer<GLRenderbufferStorageMultisampleDelegate>(glRenderbufferStorageMultisampleNVPtr);
                        this.GLBlitFramebuffer = Marshal.GetDelegateForFunctionPointer<GLBlitFramebufferDelegate>(glBlitFramebufferNVPtr);
                        this.AllReadFramebuffer = AllReadFramebufferNV;
                        this.AllDrawFramebuffer = AllDrawFramebufferNV;
                    }
                }
                #endif

                this.SupportsBlitFramebuffer = this.GLBlitFramebuffer != null;
            }