mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
uidriver/glfw: Rename variables
DP represents a device independent pixel.
This commit is contained in:
parent
7d403930af
commit
190feb6ecd
@ -40,9 +40,9 @@ import (
|
|||||||
type UserInterface struct {
|
type UserInterface struct {
|
||||||
title string
|
title string
|
||||||
window *glfw.Window
|
window *glfw.Window
|
||||||
width int
|
screenWidthInDP int
|
||||||
windowWidth int
|
windowWidthInDP int
|
||||||
height int
|
screenHeightInDP int
|
||||||
scale float64
|
scale float64
|
||||||
fullscreenScale float64
|
fullscreenScale float64
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ type UserInterface struct {
|
|||||||
lastDeviceScaleFactor float64
|
lastDeviceScaleFactor float64
|
||||||
|
|
||||||
initMonitor *glfw.Monitor
|
initMonitor *glfw.Monitor
|
||||||
initFullscreenWidth int
|
initFullscreenWidthInDP int
|
||||||
initFullscreenHeight int
|
initFullscreenHeightInDP int
|
||||||
initFullscreen bool
|
initFullscreen bool
|
||||||
initCursorVisible bool
|
initCursorVisible bool
|
||||||
initWindowDecorated bool
|
initWindowDecorated bool
|
||||||
@ -134,8 +134,8 @@ func initialize() error {
|
|||||||
theUI.window = w
|
theUI.window = w
|
||||||
theUI.initMonitor = theUI.currentMonitorFromPosition()
|
theUI.initMonitor = theUI.currentMonitorFromPosition()
|
||||||
v := theUI.initMonitor.GetVideoMode()
|
v := theUI.initMonitor.GetVideoMode()
|
||||||
theUI.initFullscreenWidth = int(theUI.toDeviceIndependentPixel(float64(v.Width)))
|
theUI.initFullscreenWidthInDP = int(theUI.toDeviceIndependentPixel(float64(v.Width)))
|
||||||
theUI.initFullscreenHeight = int(theUI.toDeviceIndependentPixel(float64(v.Height)))
|
theUI.initFullscreenHeightInDP = int(theUI.toDeviceIndependentPixel(float64(v.Height)))
|
||||||
theUI.window.Destroy()
|
theUI.window.Destroy()
|
||||||
theUI.window = nil
|
theUI.window = nil
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ func (u *UserInterface) toDeviceDependentPixel(x float64) float64 {
|
|||||||
|
|
||||||
func (u *UserInterface) ScreenSizeInFullscreen() (int, int) {
|
func (u *UserInterface) ScreenSizeInFullscreen() (int, int) {
|
||||||
if !u.isRunning() {
|
if !u.isRunning() {
|
||||||
return u.initFullscreenWidth, u.initFullscreenHeight
|
return u.initFullscreenWidthInDP, u.initFullscreenHeightInDP
|
||||||
}
|
}
|
||||||
|
|
||||||
var w, h int
|
var w, h int
|
||||||
@ -341,7 +341,7 @@ func (u *UserInterface) SetScreenScale(scale float64) {
|
|||||||
if !u.isRunning() {
|
if !u.isRunning() {
|
||||||
panic("glfw: SetScreenScale can't be called before the main loop starts")
|
panic("glfw: SetScreenScale can't be called before the main loop starts")
|
||||||
}
|
}
|
||||||
u.setScreenSize(u.width, u.height, scale, u.isFullscreen(), u.vsync)
|
u.setScreenSize(u.screenWidthInDP, u.screenHeightInDP, scale, u.isFullscreen(), u.vsync)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) ScreenScale() float64 {
|
func (u *UserInterface) ScreenScale() float64 {
|
||||||
@ -381,7 +381,7 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
|||||||
u.setInitFullscreen(fullscreen)
|
u.setInitFullscreen(fullscreen)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
u.setScreenSize(u.width, u.height, u.scale, fullscreen, u.vsync)
|
u.setScreenSize(u.screenWidthInDP, u.screenHeightInDP, u.scale, fullscreen, u.vsync)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||||
@ -403,7 +403,7 @@ func (u *UserInterface) SetVsyncEnabled(enabled bool) {
|
|||||||
u.m.Unlock()
|
u.m.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
u.setScreenSize(u.width, u.height, u.scale, u.isFullscreen(), enabled)
|
u.setScreenSize(u.screenWidthInDP, u.screenHeightInDP, u.scale, u.isFullscreen(), enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) IsVsyncEnabled() bool {
|
func (u *UserInterface) IsVsyncEnabled() bool {
|
||||||
@ -440,13 +440,13 @@ func (u *UserInterface) ScreenPadding() (x0, y0, x1, y1 float64) {
|
|||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
}
|
}
|
||||||
if !u.IsFullscreen() {
|
if !u.IsFullscreen() {
|
||||||
if u.width == u.windowWidth {
|
if u.screenWidthInDP == u.windowWidthInDP {
|
||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
}
|
}
|
||||||
// The window width can be bigger than the game screen width (#444).
|
// The window width can be bigger than the game screen width (#444).
|
||||||
ox := 0.0
|
ox := 0.0
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
ox = (float64(u.windowWidth)*u.actualScreenScale() - float64(u.width)*u.actualScreenScale()) / 2
|
ox = (float64(u.windowWidthInDP)*u.actualScreenScale() - float64(u.screenWidthInDP)*u.actualScreenScale()) / 2
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return ox, 0, ox, 0
|
return ox, 0, ox, 0
|
||||||
@ -458,8 +458,8 @@ func (u *UserInterface) ScreenPadding() (x0, y0, x1, y1 float64) {
|
|||||||
mx := 0.0
|
mx := 0.0
|
||||||
my := 0.0
|
my := 0.0
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
sx = float64(u.width) * u.actualScreenScale()
|
sx = float64(u.screenWidthInDP) * u.actualScreenScale()
|
||||||
sy = float64(u.height) * u.actualScreenScale()
|
sy = float64(u.screenHeightInDP) * u.actualScreenScale()
|
||||||
|
|
||||||
v := u.currentMonitor().GetVideoMode()
|
v := u.currentMonitor().GetVideoMode()
|
||||||
d = u.deviceScaleFactor()
|
d = u.deviceScaleFactor()
|
||||||
@ -780,8 +780,8 @@ func (u *UserInterface) run(width, height int, scale float64, title string, cont
|
|||||||
|
|
||||||
// deviceDependentWindowSize must be called from the main thread.
|
// deviceDependentWindowSize must be called from the main thread.
|
||||||
func (u *UserInterface) deviceDependentWindowSize() (int, int) {
|
func (u *UserInterface) deviceDependentWindowSize() (int, int) {
|
||||||
w := int(u.toDeviceDependentPixel(float64(u.windowWidth) * u.getScale()))
|
w := int(u.toDeviceDependentPixel(float64(u.windowWidthInDP) * u.getScale()))
|
||||||
h := int(u.toDeviceDependentPixel(float64(u.height) * u.getScale()))
|
h := int(u.toDeviceDependentPixel(float64(u.screenHeightInDP) * u.getScale()))
|
||||||
return w, h
|
return w, h
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,8 +792,8 @@ func (u *UserInterface) getScale() float64 {
|
|||||||
}
|
}
|
||||||
if u.fullscreenScale == 0 {
|
if u.fullscreenScale == 0 {
|
||||||
v := u.currentMonitor().GetVideoMode()
|
v := u.currentMonitor().GetVideoMode()
|
||||||
sw := u.toDeviceIndependentPixel(float64(v.Width)) / float64(u.width)
|
sw := u.toDeviceIndependentPixel(float64(v.Width)) / float64(u.screenWidthInDP)
|
||||||
sh := u.toDeviceIndependentPixel(float64(v.Height)) / float64(u.height)
|
sh := u.toDeviceIndependentPixel(float64(v.Height)) / float64(u.screenHeightInDP)
|
||||||
s := sw
|
s := sw
|
||||||
if s > sh {
|
if s > sh {
|
||||||
s = sh
|
s = sh
|
||||||
@ -809,7 +809,7 @@ func (u *UserInterface) actualScreenScale() float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) updateSize(context driver.UIContext) {
|
func (u *UserInterface) updateSize(context driver.UIContext) {
|
||||||
u.setScreenSize(u.width, u.height, u.scale, u.isFullscreen(), u.vsync)
|
u.setScreenSize(u.screenWidthInDP, u.screenHeightInDP, u.scale, u.isFullscreen(), u.vsync)
|
||||||
|
|
||||||
sizeChanged := false
|
sizeChanged := false
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
@ -827,7 +827,7 @@ func (u *UserInterface) updateSize(context driver.UIContext) {
|
|||||||
actualScale = u.actualScreenScale()
|
actualScale = u.actualScreenScale()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
context.SetSize(u.width, u.height, actualScale)
|
context.SetSize(u.screenWidthInDP, u.screenHeightInDP, actualScale)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if u.isInitFullscreen() {
|
if u.isInitFullscreen() {
|
||||||
u.setScreenSize(u.width, u.height, u.scale, true, u.vsync)
|
u.setScreenSize(u.screenWidthInDP, u.screenHeightInDP, u.scale, true, u.vsync)
|
||||||
u.setInitFullscreen(false)
|
u.setInitFullscreen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ func (u *UserInterface) setScreenSize(width, height int, scale float64, fullscre
|
|||||||
windowRecreated := false
|
windowRecreated := false
|
||||||
|
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
if u.width == width && u.height == height && u.scale == scale && u.isFullscreen() == fullscreen && u.vsync == vsync && u.lastDeviceScaleFactor == u.deviceScaleFactor() {
|
if u.screenWidthInDP == width && u.screenHeightInDP == height && u.scale == scale && u.isFullscreen() == fullscreen && u.vsync == vsync && u.lastDeviceScaleFactor == u.deviceScaleFactor() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,13 +967,13 @@ func (u *UserInterface) setScreenSize(width, height int, scale float64, fullscre
|
|||||||
height = 1
|
height = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
u.width = width
|
u.screenWidthInDP = width
|
||||||
u.windowWidth = width
|
u.windowWidthInDP = width
|
||||||
s := scale * u.deviceScaleFactor()
|
s := scale * u.deviceScaleFactor()
|
||||||
if int(float64(width)*s) < minWindowWidth {
|
if int(float64(width)*s) < minWindowWidth {
|
||||||
u.windowWidth = int(math.Ceil(float64(minWindowWidth) / s))
|
u.windowWidthInDP = int(math.Ceil(float64(minWindowWidth) / s))
|
||||||
}
|
}
|
||||||
u.height = height
|
u.screenHeightInDP = height
|
||||||
u.scale = scale
|
u.scale = scale
|
||||||
u.fullscreenScale = 0
|
u.fullscreenScale = 0
|
||||||
u.vsync = vsync
|
u.vsync = vsync
|
||||||
|
Loading…
Reference in New Issue
Block a user