示例#1
0
        /// <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);
        }
示例#2
0
 internal void ResetErrors()
 {
     if (!this.Context.ErrorChecking)
     {
         return;
     }
     do
     {
         ;
     }while (GL.GetError() != All.False);
 }
示例#3
0
        internal void CheckErrors()
        {
            if (!this.Context.ErrorChecking)
            {
                return;
            }
            List <ErrorCode> list = ErrorHelper.ContextErrors[this.Context];

            list.Clear();
            ErrorCode errorCode1;

            do
            {
                errorCode1 = (ErrorCode)GL.GetError();
                list.Add(errorCode1);
            }while (errorCode1 != ErrorCode.NoError);
            if (list.Count == 1)
            {
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();

            foreach (ErrorCode errorCode2 in list)
            {
                if (errorCode2 != ErrorCode.NoError)
                {
                    stringBuilder.Append(((object)errorCode2).ToString());
                    stringBuilder.Append(", ");
                }
                else
                {
                    break;
                }
            }
            stringBuilder.Remove(stringBuilder.Length - 2, 2);
            throw new GraphicsErrorException(((object)stringBuilder).ToString());
        }