mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
e6d0943366
commit
3136ef5fbd
@ -33,6 +33,7 @@ type graphicsContext struct {
|
|||||||
f func(*Image) error
|
f func(*Image) error
|
||||||
offscreen *Image
|
offscreen *Image
|
||||||
screen *Image
|
screen *Image
|
||||||
|
screenScale float64
|
||||||
initialized bool
|
initialized bool
|
||||||
invalidated bool // browser only
|
invalidated bool // browser only
|
||||||
offsetX float64
|
offsetX float64
|
||||||
@ -48,6 +49,8 @@ func (c *graphicsContext) Invalidate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) SetSize(screenWidth, screenHeight int, screenScale float64) {
|
func (c *graphicsContext) SetSize(screenWidth, screenHeight int, screenScale float64) {
|
||||||
|
c.screenScale = screenScale
|
||||||
|
|
||||||
if c.screen != nil {
|
if c.screen != nil {
|
||||||
_ = c.screen.Dispose()
|
_ = c.screen.Dispose()
|
||||||
}
|
}
|
||||||
@ -109,14 +112,12 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
|||||||
c.screen.DrawImage(emptyImage, op)
|
c.screen.DrawImage(emptyImage, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
dw, dh := c.screen.Size()
|
_, dh := c.screen.Size()
|
||||||
sw, _ := c.offscreen.Size()
|
|
||||||
scale := float64(dw) / float64(sw)
|
|
||||||
|
|
||||||
op := &DrawImageOptions{}
|
op := &DrawImageOptions{}
|
||||||
// c.screen is special: its Y axis is down to up,
|
// c.screen is special: its Y axis is down to up,
|
||||||
// and the origin point is lower left.
|
// and the origin point is lower left.
|
||||||
op.GeoM.Scale(scale, -scale)
|
op.GeoM.Scale(c.screenScale, -c.screenScale)
|
||||||
op.GeoM.Translate(0, float64(dh))
|
op.GeoM.Translate(0, float64(dh))
|
||||||
op.GeoM.Translate(c.offsetX, c.offsetY)
|
op.GeoM.Translate(c.offsetX, c.offsetY)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user