diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2014-12-24 08:23:20 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2014-12-24 08:23:20 +0100 |
commit | 4bcdbce22259bbd247ef8ddc4573344256002086 (patch) | |
tree | 200e6aa69df269df41ece6611d7d6a60d2eb1256 | |
parent | 032c282b8ef18040c9ec5e8a2356820df031ef8b (diff) | |
parent | 7f6f4f8d04b9f6dfbbc9528552fa45db932d6dae (diff) | |
download | glutin-4bcdbce22259bbd247ef8ddc4573344256002086.tar.gz glutin-4bcdbce22259bbd247ef8ddc4573344256002086.zip |
Merge pull request #171 from tomaka/update-gl-generator
Update for gl_generator's changes
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | build.rs | 68 | ||||
-rw-r--r-- | examples/support/mod.rs | 14 | ||||
-rw-r--r-- | src/android/ffi.rs | 7 | ||||
-rw-r--r-- | src/win32/gl.rs | 18 | ||||
-rw-r--r-- | src/x11/ffi.rs | 17 | ||||
-rw-r--r-- | tests/headless.rs | 7 |
7 files changed, 79 insertions, 57 deletions
@@ -9,16 +9,17 @@ license = "Apache-2.0" readme = "README.md" repository = "https://github.com/tomaka/glutin" documentation = "http://tomaka.github.io/glutin/" +build = "build.rs" [features] default = ["window"] window = [] headless = [] -[dependencies.gl_generator] +[dependencies.gl_common] git = "https://github.com/bjz/gl-rs" -[dependencies.gl_common] +[build-dependencies.gl_generator] git = "https://github.com/bjz/gl-rs" [target.arm-linux-androideabi.dependencies.android_glue] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..166c223 --- /dev/null +++ b/build.rs @@ -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(); +} diff --git a/examples/support/mod.rs b/examples/support/mod.rs index eb27d23..6904653 100644 --- a/examples/support/mod.rs +++ b/examples/support/mod.rs @@ -7,23 +7,13 @@ use glutin; #[cfg(not(target_os = "android"))] mod gl { - generate_gl_bindings! { - api: "gl", - profile: "core", - version: "1.1", - generator: "struct" - } + include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs")); } #[cfg(target_os = "android")] mod gl { pub use self::Gles1 as Gl; - generate_gl_bindings! { - api: "gles1", - profile: "core", - version: "1.1", - generator: "struct" - } + include!(concat!(env!("OUT_DIR"), "/test_gles1_bindings.rs")); } pub struct Context { diff --git a/src/android/ffi.rs b/src/android/ffi.rs index 5e7060d..111f670 100644 --- a/src/android/ffi.rs +++ b/src/android/ffi.rs @@ -17,12 +17,7 @@ pub mod egl { pub type NativePixmapType = super::EGLNativePixmapType; pub type NativeWindowType = super::EGLNativeWindowType; - generate_gl_bindings! { - api: "egl", - profile: "core", - version: "1.5", - generator: "static" - } + include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs")); } pub type khronos_utime_nanoseconds_t = khronos_uint64_t; diff --git a/src/win32/gl.rs b/src/win32/gl.rs index a44af77..1354d95 100644 --- a/src/win32/gl.rs +++ b/src/win32/gl.rs @@ -1,25 +1,11 @@ /// WGL bindings pub mod wgl { - generate_gl_bindings! { - api: "wgl", - profile: "core", - version: "1.0", - generator: "static" - } + include!(concat!(env!("OUT_DIR"), "/wgl_bindings.rs")); } /// Functions that are not necessarly always available pub mod wgl_extra { - generate_gl_bindings! { - api: "wgl", - profile: "core", - version: "1.0", - generator: "struct", - extensions: [ - "WGL_ARB_create_context", - "WGL_EXT_swap_control" - ] - } + include!(concat!(env!("OUT_DIR"), "/wgl_extra_bindings.rs")); } #[link(name = "opengl32")] diff --git a/src/x11/ffi.rs b/src/x11/ffi.rs index 1f8b10f..5610eee 100644 --- a/src/x11/ffi.rs +++ b/src/x11/ffi.rs @@ -8,25 +8,12 @@ use libc; /// GLX bindings pub mod glx { - generate_gl_bindings! { - api: "glx", - profile: "core", - version: "1.4", - generator: "static" - } + include!(concat!(env!("OUT_DIR"), "/glx_bindings.rs")); } /// Functions that are not necessarly always available pub mod glx_extra { - generate_gl_bindings! { - api: "glx", - profile: "core", - version: "1.4", - generator: "struct", - extensions: [ - "GLX_ARB_create_context" - ] - } + include!(concat!(env!("OUT_DIR"), "/glx_extra_bindings.rs")); } pub type Atom = libc::c_ulong; diff --git a/tests/headless.rs b/tests/headless.rs index ca96fdb..b2b23da 100644 --- a/tests/headless.rs +++ b/tests/headless.rs @@ -6,12 +6,7 @@ extern crate glutin; extern crate libc; mod gl { - generate_gl_bindings! { - api: "gl", - profile: "core", - version: "1.1", - generator: "struct" - } + include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs")); } #[cfg(feature = "headless")] |