private void Build(int width, int height, bool mipMap, RSurfaceFormat preferredFormat, RDepthFormat preferredDepthFormat, int preferredMultiSampleCount, bool shared) { var depth = 0; var stencil = 0; BackBuffer = new RTexture2D(); BackBuffer.Create(width, height, RPixelFormat.Rgba, preferredFormat); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, BackBuffer.Id, 0); if (preferredDepthFormat != RDepthFormat.None) { DepthBuffer = new RTexture2D(); if (preferredDepthFormat == RDepthFormat.Depth24Stencil8 || preferredDepthFormat == RDepthFormat.Depth32Stencil8) { DepthBuffer.CreateDepth(width, height, RPixelFormat.DepthStencil, preferredDepthFormat); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthStencilAttachment, TextureTarget.Texture2D, DepthBuffer.Id, 0); } else { DepthBuffer.CreateDepth(width, height, RPixelFormat.DepthComponent, preferredDepthFormat); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, DepthBuffer.Id, 0); } REngine.CheckGLError(); } if (GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer) != FramebufferErrorCode.FramebufferComplete) { throw new Exception("Error creating frame buffer: framebuffer is not complete"); } }