From d182608b033b97e8011e925ee0b3bc37be315264 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 18 Sep 2016 22:33:55 +0100 Subject: [PATCH 1/3] Unset the texture/rb bindings after we use them. webgl's default-texture.html was expecting to have no texture bound on a freshly created context, but with this module in place a texture was there. That texture happened to be the draw buffer, creating a feedback loop (undefined behavior). --- src/draw_buffer.rs | 3 +++ src/tests.rs | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/draw_buffer.rs b/src/draw_buffer.rs index a0b9285..5e38cb1 100644 --- a/src/draw_buffer.rs +++ b/src/draw_buffer.rs @@ -75,6 +75,7 @@ fn create_renderbuffer(format: GLenum, gl::GenRenderbuffers(1, &mut ret); gl::BindRenderbuffer(gl::RENDERBUFFER, ret); gl::RenderbufferStorage(gl::RENDERBUFFER, format, size.width, size.height); + gl::BindRenderbuffer(gl::RENDERBUFFER, 0); } ret @@ -227,6 +228,8 @@ impl DrawBufferHelpers for DrawBuffer { gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_S, gl::CLAMP_TO_EDGE as GLint); gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_T, gl::CLAMP_TO_EDGE as GLint); + gl::BindTexture(gl::TEXTURE_2D, 0); + debug_assert!(gl::get_error() == gl::NO_ERROR); Some(ColorAttachment::Texture(texture)) diff --git a/src/tests.rs b/src/tests.rs index 8c91445..3ce2c84 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,5 +1,4 @@ use gleam::gl; -use gleam::gl::types::GLint; use euclid::Size2D; use std::sync::{Once, ONCE_INIT}; @@ -133,10 +132,6 @@ fn test_sharing() { primary.make_current().unwrap(); assert!(unsafe { gl::IsTexture(secondary_texture_id) != 0 }); - // Ensure the old texture is bound, and bind the new one - assert!(gl::get_integer_v(gl::TEXTURE_BINDING_2D) == primary_texture_id as GLint); - - // Clearing and re-binding to a framebuffer instead of using getTexImage since it's not // available in GLES2 gl::clear_color(0.0, 0.0, 0.0, 1.0); From 91ee7ae24f1deb47880b957a92886a68dddc5aae Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Sep 2016 08:33:39 +0100 Subject: [PATCH 2/3] Drop unused khronos_api crate. Its last use was removed in d3355c5aaf02db2ad9ca33af03aa1cf037254470 (gl_generator version bump) and it was causing compiler warnings in servo. --- Cargo.toml | 1 - build.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e0a3418..6cb6676 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ build = "build.rs" [build-dependencies] gl_generator = "0.5" -khronos_api = "1.0" # NOTE: Just for testing use, there are no other changes [features] diff --git a/build.rs b/build.rs index 227daf9..4a7782d 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,4 @@ extern crate gl_generator; -extern crate khronos_api; use std::env; use std::fs::File; From e2f28d3f401e5a2f0065758fbd267b25835a9891 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Sep 2016 09:09:08 +0100 Subject: [PATCH 3/3] Bump version to 0.4.2. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6cb6676..b188877 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "offscreen_gl_context" license = "MIT / Apache-2.0" -version = "0.4.1" +version = "0.4.2" authors = ["Emilio Cobos Álvarez ", "The Servo Project Developers"] description = "Creation and manipulation of HW accelerated offscreen rendering contexts in multiple platforms. Originally intended for the Servo project's WebGL implementation." repository = "https://github.com/emilio/rust-offscreen-rendering-context"