diff --git a/internal/graphics/framebuffer.go b/internal/graphics/framebuffer.go index 7c56b6df2..16cfa04e0 100644 --- a/internal/graphics/framebuffer.go +++ b/internal/graphics/framebuffer.go @@ -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 } diff --git a/internal/web/js.go b/internal/web/js.go index 0e323f0fb..3ae242c57 100644 --- a/internal/web/js.go +++ b/internal/web/js.go @@ -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") -} diff --git a/internal/web/notjs.go b/internal/web/notjs.go index 3250b9ce0..bdd483258 100644 --- a/internal/web/notjs.go +++ b/internal/web/notjs.go @@ -16,10 +16,10 @@ package web -func IsMobileBrowser() bool { +func IsBrowser() bool { return false } -func IsEdgeBrowser() bool { +func IsMobileBrowser() bool { return false }