ui: Remove opengl dependency from ui package (desktop)

This commit is contained in:
Hajime Hoshi 2018-11-05 01:09:12 +09:00
parent 02b570a8e1
commit 2c7017534f
4 changed files with 15 additions and 5 deletions

View File

@ -198,6 +198,13 @@ func (q *commandQueue) Flush() {
q.nindices = 0
q.tmpNumIndices = 0
q.nextIndex = 0
// The bound framebuffer must be the original screen framebuffer before swapping buffers.
// Note that swapping might not happen after this function. BeforeSwapping should not be
// harmful in any cases.
//
// TODO: Confirm which machine requires this. Probably BungBungame Photon 2?
opengl.GetContext().BeforeSwapping()
}
// Error returns an OpenGL error for the last command.

View File

@ -506,3 +506,7 @@ func (c *Context) RestoreContext() {
c.loseContext.Call("restoreContext")
}
}
func (c *Context) BeforeSwapping() {
// Do nothing
}

View File

@ -400,3 +400,7 @@ func (c *Context) Flush() {
gl := c.gl
gl.Flush()
}
func (c *Context) BeforeSwapping() {
// Do nothing
}

View File

@ -32,7 +32,6 @@ import (
"github.com/hajimehoshi/ebiten/internal/hooks"
"github.com/hajimehoshi/ebiten/internal/input"
"github.com/hajimehoshi/ebiten/internal/mainthread"
"github.com/hajimehoshi/ebiten/internal/opengl"
)
type userInterface struct {
@ -649,10 +648,6 @@ func (u *userInterface) loop(g GraphicsContext) error {
vsync := u.vsync
u.m.Unlock()
// The bound framebuffer must be the original screen framebuffer
// before swapping buffers.
opengl.GetContext().BeforeSwapping()
_ = mainthread.Run(func() error {
if !vsync {
u.swapBuffers()