private void CreateFramebuffer() { this.glControl.MakeCurrent(); if (this.framebufferId > 0) { GL.DeleteFramebuffer(this.framebufferId); } if (this.depthbufferId > 0) { GL.DeleteRenderbuffer(this.depthbufferId); } if (this.colorbufferId > 0) { GL.DeleteRenderbuffer(this.colorbufferId); } this.framebufferId = GL.GenFramebuffer(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, this.framebufferId); this.colorbufferId = GL.GenRenderbuffer(); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, this.colorbufferId); GL.RenderbufferStorage( RenderbufferTarget.Renderbuffer, RenderbufferStorage.Rgba8, this.size.Width, this.size.Height); GL.FramebufferRenderbuffer( FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, RenderbufferTarget.Renderbuffer, this.colorbufferId); this.depthbufferId = GL.GenRenderbuffer(); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, this.depthbufferId); GL.RenderbufferStorage( RenderbufferTarget.Renderbuffer, RenderbufferStorage.DepthComponent24, this.size.Width, this.size.Height); GL.FramebufferRenderbuffer( FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, RenderbufferTarget.Renderbuffer, this.depthbufferId); FramebufferErrorCode error = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); if (error != FramebufferErrorCode.FramebufferComplete) { throw new Exception(); } this.loaded = true; }