Comments (22)
This isn't related to rust-windowing/glutin#1068. While I'm not familiar with Piston's stack, it looks like the rendering isn't accounting for the DPI factor at all. I'd look into whatever's generating your matrices, since that's where the problem should be.
from glutin_window.
I tested on Windows, and it seems to be the opposite. It's correct on the HiDPI display, but not the standard dpi display.
from glutin_window.
Notice that drawing is set up in frame buffer coordinates by 2D backends, not user coordinates, as @francesca64 pointed out.
from glutin_window.
Do you get the same bug with the SDL2 or GLFW backend?
from glutin_window.
The bug doesn't occur in SDL2 nor GLFW in that the position isn't blatantly wrong like with glutin, but SDL and GLFW don't appear to scale with DPI. i.e. the square is smaller.
from glutin_window.
So, Glutin detects DPI change and resizes the window.
What happens if you add c.transform.scale(dx, dy)
where dx, dy
are Window::draw_size()
divided by Window::size()
?
from glutin_window.
Adding
let size = window.size();
let draw_size = window.draw_size();
let dx = draw_size.width as f64 / size.width as f64;
let dy = draw_size.height as f64 / size.height as f64;
c.transform = c.transform.scale(dx, dy);
made the square bigger, and the position is still wrong.
from glutin_window.
I think it is likely that the bug detecting code triggers this bug. We could merge #147, release a new patch, and yank the version if people get problems.
from glutin_window.
For some reason I can't find the original issue to this PR: #136
from glutin_window.
@0e4ef622 how does the dx, dy
modification work with your patch? Is it scaled right?
from glutin_window.
It might be that you should scale with 1/dx, 1/dy
instead.
from glutin_window.
Link to previous bug fix: #137
from glutin_window.
If my intuition is correct, the position should be affected by the bug, not the size. So, with the right matrix set up the rectangle should be at the right size and position correctly with the patch.
If this is correct, then there is a bug, and merging the patch will either fix the problem for everyone or lead to a Heisen-bug (a bug fix that triggers another bug).
from glutin_window.
Scaling by 1/dx and 1/dy with my patch makes the red square the same size as with the GLFW backend and SDL2 backend without the scaling.
from glutin_window.
Hmm... that doesn't sound right. Do you have screenshots comparing SDL2 vs Glutin?
from glutin_window.
EDIT: I don't know what's wrong with the title .-.
from glutin_window.
Another screenshot comparing SDL2 and glutin_window 0.47.
from glutin_window.
I'm not sure how to interpret those screenshots.
The general idea is that if the resolution gets larger, drawing should stay in pixel coordinates. This how 2D backends behave by default today, but it might change in future. So, the size of the rectangle should stay the same in pixel coordinates.
However, somehow the rectangle size is corrected after applying a matrix transform. This confuses me.
from glutin_window.
Glutin is the only backend that appears to scale with dpi, at least on Linux. All the screenshots we're on a 144 dpi display.
from glutin_window.
A side effect of this is text appears blurry on high dpi screens since the glyphs are rasterized at the wrong size.
from glutin_window.
I think it makes sense to go the route of #148, but also remove the stuff which is no longer needed.
from glutin_window.
I believe combining the two PRs is the right thing to do. Will make a PR soon.
from glutin_window.
Related Issues (20)
- Can't detect window close with `wait_event`
- panic when closing window during render, Windows 10
- panicked at 'glx::MakeCurrent failed'
- fullscreen take size from setting HOT 3
- Panicked Ubuntu 14.04
- Make OpenGL initialization default Cargo feature flag
- Building a window results in an "explicit panic" on Windows HOT 2
- A lot of mouse input seems to cause poll_event to return None when it should still have events for that frame HOT 4
- Stack overflow in event handling HOT 2
- Coordinate system is messed up in 0.45.2 HOT 6
- Allow use of opengles HOT 1
- Capturing glutin events not supported by piston HOT 2
- `eglCreateWindowSurface` fails after updating to android 10 HOT 1
- Unknown keys with valid scan codes are not handled.
- Thread panic in Rust 1.48.0 HOT 2
- Panic when polling event in rust 1.48.0 in piston rotating box example
- `scale_factor` is not considered in mouse event arguments
- All colors darkened after updating to 0.71.0
- Panic when creating basic fullscreen window
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glutin_window.