aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--build.rs2
-rw-r--r--examples/support/mod.rs19
-rw-r--r--src/api/x11/input.rs21
4 files changed, 25 insertions, 19 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 5662754..41bf084 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ keywords = ["windowing", "opengl"]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/tomaka/glutin"
-documentation = "http://tomaka.github.io/glutin/"
+documentation = "https://tomaka.github.io/glutin/"
build = "build.rs"
[features]
diff --git a/build.rs b/build.rs
index b8d3fb6..eaa42b3 100644
--- a/build.rs
+++ b/build.rs
@@ -176,5 +176,5 @@ fn main() {
gl_generator::registry::Ns::Gles2,
gl_generator::Fallbacks::All,
khronos_api::GL_XML, vec![],
- "2.0", "core", &mut file).unwrap();
+ "3.0", "core", &mut file).unwrap();
}
diff --git a/examples/support/mod.rs b/examples/support/mod.rs
index 7e9aa4f..ab8e2a1 100644
--- a/examples/support/mod.rs
+++ b/examples/support/mod.rs
@@ -46,9 +46,12 @@ pub fn load(window: &glutin::Window) -> Context {
(VERTEX_DATA.len() * mem::size_of::<f32>()) as gl::types::GLsizeiptr,
VERTEX_DATA.as_ptr() as *const _, gl::STATIC_DRAW);
- /*let mut vao = mem::uninitialized();
- gl.GenVertexArrays(1, &mut vao);
- gl.BindVertexArray(vao);*/
+ if gl.BindVertexArray.is_loaded() {
+ let mut vao = mem::uninitialized();
+ gl.GenVertexArrays(1, &mut vao);
+ gl.BindVertexArray(vao);
+ }
+
let pos_attrib = gl.GetAttribLocation(program, b"position\0".as_ptr() as *const _);
let color_attrib = gl.GetAttribLocation(program, b"color\0".as_ptr() as *const _);
gl.VertexAttribPointer(pos_attrib as gl::types::GLuint, 2, gl::FLOAT, 0,
@@ -85,11 +88,12 @@ static VERTEX_DATA: [f32; 15] = [
const VS_SRC: &'static [u8] = b"
#version 100
+precision mediump float;
-lowp attribute vec2 position;
-lowp attribute vec3 color;
+attribute vec2 position;
+attribute vec3 color;
-lowp varying vec3 v_color;
+varying vec3 v_color;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
@@ -99,8 +103,9 @@ void main() {
const FS_SRC: &'static [u8] = b"
#version 100
+precision mediump float;
-lowp varying vec3 v_color;
+varying vec3 v_color;
void main() {
gl_FragColor = vec4(v_color, 1.0);
diff --git a/src/api/x11/input.rs b/src/api/x11/input.rs
index 7387ab0..388b651 100644
--- a/src/api/x11/input.rs
+++ b/src/api/x11/input.rs
@@ -21,7 +21,8 @@ struct Axis {
id: i32,
device_id: i32,
axis_number: i32,
- axis_type: AxisType
+ axis_type: AxisType,
+ scroll_increment: f64,
}
#[derive(Debug)]
@@ -167,7 +168,7 @@ impl XInputEventHandler {
use events::Event::{Focused, MouseInput, MouseMoved, MouseWheel};
use events::ElementState::{Pressed, Released};
use events::MouseButton::{Left, Right, Middle};
- use events::MouseScrollDelta::{PixelDelta, LineDelta};
+ use events::MouseScrollDelta::LineDelta;
use events::{Touch, TouchPhase};
match cookie.evtype {
@@ -221,7 +222,7 @@ impl XInputEventHandler {
}
if scroll_delta.0.abs() > 0.0 || scroll_delta.1.abs() > 0.0 {
- Some(MouseWheel(PixelDelta(scroll_delta.0 as f32, scroll_delta.1 as f32)))
+ Some(MouseWheel(LineDelta(scroll_delta.0 as f32, scroll_delta.1 as f32)))
} else {
let new_cursor_pos = (event_data.event_x, event_data.event_y);
if new_cursor_pos != self.current_state.cursor_pos {
@@ -267,10 +268,9 @@ fn read_input_axis_info(display: &Arc<XConnection>) -> Vec<Axis> {
let mut axis_list = Vec::new();
let mut device_count = 0;
- // only get events from the master devices which are 'attached'
- // to the keyboard or cursor
+ // Check all input devices for scroll axes.
let devices = unsafe{
- (display.xinput2.XIQueryDevice)(display.display, ffi::XIAllMasterDevices, &mut device_count)
+ (display.xinput2.XIQueryDevice)(display.display, ffi::XIAllDevices, &mut device_count)
};
for i in 0..device_count {
let device = unsafe { *(devices.offset(i as isize)) };
@@ -290,7 +290,8 @@ fn read_input_axis_info(display: &Arc<XConnection>) -> Vec<Axis> {
ffi::XIScrollTypeHorizontal => AxisType::HorizontalScroll,
ffi::XIScrollTypeVertical => AxisType::VerticalScroll,
_ => { unreachable!() }
- }
+ },
+ scroll_increment: scroll_class.increment,
})
},
_ => {}
@@ -314,7 +315,7 @@ fn calc_scroll_deltas(event: &ffi::XIDeviceEvent,
prev_axis.axis_number == axis_id
});
let delta = match prev_value_pos {
- Some(idx) => axis_value - prev_axis_values[idx].value,
+ Some(idx) => prev_axis_values[idx].value - axis_value,
None => 0.0
};
@@ -335,8 +336,8 @@ fn calc_scroll_deltas(event: &ffi::XIDeviceEvent,
if axis.id == event.sourceid &&
axis.axis_number == axis_id {
match axis.axis_type {
- AxisType::HorizontalScroll => scroll_delta.0 = delta,
- AxisType::VerticalScroll => scroll_delta.1 = delta
+ AxisType::HorizontalScroll => scroll_delta.0 = delta / axis.scroll_increment,
+ AxisType::VerticalScroll => scroll_delta.1 = delta / axis.scroll_increment
}
}
}