graphicsdriver/opengl: Refactoring: Improve logic to generate framebuffer

This commit is contained in:
Hajime Hoshi 2018-11-17 19:49:30 +09:00
parent 44d1b137e7
commit de745f00fa
2 changed files with 11 additions and 4 deletions

View File

@ -73,11 +73,8 @@ func (d *Driver) NewScreenFramebufferImage(width, height int) (graphicsdriver.Im
driver: d,
width: width,
height: height,
screen: true,
}
// The (default) framebuffer size can't be converted to a power of 2.
// On browsers, c.width and c.height are used as viewport size and
// Edge can't treat a bigger viewport than the drawing area (#71).
i.framebuffer = newScreenFramebuffer(&d.context, width, height)
return i, nil
}

View File

@ -24,6 +24,7 @@ type Image struct {
framebuffer *framebuffer
width int
height int
screen bool
}
func (i *Image) IsInvalidated() bool {
@ -73,6 +74,15 @@ func (i *Image) ensureFramebuffer() error {
if i.framebuffer != nil {
return nil
}
if i.screen {
// The (default) framebuffer size can't be converted to a power of 2.
// On browsers, c.width and c.height are used as viewport size and
// Edge can't treat a bigger viewport than the drawing area (#71).
i.framebuffer = newScreenFramebuffer(&i.driver.context, i.width, i.height)
return nil
}
w, h := math.NextPowerOf2Int(i.width), math.NextPowerOf2Int(i.height)
f, err := newFramebufferFromTexture(&i.driver.context, i.textureNative, w, h)
if err != nil {