internal/ui: refactoring: remove globalState

This commit is contained in:
Hajime Hoshi 2023-10-15 15:50:39 +09:00
parent a16a03c9db
commit 83a4133577
14 changed files with 123 additions and 160 deletions

View File

@ -96,7 +96,7 @@ func (g *gameForUI) NewOffscreenImage(width, height int) *ui.Image {
// An image on an atlas is surrounded by a transparent edge,
// and the shader program unexpectedly picks the pixel on the edges.
imageType := atlas.ImageTypeUnmanaged
if ui.IsScreenClearedEveryFrame() {
if ui.Get().IsScreenClearedEveryFrame() {
// A violatile image is also always isolated.
imageType = atlas.ImageTypeVolatile
}

View File

@ -66,5 +66,5 @@ type DebugInfo struct {
// ReadDebugInfo writes debug info (e.g. current graphics library) into a provided struct.
func ReadDebugInfo(d *DebugInfo) {
d.GraphicsLibrary = GraphicsLibrary(ui.GetGraphicsLibrary())
d.GraphicsLibrary = GraphicsLibrary(ui.Get().GetGraphicsLibrary())
}

View File

@ -141,7 +141,7 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
}
// Catch the error that happened at (*Image).At.
if err := theGlobalState.error(); err != nil {
if err := ui.error(); err != nil {
return err
}
}
@ -153,7 +153,7 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
}
// Draw the game.
if err := c.drawGame(graphicsDriver, forceDraw); err != nil {
if err := c.drawGame(graphicsDriver, ui, forceDraw); err != nil {
return err
}
@ -168,8 +168,8 @@ func (c *context) newOffscreenImage(w, h int) *Image {
return img
}
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, forceDraw bool) error {
if (c.offscreen.imageType == atlas.ImageTypeVolatile) != theGlobalState.isScreenClearedEveryFrame() {
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, ui *UserInterface, forceDraw bool) error {
if (c.offscreen.imageType == atlas.ImageTypeVolatile) != ui.IsScreenClearedEveryFrame() {
w, h := c.offscreen.width, c.offscreen.height
c.offscreen.MarkDisposed()
c.offscreen = c.newOffscreenImage(w, h)
@ -181,7 +181,7 @@ func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, forceDraw boo
// Even though updateCount == 0, the offscreen is cleared and Draw is called.
// Draw should not update the game state and then the screen should not be updated without Update, but
// users might want to process something at Draw with the time intervals of FPS.
if theGlobalState.isScreenClearedEveryFrame() {
if ui.IsScreenClearedEveryFrame() {
c.offscreen.clear()
}

View File

@ -1,82 +0,0 @@
// Copyright 2022 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ui
import (
"sync"
"sync/atomic"
)
// TODO: Move theGlobalState to UserInterface's member
var theGlobalState = globalState{
isScreenClearedEveryFrame_: 1,
graphicsLibrary_: int32(GraphicsLibraryUnknown),
}
// globalState represents a global state in this package.
// This is available even before the game loop starts.
type globalState struct {
err_ error
errM sync.Mutex
isScreenClearedEveryFrame_ int32
graphicsLibrary_ int32
}
func (g *globalState) error() error {
g.errM.Lock()
defer g.errM.Unlock()
return g.err_
}
func (g *globalState) setError(err error) {
g.errM.Lock()
defer g.errM.Unlock()
if g.err_ == nil {
g.err_ = err
}
}
func (g *globalState) isScreenClearedEveryFrame() bool {
return atomic.LoadInt32(&g.isScreenClearedEveryFrame_) != 0
}
func (g *globalState) setScreenClearedEveryFrame(cleared bool) {
v := int32(0)
if cleared {
v = 1
}
atomic.StoreInt32(&g.isScreenClearedEveryFrame_, v)
}
func (g *globalState) setGraphicsLibrary(library GraphicsLibrary) {
atomic.StoreInt32(&g.graphicsLibrary_, int32(library))
}
func (g *globalState) graphicsLibrary() GraphicsLibrary {
return GraphicsLibrary(atomic.LoadInt32(&g.graphicsLibrary_))
}
func IsScreenClearedEveryFrame() bool {
return theGlobalState.isScreenClearedEveryFrame()
}
func SetScreenClearedEveryFrame(cleared bool) {
theGlobalState.setScreenClearedEveryFrame(cleared)
}
func GetGraphicsLibrary() GraphicsLibrary {
return theGlobalState.graphicsLibrary()
}

View File

@ -149,7 +149,7 @@ func (i *Image) WritePixels(pix []byte, region image.Rectangle) {
func (i *Image) ReadPixels(pixels []byte, region image.Rectangle) {
// Check the error existence and avoid unnecessary calls.
if theGlobalState.error() != nil {
if i.ui.error() != nil {
return
}
@ -170,7 +170,7 @@ func (i *Image) ReadPixels(pixels []byte, region image.Rectangle) {
if panicOnErrorOnReadingPixels {
panic(err)
}
theGlobalState.setError(err)
i.ui.setError(err)
}
}

View File

@ -139,7 +139,7 @@ func (u *UserInterface) KeyName(key Key) string {
}
n, err := glfw.GetKeyName(gk, 0)
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
name = n

View File

@ -17,6 +17,8 @@ package ui
import (
"errors"
"image"
"sync"
"sync/atomic"
"github.com/hajimehoshi/ebiten/v2/internal/atlas"
"github.com/hajimehoshi/ebiten/v2/internal/mipmap"
@ -67,6 +69,12 @@ const (
)
type UserInterface struct {
err error
errM sync.Mutex
isScreenClearedEveryFrame int32
graphicsLibrary int32
whiteImage *Image
userInterfaceImpl
@ -91,7 +99,10 @@ func Get() *UserInterface {
// newUserInterface must be called from the main thread.
func newUserInterface() (*UserInterface, error) {
u := &UserInterface{}
u := &UserInterface{
isScreenClearedEveryFrame: 1,
graphicsLibrary: int32(GraphicsLibraryUnknown),
}
u.whiteImage = u.NewImage(3, 3, atlas.ImageTypeRegular)
pix := make([]byte, 4*u.whiteImage.width*u.whiteImage.height)
@ -131,3 +142,37 @@ type RunOptions struct {
func InitialWindowPosition(mw, mh, ww, wh int) (x, y int) {
return (mw - ww) / 2, (mh - wh) / 3
}
func (u *UserInterface) error() error {
u.errM.Lock()
defer u.errM.Unlock()
return u.err
}
func (u *UserInterface) setError(err error) {
u.errM.Lock()
defer u.errM.Unlock()
if u.err == nil {
u.err = err
}
}
func (u *UserInterface) IsScreenClearedEveryFrame() bool {
return atomic.LoadInt32(&u.isScreenClearedEveryFrame) != 0
}
func (u *UserInterface) SetScreenClearedEveryFrame(cleared bool) {
v := int32(0)
if cleared {
v = 1
}
atomic.StoreInt32(&u.isScreenClearedEveryFrame, v)
}
func (u *UserInterface) setGraphicsLibrary(library GraphicsLibrary) {
atomic.StoreInt32(&u.graphicsLibrary, int32(library))
}
func (u *UserInterface) GetGraphicsLibrary() GraphicsLibrary {
return GraphicsLibrary(atomic.LoadInt32(&u.graphicsLibrary))
}

View File

@ -122,7 +122,7 @@ func (u *UserInterface) initializePlatform() error {
Cmd: sel_windowWillEnterFullScreen,
Fn: func(id objc.ID, cmd objc.SEL, notification objc.ID) {
if err := u.setOrigWindowPosWithCurrentPos(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
pushResizableState(id, cocoa.NSNotification{ID: notification}.Object())
@ -142,7 +142,7 @@ func (u *UserInterface) initializePlatform() error {
// In this case, the window size limitation is disabled temporarily.
// When exiting from fullscreen, reset the window size limitation.
if err := u.updateWindowSizeLimits(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
},

View File

@ -153,7 +153,7 @@ func (u *UserInterface) init() error {
}
if _, err := glfw.SetMonitorCallback(func(monitor *glfw.Monitor, event glfw.PeripheralEvent) {
if err := theMonitors.update(); err != nil {
theGlobalState.setError(err)
u.setError(err)
}
}); err != nil {
return err
@ -278,7 +278,7 @@ func (u *UserInterface) Monitor() *Monitor {
}
m, err := u.currentMonitor()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
monitor = m
@ -611,7 +611,7 @@ func (u *UserInterface) ScreenSizeInFullscreen() (int, int) {
}
m, err := u.currentMonitor()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
if m == nil {
@ -658,7 +658,7 @@ func (u *UserInterface) IsFullscreen() bool {
}
b, err := u.isFullscreen()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
fullscreen = b
@ -685,14 +685,14 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
}
f, err := u.isFullscreen()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
if f == fullscreen {
return
}
if err := u.setFullscreen(fullscreen); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
})
@ -710,7 +710,7 @@ func (u *UserInterface) IsFocused() bool {
}
a, err := u.window.GetAttrib(glfw.Focused)
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
focused = a == glfw.True
@ -752,7 +752,7 @@ func (u *UserInterface) SetFPSMode(mode FPSModeType) {
return
}
if err := u.setFPSMode(mode); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
})
@ -765,7 +765,7 @@ func (u *UserInterface) ScheduleFrame() {
// As the main thread can be blocked, do not check the current FPS mode.
// PostEmptyEvent is concurrent safe.
if err := glfw.PostEmptyEvent(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}
@ -785,7 +785,7 @@ func (u *UserInterface) CursorMode() CursorMode {
}
m, err := u.window.GetInputMode(glfw.CursorMode)
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
mode = m
@ -818,12 +818,12 @@ func (u *UserInterface) SetCursorMode(mode CursorMode) {
return
}
if err := u.window.SetInputMode(glfw.CursorMode, driverCursorModeToGLFWCursorMode(mode)); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
if mode == CursorModeVisible {
if err := u.window.SetCursor(glfwSystemCursors[u.getCursorShape()]); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}
@ -851,7 +851,7 @@ func (u *UserInterface) SetCursorShape(shape CursorShape) {
return
}
if err := u.window.SetCursor(glfwSystemCursors[shape]); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
})
@ -872,7 +872,7 @@ func (u *UserInterface) DeviceScaleFactor() float64 {
}
m, err := u.currentMonitor()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
f = m.deviceScaleFactor()
@ -969,11 +969,11 @@ func (u *UserInterface) registerWindowCloseCallback() error {
return
}
if err := u.window.Focus(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
if err := u.window.SetShouldClose(false); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}
@ -996,7 +996,7 @@ func (u *UserInterface) registerWindowFramebufferSizeCallback() error {
u.defaultFramebufferSizeCallback = func(_ *glfw.Window, w, h int) {
f, err := u.isFullscreen()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
if f {
@ -1004,7 +1004,7 @@ func (u *UserInterface) registerWindowFramebufferSizeCallback() error {
}
a, err := u.window.GetAttrib(glfw.Iconified)
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
if a == glfw.True {
@ -1015,14 +1015,14 @@ func (u *UserInterface) registerWindowFramebufferSizeCallback() error {
// See also the implementation in uiContext.updateOffscreen.
m, err := u.currentMonitor()
if err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
s := m.deviceScaleFactor()
ww := int(float64(w) / s)
wh := int(float64(h) / s)
if err := u.setWindowSizeInDIP(ww, wh, false); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}
@ -1134,7 +1134,7 @@ func (u *UserInterface) initOnMainThread(options *RunOptions) error {
return err
}
u.graphicsDriver = g
theGlobalState.setGraphicsLibrary(lib)
u.setGraphicsLibrary(lib)
u.graphicsDriver.SetTransparent(options.ScreenTransparent)
if u.graphicsDriver.IsGL() {
@ -1322,7 +1322,7 @@ func (u *UserInterface) setFPSMode(fpsMode FPSModeType) error {
// update must be called from the main thread.
func (u *UserInterface) update() (float64, float64, error) {
if err := theGlobalState.error(); err != nil {
if err := u.error(); err != nil {
return 0, 0, err
}
@ -1429,7 +1429,7 @@ func (u *UserInterface) loopGame() (ferr error) {
u.renderThread.Call(func() {
if u.graphicsDriver.IsGL() {
if err := u.window.MakeContextCurrent(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}
@ -1483,13 +1483,13 @@ func (u *UserInterface) updateGame() error {
// Call updateVsync even though fpsMode is not updated.
// When toggling to fullscreen, vsync state might be reset unexpectedly (#1787).
if err := u.updateVsyncOnRenderThread(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
// This works only for OpenGL.
if err := u.swapBuffersOnRenderThread(); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}); err != nil {
@ -1557,7 +1557,7 @@ func (u *UserInterface) updateIconIfNeeded() error {
}
// Catch a possible error at 'At' (#2647).
if err := theGlobalState.error(); err != nil {
if err := u.error(); err != nil {
return err
}

View File

@ -395,7 +395,7 @@ func (u *UserInterface) loop(game Game) <-chan error {
var cf js.Func
f := func() {
if err := theGlobalState.error(); err != nil {
if err := u.error(); err != nil {
errCh <- err
return
}
@ -572,7 +572,7 @@ func (u *UserInterface) setWindowEventHandlers(v js.Value) {
// See https://pkg.go.dev/syscall/js#FuncOf.
go func() {
if err := u.updateImpl(true); err != nil {
theGlobalState.setError(err)
u.setError(err)
return
}
}()
@ -589,7 +589,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -598,7 +598,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -612,7 +612,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -621,7 +621,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -630,7 +630,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -639,7 +639,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -653,7 +653,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -662,7 +662,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -671,7 +671,7 @@ func (u *UserInterface) setCanvasEventHandlers(v js.Value) {
e := args[0]
e.Call("preventDefault")
if err := u.updateInputFromEvent(e); err != nil {
theGlobalState.setError(err)
u.setError(err)
return nil
}
return nil
@ -733,7 +733,7 @@ func (u *UserInterface) forceUpdateOnMinimumFPSMode() {
// See https://pkg.go.dev/syscall/js#FuncOf.
go func() {
if err := u.updateImpl(true); err != nil {
theGlobalState.setError(err)
u.setError(err)
}
}()
}
@ -755,7 +755,7 @@ func (u *UserInterface) Run(game Game, options *RunOptions) error {
return err
}
u.graphicsDriver = g
theGlobalState.setGraphicsLibrary(lib)
u.setGraphicsLibrary(lib)
if bodyStyle := document.Get("body").Get("style"); options.ScreenTransparent {
bodyStyle.Set("backgroundColor", "transparent")

View File

@ -288,7 +288,7 @@ func (u *UserInterface) run(game Game, mainloop bool, options *RunOptions) (err
return err
}
u.graphicsDriver = g
theGlobalState.setGraphicsLibrary(lib)
u.setGraphicsLibrary(lib)
close(u.graphicsDriverInitCh)
// If gomobile-build is used, wait for the outside size fixed.

View File

@ -85,7 +85,7 @@ func (u *UserInterface) Run(game Game, options *RunOptions) error {
return err
}
u.graphicsDriver = g
theGlobalState.setGraphicsLibrary(lib)
u.setGraphicsLibrary(lib)
n := C.ebitengine_Initialize()
if err := u.egl.init(n); err != nil {

View File

@ -41,7 +41,7 @@ func (w *glfwWindow) IsDecorated() bool {
}
a, err := w.ui.window.GetAttrib(glfw.Decorated)
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
v = a == glfw.True
@ -63,7 +63,7 @@ func (w *glfwWindow) SetDecorated(decorated bool) {
return
}
if err := w.ui.setWindowDecorated(decorated); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -104,7 +104,7 @@ func (w *glfwWindow) SetResizingMode(mode WindowResizingMode) {
return
}
if err := w.ui.setWindowResizingMode(mode); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -124,7 +124,7 @@ func (w *glfwWindow) IsFloating() bool {
}
a, err := w.ui.window.GetAttrib(glfw.Floating)
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
v = a == glfw.True
@ -145,7 +145,7 @@ func (w *glfwWindow) SetFloating(floating bool) {
return
}
if err := w.ui.setWindowFloating(floating); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -168,7 +168,7 @@ func (w *glfwWindow) IsMaximized() bool {
}
m, err := w.ui.isWindowMaximized()
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
v = m
@ -201,7 +201,7 @@ func (w *glfwWindow) Maximize() {
return
}
if err := w.ui.maximizeWindow(); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -218,7 +218,7 @@ func (w *glfwWindow) IsMinimized() bool {
}
a, err := w.ui.window.GetAttrib(glfw.Iconified)
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
v = a == glfw.True
@ -236,7 +236,7 @@ func (w *glfwWindow) Minimize() {
return
}
if err := w.ui.iconifyWindow(); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -258,7 +258,7 @@ func (w *glfwWindow) Restore() {
return
}
if err := w.ui.restoreWindow(); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -280,7 +280,7 @@ func (w *glfwWindow) SetMonitor(monitor *Monitor) {
return
}
if err := w.ui.setWindowMonitor(monitor); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -300,7 +300,7 @@ func (w *glfwWindow) Position() (int, int) {
}
f, err := w.ui.isFullscreen()
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
@ -310,14 +310,14 @@ func (w *glfwWindow) Position() (int, int) {
} else {
x, y, err := w.ui.window.GetPos()
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
wx, wy = x, y
}
m, err := w.ui.currentMonitor()
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
wx -= m.boundsInGLFWPixels.Min.X
@ -343,11 +343,11 @@ func (w *glfwWindow) SetPosition(x, y int) {
}
m, err := w.ui.currentMonitor()
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
if err := w.ui.setWindowPositionInDIP(x, y, m); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -388,14 +388,14 @@ func (w *glfwWindow) SetSize(width, height int) {
}
m, err := w.ui.isWindowMaximized()
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
if m && runtime.GOOS != "darwin" {
return
}
if err := w.ui.setWindowSizeInDIP(width, height, true); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -421,7 +421,7 @@ func (w *glfwWindow) SetSizeLimits(minw, minh, maxw, maxh int) {
return
}
if err := w.ui.updateWindowSizeLimits(); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -451,7 +451,7 @@ func (w *glfwWindow) SetTitle(title string) {
return
}
if err := w.ui.setWindowTitle(title); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -478,7 +478,7 @@ func (w *glfwWindow) SetMousePassthrough(enabled bool) {
return
}
if err := w.ui.setWindowMousePassthrough(enabled); err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
})
@ -498,7 +498,7 @@ func (w *glfwWindow) IsMousePassthrough() bool {
}
a, err := w.ui.window.GetAttrib(glfw.MousePassthrough)
if err != nil {
theGlobalState.setError(err)
w.ui.setError(err)
return
}
v = a == glfw.True

4
run.go
View File

@ -157,14 +157,14 @@ var (
//
// SetScreenClearedEveryFrame is concurrent-safe.
func SetScreenClearedEveryFrame(cleared bool) {
ui.SetScreenClearedEveryFrame(cleared)
ui.Get().SetScreenClearedEveryFrame(cleared)
}
// IsScreenClearedEveryFrame returns true if the frame isn't cleared at the beginning.
//
// IsScreenClearedEveryFrame is concurrent-safe.
func IsScreenClearedEveryFrame() bool {
return ui.IsScreenClearedEveryFrame()
return ui.Get().IsScreenClearedEveryFrame()
}
// SetScreenFilterEnabled enables/disables the use of the "screen" filter Ebitengine uses.