mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphics: Use a const viewport
This commit is contained in:
parent
8d17d1876c
commit
9757319848
@ -73,9 +73,11 @@ func (f *Framebuffer) Dispose(c *opengl.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const viewportSize = 4096
|
||||||
|
|
||||||
func (f *Framebuffer) setAsViewport(c *opengl.Context) error {
|
func (f *Framebuffer) setAsViewport(c *opengl.Context) error {
|
||||||
width := int(NextPowerOf2Int32(int32(f.width)))
|
width := viewportSize
|
||||||
height := int(NextPowerOf2Int32(int32(f.height)))
|
height := viewportSize
|
||||||
return c.SetViewport(f.native, width, height)
|
return c.SetViewport(f.native, width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,12 +85,12 @@ func (f *Framebuffer) projectionMatrix() *[4][4]float64 {
|
|||||||
if f.proMatrix != nil {
|
if f.proMatrix != nil {
|
||||||
return f.proMatrix
|
return f.proMatrix
|
||||||
}
|
}
|
||||||
width := int(NextPowerOf2Int32(int32(f.width)))
|
width := viewportSize
|
||||||
height := int(NextPowerOf2Int32(int32(f.height)))
|
height := viewportSize
|
||||||
m := orthoProjectionMatrix(0, width, 0, height)
|
m := orthoProjectionMatrix(0, width, 0, height)
|
||||||
if f.flipY {
|
if f.flipY {
|
||||||
m[1][1] *= -1
|
m[1][1] *= -1
|
||||||
m[1][3] += float64(f.height) / float64(NextPowerOf2Int32(int32(f.height))) * 2
|
m[1][3] += float64(f.height) / float64(height) * 2
|
||||||
}
|
}
|
||||||
f.proMatrix = m
|
f.proMatrix = m
|
||||||
return f.proMatrix
|
return f.proMatrix
|
||||||
|
Loading…
Reference in New Issue
Block a user