aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas/webgl_thread.rs
diff options
context:
space:
mode:
authorMátyás Mustoha <matyas.mustoha@h-lab.eu>2019-08-26 14:25:47 +0200
committerMátyás Mustoha <matyas.mustoha@h-lab.eu>2019-08-26 15:12:43 +0200
commit736f6859b0a3fc2a42247dd732d7734213cc9eec (patch)
treeba2364cfb2a460d81e693ad3113cec0e18597d42 /components/canvas/webgl_thread.rs
parent66e5ad0cb8a7674ba0ff0a5a9a77ccc8dc3f2b0f (diff)
downloadservo-736f6859b0a3fc2a42247dd732d7734213cc9eec.tar.gz
servo-736f6859b0a3fc2a42247dd732d7734213cc9eec.zip
Fix extension querying when using WebGL2
This patch fixes a crash caused by using a deprecated GL call. Starting with OpenGL 3 (used by WebGL2), the `glGetString(GL_EXTENSIONS)` call is deprecated, and some drivers produce GL_INVALID_ENUM error. Querying can be done by checking the number of extensions first, then getting the extensions one by one.
Diffstat (limited to 'components/canvas/webgl_thread.rs')
-rw-r--r--components/canvas/webgl_thread.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index faea8e76d1c..7844c762cfb 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -1721,8 +1721,19 @@ impl WebGLImpl {
chan.send(result).unwrap();
}
+ #[allow(unsafe_code)]
fn get_extensions(gl: &dyn gl::Gl, chan: &WebGLSender<String>) {
- chan.send(gl.get_string(gl::EXTENSIONS)).unwrap();
+ let mut ext_count = [0];
+ unsafe {
+ gl.get_integer_v(gl::NUM_EXTENSIONS, &mut ext_count);
+ }
+ let ext_count = ext_count[0] as usize;
+ let mut extensions = Vec::with_capacity(ext_count);
+ for idx in 0..ext_count {
+ extensions.push(gl.get_string_i(gl::EXTENSIONS, idx as u32))
+ }
+ let extensions = extensions.join(" ");
+ chan.send(extensions).unwrap();
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6