extern crate gl_generator;
use std::env;
use std::fs::File;
use std::path::Path;
use gl_generator::{Registry, Api, Profile, Fallbacks};
fn main() {
let dest = env::var("OUT_DIR").unwrap();
let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
let target = env::var("TARGET").unwrap();
if target.contains("android") {
Registry::new(Api::Gles2, (3, 0), Profile::Core, Fallbacks::All, ["GL_EXT_texture_format_BGRA8888"])
.write_bindings(gl_generator::StaticGenerator, &mut file)
.unwrap();
println!("cargo:rustc-link-lib=GLESv2");
} else {
Registry::new(Api::Gl, (3, 3), Profile::Core, Fallbacks::All, ["GL_ARB_texture_rectangle"])
.write_bindings(gl_generator::GlobalGenerator, &mut file)
.unwrap();
if target.contains("linux") {
println!("cargo:rustc-link-lib=GL");
} else if target.contains("windows") {
println!("cargo:rustc-link-lib=opengl32");
} else {
println!("cargo:rustc-link-lib=framework=OpenGL");
}
}
}