Merge pull request #171 from tomaka/update-gl-generator

Update for gl_generator's changes
This commit is contained in:
tomaka 2014-12-24 08:23:20 +01:00
commit 4bcdbce222
7 changed files with 79 additions and 57 deletions

View file

@ -9,16 +9,17 @@ license = "Apache-2.0"
readme = "README.md" readme = "README.md"
repository = "https://github.com/tomaka/glutin" repository = "https://github.com/tomaka/glutin"
documentation = "http://tomaka.github.io/glutin/" documentation = "http://tomaka.github.io/glutin/"
build = "build.rs"
[features] [features]
default = ["window"] default = ["window"]
window = [] window = []
headless = [] headless = []
[dependencies.gl_generator] [dependencies.gl_common]
git = "https://github.com/bjz/gl-rs" git = "https://github.com/bjz/gl-rs"
[dependencies.gl_common] [build-dependencies.gl_generator]
git = "https://github.com/bjz/gl-rs" git = "https://github.com/bjz/gl-rs"
[target.arm-linux-androideabi.dependencies.android_glue] [target.arm-linux-androideabi.dependencies.android_glue]

68
build.rs Normal file
View file

@ -0,0 +1,68 @@
extern crate gl_generator;
extern crate khronos_api;
use std::os;
use std::io::File;
fn main() {
let target = os::getenv("TARGET").unwrap();
let dest = Path::new(os::getenv("OUT_DIR").unwrap());
if target.contains("windows") {
let mut file = File::create(&dest.join("wgl_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StaticGenerator,
gl_generator::registry::Ns::Wgl,
khronos_api::WGL_XML, vec![],
"1.0", "core", &mut file).unwrap();
let mut file = File::create(&dest.join("wgl_extra_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StructGenerator,
gl_generator::registry::Ns::Wgl,
khronos_api::WGL_XML,
vec![
"WGL_ARB_create_context".to_string(),
"WGL_EXT_swap_control".to_string()
],
"1.0", "core", &mut file).unwrap();
}
if target.contains("linux") {
let mut file = File::create(&dest.join("glx_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StaticGenerator,
gl_generator::registry::Ns::Glx,
khronos_api::GLX_XML, vec![],
"1.4", "core", &mut file).unwrap();
let mut file = File::create(&dest.join("glx_extra_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StructGenerator,
gl_generator::registry::Ns::Glx,
khronos_api::GLX_XML,
vec![
"GLX_ARB_create_context".to_string(),
],
"1.4", "core", &mut file).unwrap();
}
if target.contains("android") {
let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StaticGenerator,
gl_generator::registry::Ns::Egl,
khronos_api::EGL_XML, vec![],
"1.5", "core", &mut file).unwrap();
}
// TODO: only build the bindings below if we run tests/examples
let mut file = File::create(&dest.join("test_gl_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StructGenerator,
gl_generator::registry::Ns::Gl,
khronos_api::GL_XML, vec![],
"1.1", "core", &mut file).unwrap();
let mut file = File::create(&dest.join("test_gles1_bindings.rs")).unwrap();
gl_generator::generate_bindings(gl_generator::StructGenerator,
gl_generator::registry::Ns::Gles1,
khronos_api::GL_XML, vec![],
"1.1", "core", &mut file).unwrap();
}

View file

@ -7,23 +7,13 @@ use glutin;
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
mod gl { mod gl {
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
api: "gl",
profile: "core",
version: "1.1",
generator: "struct"
}
} }
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
mod gl { mod gl {
pub use self::Gles1 as Gl; pub use self::Gles1 as Gl;
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/test_gles1_bindings.rs"));
api: "gles1",
profile: "core",
version: "1.1",
generator: "struct"
}
} }
pub struct Context { pub struct Context {

View file

@ -17,12 +17,7 @@ pub mod egl {
pub type NativePixmapType = super::EGLNativePixmapType; pub type NativePixmapType = super::EGLNativePixmapType;
pub type NativeWindowType = super::EGLNativeWindowType; pub type NativeWindowType = super::EGLNativeWindowType;
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
api: "egl",
profile: "core",
version: "1.5",
generator: "static"
}
} }
pub type khronos_utime_nanoseconds_t = khronos_uint64_t; pub type khronos_utime_nanoseconds_t = khronos_uint64_t;

View file

@ -1,25 +1,11 @@
/// WGL bindings /// WGL bindings
pub mod wgl { pub mod wgl {
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/wgl_bindings.rs"));
api: "wgl",
profile: "core",
version: "1.0",
generator: "static"
}
} }
/// Functions that are not necessarly always available /// Functions that are not necessarly always available
pub mod wgl_extra { pub mod wgl_extra {
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/wgl_extra_bindings.rs"));
api: "wgl",
profile: "core",
version: "1.0",
generator: "struct",
extensions: [
"WGL_ARB_create_context",
"WGL_EXT_swap_control"
]
}
} }
#[link(name = "opengl32")] #[link(name = "opengl32")]

View file

@ -8,25 +8,12 @@ use libc;
/// GLX bindings /// GLX bindings
pub mod glx { pub mod glx {
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/glx_bindings.rs"));
api: "glx",
profile: "core",
version: "1.4",
generator: "static"
}
} }
/// Functions that are not necessarly always available /// Functions that are not necessarly always available
pub mod glx_extra { pub mod glx_extra {
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/glx_extra_bindings.rs"));
api: "glx",
profile: "core",
version: "1.4",
generator: "struct",
extensions: [
"GLX_ARB_create_context"
]
}
} }
pub type Atom = libc::c_ulong; pub type Atom = libc::c_ulong;

View file

@ -6,12 +6,7 @@ extern crate glutin;
extern crate libc; extern crate libc;
mod gl { mod gl {
generate_gl_bindings! { include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
api: "gl",
profile: "core",
version: "1.1",
generator: "struct"
}
} }
#[cfg(feature = "headless")] #[cfg(feature = "headless")]