servo/main: Load gl symbols in headless mode

This allows running WebGL reftests in wpt.
This commit is contained in:
Emilio Cobos Álvarez 2015-11-01 14:47:46 +01:00
parent 35473b0009
commit 938a05428a
3 changed files with 20 additions and 0 deletions

View file

@ -29,12 +29,25 @@ extern crate log;
extern crate servo;
extern crate time;
extern crate gleam;
extern crate offscreen_gl_context;
use gleam::gl;
use offscreen_gl_context::GLContext;
use servo::Browser;
use servo::compositing::windowing::WindowEvent;
use servo::net_traits::hosts;
use servo::util::opts;
use std::rc::Rc;
#[cfg(not(target_os = "android"))]
fn load_gl_when_headless() {
gl::load_with(|addr| GLContext::get_proc_address(addr) as *const _);
}
#[cfg(target_os = "android")]
fn load_gl_when_headless() {}
fn main() {
env_logger::init().unwrap();
@ -47,6 +60,9 @@ fn main() {
hosts::global_init();
let window = if opts::get().headless {
// Load gl functions even when in headless mode,
// to avoid crashing with webgl
load_gl_when_headless();
None
} else {
Some(app::create_window(std::ptr::null_mut()))