mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/uidriver/glfw, internal/devicescale: Add comments
This commit is contained in:
parent
585f173d1c
commit
e89f53774c
@ -27,6 +27,8 @@ var (
|
||||
cache = map[pos]float64{}
|
||||
)
|
||||
|
||||
// GetAt returns the device scale at (x, y).
|
||||
// x and y are in device-dependent pixels.
|
||||
func GetAt(x, y int) float64 {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
|
||||
// fromGLFWMonitorPixel must be called from the main thread.
|
||||
func fromGLFWMonitorPixel(x float64, deviceScale float64) float64 {
|
||||
// deviceScaleFactor is sometimes an unnice value (e.g., 1.502361). Use math.Ceil to clean the vaule.
|
||||
return math.Ceil(x / deviceScale)
|
||||
}
|
||||
|
||||
@ -45,6 +46,7 @@ func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
||||
// toFramebufferPixel must be called from the main thread.
|
||||
func (u *UserInterface) toFramebufferPixel(x float64) float64 {
|
||||
s, _ := currentMonitor(u.window).GetContentScale()
|
||||
// deviceScaleFactor is sometimes an unnice value (e.g., 1.502361). Use math.Ceil to clean the vaule.
|
||||
return math.Ceil(x * float64(s) / u.deviceScaleFactor())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user