From 61c2331ac4b9df617123b56f466dc4d78bf1e9c1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 1 Nov 2018 03:34:58 +0900 Subject: [PATCH] graphicscommand: Refactoring --- internal/graphicscommand/command.go | 5 ++++- internal/graphicscommand/framebuffer.go | 17 +---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 846dfb790..7324736b1 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -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 { diff --git a/internal/graphicscommand/framebuffer.go b/internal/graphicscommand/framebuffer.go index e885b8358..05e047fd2 100644 --- a/internal/graphicscommand/framebuffer.go +++ b/internal/graphicscommand/framebuffer.go @@ -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 }