webgl: Ensure that framebuffers have a color attachment before reading or writing.

This commit is contained in:
Josh Matthews 2018-08-15 13:27:44 -04:00
parent 80ed829241
commit d179435eab
4 changed files with 129 additions and 4 deletions

View file

@ -203,6 +203,16 @@ impl WebGLFramebuffer {
return self.status.get();
}
pub fn check_status_for_rendering(&self) -> u32 {
let result = self.check_status();
if result == constants::FRAMEBUFFER_COMPLETE {
if self.color.borrow().is_none() {
return constants::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
result
}
pub fn renderbuffer(&self, attachment: u32, rb: Option<&WebGLRenderbuffer>) -> WebGLResult<()> {
let binding = match attachment {
constants::COLOR_ATTACHMENT0 => &self.color,