mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
graphics: Bug fix: viewport size must be within the framebuffer size
This fixes #71 and #420
This commit is contained in:
parent
0dcba7844b
commit
72c02fc398
@ -58,9 +58,13 @@ func newFramebufferFromTexture(texture *texture, width, height int) (*framebuffe
|
||||
const defaultViewportSize = 4096
|
||||
|
||||
func (f *framebuffer) viewportSize() (int, int) {
|
||||
if web.IsEdgeBrowser() {
|
||||
// On some browsers, viewport size must be within the framebuffer size.
|
||||
// e.g. Edge (#71), Chrome on GPD Pocket (#420)
|
||||
if web.IsBrowser() {
|
||||
return f.width, f.height
|
||||
}
|
||||
|
||||
// If possible, always use the same viewport size to reduce draw calls.
|
||||
return defaultViewportSize, defaultViewportSize
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,10 @@ import (
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
)
|
||||
|
||||
func IsBrowser() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func isIOS() bool {
|
||||
ua := js.Global.Get("navigator").Get("userAgent").String()
|
||||
if !strings.Contains(ua, "iPhone") {
|
||||
@ -44,8 +48,3 @@ func isAndroidChrome() bool {
|
||||
func IsMobileBrowser() bool {
|
||||
return isIOS() || isAndroidChrome()
|
||||
}
|
||||
|
||||
func IsEdgeBrowser() bool {
|
||||
ua := js.Global.Get("navigator").Get("userAgent").String()
|
||||
return strings.Contains(ua, "Edge")
|
||||
}
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
package web
|
||||
|
||||
func IsMobileBrowser() bool {
|
||||
func IsBrowser() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func IsEdgeBrowser() bool {
|
||||
func IsMobileBrowser() bool {
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user