graphicscommand: Refactoring

This commit is contained in:
Hajime Hoshi 2018-11-01 03:34:58 +09:00
parent e28c7b0f50
commit 61c2331ac4
2 changed files with 5 additions and 17 deletions

View File

@ -234,8 +234,11 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
if err != nil {
return err
}
f.setAsViewport()
// 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.
opengl.GetContext().SetViewport(f.native, f.width, f.height)
opengl.GetContext().BlendFunc(c.mode)
if c.nindices == 0 {

View File

@ -48,20 +48,6 @@ func newScreenFramebuffer(width, height int) *framebuffer {
}
}
// viewportSize returns the viewport size of the framebuffer.
func (f *framebuffer) viewportSize() (int, int) {
// 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.
return f.width, f.height
}
// setAsViewport sets the framebuffer as the current viewport.
func (f *framebuffer) setAsViewport() {
w, h := f.viewportSize()
opengl.GetContext().SetViewport(f.native, w, h)
}
// projectionMatrix returns a projection matrix of the framebuffer.
//
// A projection matrix converts the coodinates on the framebuffer
@ -71,7 +57,6 @@ func (f *framebuffer) projectionMatrix() []float32 {
if f.proMatrix != nil {
return f.proMatrix
}
w, h := f.viewportSize()
f.proMatrix = opengl.OrthoProjectionMatrix(0, w, 0, h)
f.proMatrix = opengl.OrthoProjectionMatrix(0, f.width, 0, f.height)
return f.proMatrix
}