graphicsdriver/opengl: Refactoring

This commit is contained in:
Hajime Hoshi 2018-11-17 19:29:52 +09:00
parent 7586c660d5
commit 44d1b137e7
3 changed files with 6 additions and 5 deletions

View File

@ -86,7 +86,11 @@ func (c *context) bindFramebuffer(f framebufferNative) {
func (c *context) setViewport(f *framebuffer) {
c.bindFramebuffer(f.native)
if c.lastViewportWidth != f.width || c.lastViewportHeight != f.height {
// On some environments, viewport size must be within the framebuffer size.
// e.g. Edge (#71), Chrome on GPD Pocket (#420), macOS Mojave (#691).
// Use the same size of the framebuffer here.
c.setViewportImpl(f.width, f.height)
// glViewport must be called at least at every frame on iOS.
// As the screen framebuffer is the last render target, next SetViewport should be
// the first call at a frame.

View File

@ -73,8 +73,8 @@ func (i *Image) ensureFramebuffer() error {
if i.framebuffer != nil {
return nil
}
w, h := i.width, i.height
f, err := newFramebufferFromTexture(&i.driver.context, i.textureNative, math.NextPowerOf2Int(w), math.NextPowerOf2Int(h))
w, h := math.NextPowerOf2Int(i.width), math.NextPowerOf2Int(i.height)
f, err := newFramebufferFromTexture(&i.driver.context, i.textureNative, w, h)
if err != nil {
return err
}

View File

@ -264,9 +264,6 @@ func (d *Driver) useProgram(mode graphics.CompositeMode, colorM *affine.ColorM,
panic("source image is not set")
}
// On some environments, viewport size must be within the framebuffer size.
// e.g. Edge (#71), Chrome on GPD Pocket (#420), macOS Mojave (#691).
// Use the same size of the framebuffer here.
if err := destination.setViewport(); err != nil {
return err
}