mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +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{}
|
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 {
|
func GetAt(x, y int) float64 {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.Unlock()
|
defer m.Unlock()
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
// fromGLFWMonitorPixel must be called from the main thread.
|
// fromGLFWMonitorPixel must be called from the main thread.
|
||||||
func fromGLFWMonitorPixel(x float64, deviceScale float64) float64 {
|
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)
|
return math.Ceil(x / deviceScale)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
|||||||
// toFramebufferPixel must be called from the main thread.
|
// toFramebufferPixel must be called from the main thread.
|
||||||
func (u *UserInterface) toFramebufferPixel(x float64) float64 {
|
func (u *UserInterface) toFramebufferPixel(x float64) float64 {
|
||||||
s, _ := currentMonitor(u.window).GetContentScale()
|
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())
|
return math.Ceil(x * float64(s) / u.deviceScaleFactor())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user