renderer: Account for OpenGLs coordinate system in the Gles2Renderer
This commit is contained in:
parent
eccdd5221c
commit
76787fb7df
|
@ -33,6 +33,7 @@
|
||||||
- `X11Surface` is now multi-window capable.
|
- `X11Surface` is now multi-window capable.
|
||||||
- `Renderer::clear` now expects a second argument to optionally only clear parts of the buffer/surface
|
- `Renderer::clear` now expects a second argument to optionally only clear parts of the buffer/surface
|
||||||
- `Transform::transform_size` now takes a `Size` instead of two `u32`
|
- `Transform::transform_size` now takes a `Size` instead of two `u32`
|
||||||
|
- `Gles2Renderer` now automatically flips the `render` result to account for OpenGLs coordinate system
|
||||||
|
|
||||||
### Additions
|
### Additions
|
||||||
|
|
||||||
|
|
|
@ -743,18 +743,8 @@ fn render_surface(
|
||||||
|
|
||||||
// and draw to our buffer
|
// and draw to our buffer
|
||||||
match renderer
|
match renderer
|
||||||
.render(
|
.render(mode.size, Transform::Normal, |renderer, frame| {
|
||||||
mode.size,
|
render_layers_and_windows(renderer, frame, window_map, output_geometry, output_scale, logger)?;
|
||||||
Transform::Flipped180, // Scanout is rotated
|
|
||||||
|renderer, frame| {
|
|
||||||
render_layers_and_windows(
|
|
||||||
renderer,
|
|
||||||
frame,
|
|
||||||
window_map,
|
|
||||||
output_geometry,
|
|
||||||
output_scale,
|
|
||||||
logger,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// set cursor
|
// set cursor
|
||||||
if output_geometry.to_f64().contains(pointer_location) {
|
if output_geometry.to_f64().contains(pointer_location) {
|
||||||
|
@ -827,8 +817,7 @@ fn render_surface(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
})
|
||||||
)
|
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
.and_then(|x| x)
|
.and_then(|x| x)
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
|
|
|
@ -239,12 +239,8 @@ pub fn run_x11(log: Logger) {
|
||||||
|
|
||||||
// drawing logic
|
// drawing logic
|
||||||
match renderer
|
match renderer
|
||||||
// X11 scanout for a Dmabuf is upside down
|
|
||||||
// TODO: Address this issue in renderer.
|
// TODO: Address this issue in renderer.
|
||||||
.render(
|
.render(backend_data.mode.size, Transform::Normal, |renderer, frame| {
|
||||||
backend_data.mode.size,
|
|
||||||
Transform::Flipped180,
|
|
||||||
|renderer, frame| {
|
|
||||||
render_layers_and_windows(
|
render_layers_and_windows(
|
||||||
renderer,
|
renderer,
|
||||||
frame,
|
frame,
|
||||||
|
@ -309,8 +305,7 @@ pub fn run_x11(log: Logger) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
})
|
||||||
)
|
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
.and_then(|x| x)
|
.and_then(|x| x)
|
||||||
.map_err(Into::<SwapBuffersError>::into)
|
.map_err(Into::<SwapBuffersError>::into)
|
||||||
|
|
|
@ -1077,11 +1077,14 @@ impl Renderer for Gles2Renderer {
|
||||||
renderer[2][0] = -(1.0f32.copysign(renderer[0][0] + renderer[1][0]));
|
renderer[2][0] = -(1.0f32.copysign(renderer[0][0] + renderer[1][0]));
|
||||||
renderer[2][1] = -(1.0f32.copysign(renderer[0][1] + renderer[1][1]));
|
renderer[2][1] = -(1.0f32.copysign(renderer[0][1] + renderer[1][1]));
|
||||||
|
|
||||||
|
// We account for OpenGLs coordinate system here
|
||||||
|
let flip180 = Matrix3::new(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
let mut frame = Gles2Frame {
|
let mut frame = Gles2Frame {
|
||||||
gl: self.gl.clone(),
|
gl: self.gl.clone(),
|
||||||
programs: self.programs.clone(),
|
programs: self.programs.clone(),
|
||||||
// output transformation passed in by the user
|
// output transformation passed in by the user
|
||||||
current_projection: transform.matrix() * renderer,
|
current_projection: flip180 * transform.matrix() * renderer,
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = rendering(self, &mut frame);
|
let result = rendering(self, &mut frame);
|
||||||
|
|
|
@ -298,7 +298,8 @@ impl WinitGraphicsBackend {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.renderer.bind(self.egl.clone())?;
|
self.renderer.bind(self.egl.clone())?;
|
||||||
let result = self.renderer.render(size, Transform::Normal, rendering)?;
|
// Why is winit falling out of place with the coordinate system?
|
||||||
|
let result = self.renderer.render(size, Transform::Flipped180, rendering)?;
|
||||||
self.egl.swap_buffers()?;
|
self.egl.swap_buffers()?;
|
||||||
self.renderer.unbind()?;
|
self.renderer.unbind()?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|
Loading…
Reference in New Issue