From 8c1b2dd63370fe102b2a447e7840fc038413b6cc Mon Sep 17 00:00:00 2001 From: Tomaka17 Date: Sun, 9 Nov 2014 16:07:58 +0100 Subject: Add support for the OpenGL debug flag --- src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 3c8b939..d65b415 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,6 +91,7 @@ pub struct WindowBuilder { title: String, monitor: Option, gl_version: Option<(uint, uint)>, + gl_debug: bool, vsync: bool, visible: bool, } @@ -104,6 +105,7 @@ impl WindowBuilder { title: "glutin window".to_string(), monitor: None, gl_version: None, + gl_debug: cfg!(ndebug), vsync: false, visible: true, } @@ -141,6 +143,15 @@ impl WindowBuilder { self } + /// Sets the *debug* flag for the OpenGL context. + /// + /// The default value for this flag is `cfg!(ndebug)`, which means that it's enabled + /// when you run `cargo build` and disabled when you run `cargo build --release`. + pub fn with_gl_debug_flag(mut self, flag: bool) -> WindowBuilder { + self.gl_debug = flag; + self + } + /// Requests that the window has vsync enabled. pub fn with_vsync(mut self) -> WindowBuilder { self.vsync = true; @@ -178,6 +189,7 @@ impl WindowBuilder { pub struct HeadlessRendererBuilder { dimensions: (uint, uint), gl_version: Option<(uint, uint)>, + gl_debug: bool, } #[cfg(feature = "headless")] @@ -187,6 +199,7 @@ impl HeadlessRendererBuilder { HeadlessRendererBuilder { dimensions: (width, height), gl_version: None, + gl_debug: cfg!(ndebug), } } @@ -199,6 +212,15 @@ impl HeadlessRendererBuilder { self } + /// Sets the *debug* flag for the OpenGL context. + /// + /// The default value for this flag is `cfg!(ndebug)`, which means that it's enabled + /// when you run `cargo build` and disabled when you run `cargo build --release`. + pub fn with_gl_debug_flag(mut self, flag: bool) -> HeadlessRendererBuilder { + self.gl_debug = flag; + self + } + /// Builds the headless context. /// /// Error should be very rare and only occur in case of permission denied, incompatible system, -- cgit v1.2.3