private Framebuffer CreateFramebuffer(int width, int height) { //Renderbuffer colorBuffer = Renderbuffer.CreateColorbuffer(width, height, GL.GL_RGBA); //Renderbuffer depthBuffer = Renderbuffer.CreateDepthbuffer(width, height, DepthComponentType.DepthComponent24); var framebuffer = new Framebuffer(width, height); framebuffer.Bind(); //framebuffer.Attach(colorBuffer);//0 //this.BindingTexture = framebuffer.Attach(TextureAttachment.DepthAttachment);//1 var texture = new Texture(new TexImage2D(TexImage2D.Target.Texture2D, GL.GL_DEPTH_COMPONENT32, width, height, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT), // 设置默认滤波模式 new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR), // 设置深度比较模式 new TexParameteri(TexParameter.PropertyName.TextureCompareMode, (int)GL.GL_COMPARE_REF_TO_TEXTURE), new TexParameteri(TexParameter.PropertyName.TextureCompareFunc, (int)GL.GL_LEQUAL), // 设置边界截取模式 new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE), new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE)); texture.Initialize(); framebuffer.Attach(FramebufferTarget.Framebuffer, texture, AttachmentLocation.Depth); this.BindingTexture = texture; //framebuffer.Attach(depthBuffer);// special //framebuffer.SetDrawBuffers(GL.GL_COLOR_ATTACHMENT0 + 1);// as in 1 in framebuffer.Attach(texture);//1 //framebuffer.SetDrawBuffers(GL.GL_NONE); framebuffer.SetDrawBuffer(GL.GL_NONE); //framebuffer.SetReadBuffer(GL.GL_NONE); this.BindingTexture.Bind(); framebuffer.CheckCompleteness(); this.BindingTexture.Unbind(); framebuffer.Unbind(); return(framebuffer); }
private Framebuffer CreateFramebuffer(int width, int height) { var framebuffer = new Framebuffer(width, height); framebuffer.Bind(); { var renderbuffer = new Renderbuffer(width, height, GL.GL_RGBA, RenderbufferType.ColorBuffer); framebuffer.Attach(FramebufferTarget.Framebuffer, renderbuffer, 0u);// 0 } { var texture = new Texture(new TexImageBitmap(width, height), new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_REPEAT), new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR), new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR)); texture.Initialize(); framebuffer.Attach(FramebufferTarget.Framebuffer, texture, 1u);// 1 this.BindingTexture = texture; } { var renderbuffer = new Renderbuffer(width, height, GL.GL_DEPTH_COMPONENT24, RenderbufferType.DepthBuffer); framebuffer.Attach(FramebufferTarget.Framebuffer, renderbuffer, AttachmentLocation.Depth); // special } framebuffer.SetDrawBuffer(GL.GL_COLOR_ATTACHMENT0 + 1); // as in 1 in framebuffer.Attach(FramebufferTarget.Framebuffer, texture, 1u);// 1 framebuffer.CheckCompleteness(); framebuffer.Unbind(); return(framebuffer); }
private Framebuffer CreateFramebuffer(int width, int height) { var framebuffer = new Framebuffer(width, height); framebuffer.Bind(); Renderbuffer colorbuffer = framebuffer.Attach(RenderbufferType.ColorBuffer); //0 Texture texture = framebuffer.Attach(TextureAttachment.ColorAttachment); //1 Renderbuffer depthbuffer = framebuffer.Attach(RenderbufferType.DepthBuffer); // special framebuffer.SetDrawBuffer(GL.GL_COLOR_ATTACHMENT0 + 1); // as in 1 in framebuffer.Attach(TextureAttachment.ColorAttachment);//1 framebuffer.CheckCompleteness(); framebuffer.Unbind(); this.BindingTexture = texture; return(framebuffer); }
private Framebuffer CreateFramebuffer(int width, int height) { //Renderbuffer colorBuffer = Renderbuffer.CreateColorbuffer(width, height, GL.GL_RGBA); //Renderbuffer depthBuffer = Renderbuffer.CreateDepthbuffer(width, height, DepthComponentType.DepthComponent24); var framebuffer = new Framebuffer(width, height); framebuffer.Bind(); //framebuffer.Attach(colorBuffer);//0 this.BindingTexture = framebuffer.Attach(TextureAttachment.DepthAttachment);//1 //framebuffer.Attach(depthBuffer);// special //framebuffer.SetDrawBuffers(GL.GL_COLOR_ATTACHMENT0 + 1);// as in 1 in framebuffer.Attach(texture);//1 //framebuffer.SetDrawBuffers(GL.GL_NONE); framebuffer.SetDrawBuffer(GL.GL_NONE); //framebuffer.SetReadBuffer(GL.GL_NONE); this.BindingTexture.Bind(); framebuffer.CheckCompleteness(); this.BindingTexture.Unbind(); framebuffer.Unbind(); return(framebuffer); }