webgl: Ensure that renderbuffers have been bound before attaching to a framebuffer.

This commit is contained in:
Josh Matthews 2018-08-31 10:16:57 -04:00
parent bb8d9ba74c
commit 8ede221a83
2 changed files with 6 additions and 2 deletions

View file

@ -274,7 +274,7 @@ impl WebGLFramebuffer {
let rb_id = match rb { let rb_id = match rb {
Some(rb) => { Some(rb) => {
rb.attach(self); rb.attach(self)?;
*binding.borrow_mut() = Some(WebGLFramebufferAttachment::Renderbuffer(Dom::from_ref(rb))); *binding.borrow_mut() = Some(WebGLFramebufferAttachment::Renderbuffer(Dom::from_ref(rb)));
Some(rb.id()) Some(rb.id())
} }

View file

@ -174,8 +174,12 @@ impl WebGLRenderbuffer {
Ok(()) Ok(())
} }
pub fn attach(&self, framebuffer: &WebGLFramebuffer) { pub fn attach(&self, framebuffer: &WebGLFramebuffer) -> WebGLResult<()> {
if !self.ever_bound.get() {
return Err(WebGLError::InvalidOperation);
}
self.attached_framebuffers.borrow_mut().push(Dom::from_ref(framebuffer)); self.attached_framebuffers.borrow_mut().push(Dom::from_ref(framebuffer));
Ok(())
} }
pub fn unattach(&self, fb: &WebGLFramebuffer) { pub fn unattach(&self, fb: &WebGLFramebuffer) {