示例#1
0
        public void AllocateRenderTarget()
        {
            GL.GenFramebuffers(1, out m_frameBuffer);
            GLWrapper.BindFramebuffer(m_frameBuffer);
            GL.FramebufferTexture2D(All.Framebuffer, All.ColorAttachment0, All.Texture2D, m_texture, 0);
            if (DepthFormat != 0)
            {
                GL.GenRenderbuffers(1, out m_depthBuffer);
                GL.BindRenderbuffer(All.Renderbuffer, m_depthBuffer);
                GL.RenderbufferStorage(All.Renderbuffer, GLWrapper.TranslateDepthFormat(DepthFormat), base.Width, base.Height);
                GL.FramebufferRenderbuffer(All.Framebuffer, All.DepthAttachment, All.Renderbuffer, m_depthBuffer);
                GL.FramebufferRenderbuffer(All.Framebuffer, All.StencilAttachment, All.Renderbuffer, 0);
            }
            else
            {
                GL.FramebufferRenderbuffer(All.Framebuffer, All.DepthAttachment, All.Renderbuffer, 0);
                GL.FramebufferRenderbuffer(All.Framebuffer, All.StencilAttachment, All.Renderbuffer, 0);
            }
            FramebufferErrorCode framebufferErrorCode = (FramebufferErrorCode)GL.CheckFramebufferStatus(All.Framebuffer);

            if (framebufferErrorCode != FramebufferErrorCode.FramebufferComplete)
            {
                throw new InvalidOperationException($"Error creating framebuffer ({framebufferErrorCode.ToString()}).");
            }
        }