Fix bound textures and framebuffers when a WebGL Canvas is resized

This commit is contained in:
Imanol Fernandez 2017-08-17 16:47:05 +02:00
parent fbabcaf614
commit 712998b086

View file

@ -279,6 +279,22 @@ impl WebGLRenderingContext {
// default scissor when the canvas was created or the last scissor that the user set.
let rect = self.current_scissor.get();
self.send_command(WebGLCommand::Scissor(rect.0, rect.1, rect.2, rect.3));
// Bound texture must not change when the canvas is resized.
// Right now offscreen_gl_context generates a new FBO and the bound texture is changed
// in order to create a new render to texture attachment.
// Send a command to re-bind the TEXTURE_2D, if any.
if let Some(texture) = self.bound_texture_2d.get() {
self.send_command(WebGLCommand::BindTexture(constants::TEXTURE_2D, Some(texture.id())));
}
// Bound framebuffer must not change when the canvas is resized.
// Right now offscreen_gl_context generates a new FBO on resize.
// Send a command to re-bind the framebuffer, if any.
if let Some(fbo) = self.bound_framebuffer.get() {
let id = WebGLFramebufferBindingRequest::Explicit(fbo.id());
self.send_command(WebGLCommand::BindFramebuffer(constants::FRAMEBUFFER, id));
}
}
pub fn webgl_sender(&self) -> WebGLMsgSender {