Check framebuffer status later not immediately after binding

No errors https://github.com/iceiix/steven/issues/5
This commit is contained in:
ice_iix 2018-10-06 13:58:16 -07:00
parent 3a32710b17
commit 84c682b177
2 changed files with 23 additions and 24 deletions

View File

@ -819,7 +819,8 @@ pub const DEPTH_ATTACHMENT: Attachment = gl::DEPTH_ATTACHMENT;
pub struct Framebuffer(u32);
unsafe fn check_framebuffer_status() {
pub fn check_framebuffer_status() {
unsafe {
let status = gl::CheckFramebufferStatus(gl::FRAMEBUFFER);
let s =
match status {
@ -841,7 +842,7 @@ unsafe fn check_framebuffer_status() {
println!("glBindFramebuffer failed, glCheckFrameBufferStatus(GL_FRAMEBUFFER) = {} {}", status, s);
//panic!("glBindFramebuffer failed, glCheckFrameBufferStatus(GL_FRAMEBUFFER) = {} {}", status, s);
}
}
}
impl Framebuffer {
@ -856,21 +857,18 @@ impl Framebuffer {
pub fn bind(&self) {
unsafe {
gl::BindFramebuffer(gl::FRAMEBUFFER, self.0);
check_framebuffer_status();
}
}
pub fn bind_read(&self) {
unsafe {
gl::BindFramebuffer(gl::READ_FRAMEBUFFER, self.0);
check_framebuffer_status();
}
}
pub fn bind_draw(&self) {
unsafe {
gl::BindFramebuffer(gl::DRAW_FRAMEBUFFER, self.0);
check_framebuffer_status();
}
}

View File

@ -705,7 +705,7 @@ impl TransInfo {
gl::bind_frag_data_location(&chunk_shader.program, 0, "accum");
gl::bind_frag_data_location(&chunk_shader.program, 1, "revealage");
gl::draw_buffers(&[gl::COLOR_ATTACHMENT_0, gl::COLOR_ATTACHMENT_1]);
gl::check_framebuffer_status();
let main = gl::Framebuffer::new();
main.bind();
@ -719,6 +719,7 @@ impl TransInfo {
fb_depth.bind(gl::TEXTURE_2D_MULTISAMPLE);
fb_depth.image_2d_sample(gl::TEXTURE_2D_MULTISAMPLE, NUM_SAMPLES, width, height, gl::DEPTH_COMPONENT24, false);
main.texture_2d(gl::DEPTH_ATTACHMENT, gl::TEXTURE_2D_MULTISAMPLE, &fb_depth, 0);
gl::check_framebuffer_status();
gl::unbind_framebuffer();