mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
ui: Add comments about scaleForWindow
This commit is contained in:
parent
ba0279ebe3
commit
f3712a7e62
25
uicontext.go
25
uicontext.go
@ -63,9 +63,15 @@ func newUIContext(game Game, scaleForWindow float64) *uiContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type uiContext struct {
|
type uiContext struct {
|
||||||
game Game
|
game Game
|
||||||
offscreen *Image
|
offscreen *Image
|
||||||
screen *Image
|
screen *Image
|
||||||
|
|
||||||
|
// scaleForWindow is the scale of a window. This doesn't represent the scale on fullscreen. This value works
|
||||||
|
// only on desktops.
|
||||||
|
//
|
||||||
|
// scaleForWindow is for backward compatibility and is used to calculate the window size when SetScreenSize
|
||||||
|
// is called.
|
||||||
scaleForWindow float64
|
scaleForWindow float64
|
||||||
|
|
||||||
outsideSizeUpdated bool
|
outsideSizeUpdated bool
|
||||||
@ -102,6 +108,10 @@ func (c *uiContext) getScaleForWindow() float64 {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetScreenSize sets the (logical) screen size and adjusts the window size.
|
||||||
|
//
|
||||||
|
// SetScreenSize is for backward compatibility. This is called from ebiten.SetScreenSize and
|
||||||
|
// uidriver/mobile.UserInterface.
|
||||||
func (c *uiContext) SetScreenSize(width, height int) {
|
func (c *uiContext) SetScreenSize(width, height int) {
|
||||||
g, ok := c.game.(*defaultGame)
|
g, ok := c.game.(*defaultGame)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -153,12 +163,9 @@ func (c *uiContext) updateOffscreen() {
|
|||||||
d := uiDriver().DeviceScaleFactor()
|
d := uiDriver().DeviceScaleFactor()
|
||||||
c.screen = newScreenFramebufferImage(int(c.outsideWidth*d), int(c.outsideHeight*d))
|
c.screen = newScreenFramebufferImage(int(c.outsideWidth*d), int(c.outsideHeight*d))
|
||||||
|
|
||||||
if uiDriver().CanHaveWindow() && !uiDriver().IsFullscreen() {
|
// Do not have to update scaleForWindow since this is used only for backward compatibility.
|
||||||
// TODO: Update the scale for window. In the current implementation, this can cause an infinite loop:
|
// Then, if a window is resizable, scaleForWindow (= ebiten.ScreenScale) might not match with the actual
|
||||||
// e.g., when the size is 854 and the scale is 0.75, the calculated outside size is 640.5. This is
|
// scale. This is fine since ebiten.ScreenScale will be deprecated.
|
||||||
// rounded to 640, and then the scale is updated.
|
|
||||||
// c.setScaleForWindow(c.screenScale() / d)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *uiContext) screenScale() float64 {
|
func (c *uiContext) screenScale() float64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user