graphics: Bug fix: viewport size must be within the framebuffer size

This fixes #71 and #420
This commit is contained in:
Hajime Hoshi 2017-09-09 19:24:56 +09:00
parent 0dcba7844b
commit 72c02fc398
3 changed files with 11 additions and 8 deletions

View File

@ -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
}

View File

@ -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")
}

View File

@ -16,10 +16,10 @@
package web
func IsMobileBrowser() bool {
func IsBrowser() bool {
return false
}
func IsEdgeBrowser() bool {
func IsMobileBrowser() bool {
return false
}