コード例 #1
0
ファイル: GLESFBORTTManager.cs プロジェクト: bostich83/axiom
        /// <summary>
        ///   Try a certain packed depth/stencil format, and return the status.
        /// </summary>
        /// <param name="packedFormat"> </param>
        /// <returns> true if this combo is supported, false if not </returns>
        private bool TryPacketFormat(All packedFormat)
        {
            int packedRB = 0;

            /// Generate renderbuffer
            OpenGLOES.GenRenderbuffers(1, ref packedRB);

            //bind it to FBO
            OpenGLOES.BindRenderbuffer(All.RenderbufferOes, packedRB);

            /// Allocate storage for buffer
            OpenGLOES.RenderbufferStorage(All.RenderbufferOes, packedFormat, ProbeSize, ProbeSize);

            /// Attach depth
            OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.DepthAttachmentOes, All.RenderbufferOes, packedRB);

            /// Attach stencil
            OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.StencilAttachmentOes, All.RenderbufferOes, packedRB);

            All status = OpenGLOES.CheckFramebufferStatus(All.FramebufferOes);

            /// Detach and destroy
            OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.DepthAttachmentOes, All.RenderbufferOes, 0);
            OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.StencilAttachmentOes, All.RenderbufferOes, 0);
            OpenGLOES.DeleteRenderbuffers(1, ref packedRB);

            return(status == All.FramebufferCompleteOes);
        }
コード例 #2
0
ファイル: GLESFBORTTManager.cs プロジェクト: bostich83/axiom
        /// <summary>
        ///   Try a certain FBO format, and return the status. Also sets mDepthRB and mStencilRB.
        /// </summary>
        /// <param name="depthFormat"> </param>
        /// <param name="stencilFormat"> </param>
        /// <returns> true if this combo is supported, false if not </returns>
        private bool TryFormat(All depthFormat, All stencilFormat)
        {
            int status = 0, depthRB = 0, stencilRB = 0;

            if (depthFormat != 0)
            {
                /// Generate depth renderbuffer
                OpenGLOES.GenRenderbuffers(1, ref depthRB);

                /// Bind it to FBO;
                OpenGLOES.RenderbufferStorage(All.RenderbufferOes, depthFormat, ProbeSize, ProbeSize);

                /// Attach depth
                OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.DepthAttachmentOes, All.RenderbufferOes, depthRB);
            }
            // Stencil buffers aren't available on iPhone
            if (stencilFormat != 0)
            {
                /// Generate stencil renderbuffer
                OpenGLOES.GenRenderbuffers(1, ref stencilRB);

                //bind it to FBO
                OpenGLOES.BindRenderbuffer(All.RenderbufferOes, stencilRB);

                /// Allocate storage for stencil buffer
                OpenGLOES.RenderbufferStorage(All.RenderbufferOes, stencilFormat, ProbeSize, ProbeSize);

                /// Attach stencil
                OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.StencilAttachmentOes, All.RenderbufferOes, stencilRB);
            }

            status = (int)OpenGLOES.CheckFramebufferStatus(All.FramebufferOes);

            OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.DepthAttachmentOes, All.RenderbufferOes, depthRB);
            OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.StencilAttachmentOes, All.RenderbufferOes, stencilRB);

            if (depthRB != 0)
            {
                OpenGLOES.DeleteRenderbuffers(1, ref depthRB);
            }

            if (stencilRB != 0)
            {
                OpenGLOES.DeleteRenderbuffers(1, ref stencilRB);
            }

            //Clear OpenGL Errors create because of the evaluation
            while (OpenGL.GetError() != All.NoError)
            {
                ;
            }

            return(status == (int)All.FramebufferCompleteOes);
        }
コード例 #3
0
ファイル: GLESRenderBuffer.cs プロジェクト: bostich83/axiom
        /// <summary>
        /// </summary>
        /// <param name="format"> </param>
        /// <param name="width"> </param>
        /// <param name="height"> </param>
        /// <param name="numSamples"> </param>
        public GLESRenderBuffer(All format, int width, int height, int numSamples)
            : base(width, height, 1, GLESPixelUtil.GetClosestAxiomFormat(format), BufferUsage.WriteOnly)
        {
            _glInternalFormat = format;
            /// Generate renderbuffer
            OpenGLOES.GenRenderbuffers(1, ref this._renderbufferID);
            GLESConfig.GlCheckError(this);
            /// Bind it to FBO
            OpenGLOES.BindRenderbuffer(All.RenderbufferOes, this._renderbufferID);
            GLESConfig.GlCheckError(this);

            /// Allocate storage for depth buffer
            if (numSamples <= 0)
            {
                OpenGLOES.RenderbufferStorage(All.RenderbufferOes, format, width, height);
                GLESConfig.GlCheckError(this);
            }
        }