mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
thread: Rename Run -> Call
This commit is contained in:
parent
15a5896efd
commit
85dcafe176
@ -317,7 +317,7 @@ func (d *Driver) SetThread(thread *thread.Thread) {
|
||||
}
|
||||
|
||||
func (d *Driver) Begin() {
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
// NSAutoreleasePool is required to release drawable correctly (#847).
|
||||
// https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/MTLBestPracticesGuide/Drawables.html
|
||||
d.pool = C.allocAutoreleasePool()
|
||||
@ -327,7 +327,7 @@ func (d *Driver) Begin() {
|
||||
|
||||
func (d *Driver) End() {
|
||||
d.flush(false, true)
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
d.screenDrawable = ca.MetalDrawable{}
|
||||
C.releaseAutoreleasePool(d.pool)
|
||||
d.pool = nil
|
||||
@ -336,7 +336,7 @@ func (d *Driver) End() {
|
||||
}
|
||||
|
||||
func (d *Driver) SetWindow(window uintptr) {
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
// Note that [NSApp mainWindow] returns nil when the window is borderless.
|
||||
// Then the window is needed to be given.
|
||||
d.window = window
|
||||
@ -345,7 +345,7 @@ func (d *Driver) SetWindow(window uintptr) {
|
||||
}
|
||||
|
||||
func (d *Driver) SetVertices(vertices []float32, indices []uint16) {
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
if d.vb != (mtl.Buffer{}) {
|
||||
d.vb.Release()
|
||||
}
|
||||
@ -363,7 +363,7 @@ func (d *Driver) Flush() {
|
||||
}
|
||||
|
||||
func (d *Driver) flush(wait bool, present bool) {
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
if d.cb == (mtl.CommandBuffer{}) {
|
||||
return nil
|
||||
}
|
||||
@ -384,7 +384,7 @@ func (d *Driver) flush(wait bool, present bool) {
|
||||
|
||||
func (d *Driver) checkSize(width, height int) {
|
||||
m := 0
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
if d.maxImageSize == 0 {
|
||||
d.maxImageSize = 4096
|
||||
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
|
||||
@ -444,7 +444,7 @@ func (d *Driver) NewImage(width, height int) (driver.Image, error) {
|
||||
Usage: mtl.TextureUsageShaderRead,
|
||||
}
|
||||
var t mtl.Texture
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
t = d.device.MakeTexture(td)
|
||||
return nil
|
||||
})
|
||||
@ -457,7 +457,7 @@ func (d *Driver) NewImage(width, height int) (driver.Image, error) {
|
||||
}
|
||||
|
||||
func (d *Driver) NewScreenFramebufferImage(width, height int) (driver.Image, error) {
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
d.ml.SetDrawableSize(width, height)
|
||||
return nil
|
||||
})
|
||||
@ -470,7 +470,7 @@ func (d *Driver) NewScreenFramebufferImage(width, height int) (driver.Image, err
|
||||
}
|
||||
|
||||
func (d *Driver) Reset() error {
|
||||
if err := d.t.Run(func() error {
|
||||
if err := d.t.Call(func() error {
|
||||
if d.cq != (mtl.CommandQueue{}) {
|
||||
d.cq.Release()
|
||||
d.cq = mtl.CommandQueue{}
|
||||
@ -612,7 +612,7 @@ func (d *Driver) Reset() error {
|
||||
}
|
||||
|
||||
func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter, address graphics.Address) error {
|
||||
if err := d.t.Run(func() error {
|
||||
if err := d.t.Call(func() error {
|
||||
// NSView can be changed anytime (probably). Set this everyframe.
|
||||
setView(d.window, d.ml)
|
||||
|
||||
@ -696,7 +696,7 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode
|
||||
}
|
||||
|
||||
func (d *Driver) ResetSource() {
|
||||
d.t.Run(func() error {
|
||||
d.t.Call(func() error {
|
||||
d.src = nil
|
||||
return nil
|
||||
})
|
||||
@ -738,7 +738,7 @@ func (i *Image) viewportSize() (int, int) {
|
||||
}
|
||||
|
||||
func (i *Image) Dispose() {
|
||||
i.driver.t.Run(func() error {
|
||||
i.driver.t.Call(func() error {
|
||||
if i.texture != (mtl.Texture{}) {
|
||||
i.texture.Release()
|
||||
i.texture = mtl.Texture{}
|
||||
@ -755,7 +755,7 @@ func (i *Image) IsInvalidated() bool {
|
||||
}
|
||||
|
||||
func (i *Image) syncTexture() {
|
||||
i.driver.t.Run(func() error {
|
||||
i.driver.t.Call(func() error {
|
||||
if i.driver.cb != (mtl.CommandBuffer{}) {
|
||||
panic("metal: command buffer must be empty at syncTexture: flush is not called yet?")
|
||||
}
|
||||
@ -775,7 +775,7 @@ func (i *Image) Pixels() ([]byte, error) {
|
||||
i.syncTexture()
|
||||
|
||||
b := make([]byte, 4*i.width*i.height)
|
||||
i.driver.t.Run(func() error {
|
||||
i.driver.t.Call(func() error {
|
||||
i.texture.GetBytes(&b[0], uintptr(4*i.width), mtl.Region{
|
||||
Size: mtl.Size{i.width, i.height, 1},
|
||||
}, 0)
|
||||
@ -785,14 +785,14 @@ func (i *Image) Pixels() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (i *Image) SetAsDestination() {
|
||||
i.driver.t.Run(func() error {
|
||||
i.driver.t.Call(func() error {
|
||||
i.driver.dst = i
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (i *Image) SetAsSource() {
|
||||
i.driver.t.Run(func() error {
|
||||
i.driver.t.Call(func() error {
|
||||
i.driver.src = i
|
||||
return nil
|
||||
})
|
||||
@ -801,7 +801,7 @@ func (i *Image) SetAsSource() {
|
||||
func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
|
||||
i.driver.flush(true, false)
|
||||
|
||||
i.driver.t.Run(func() error {
|
||||
i.driver.t.Call(func() error {
|
||||
i.texture.ReplaceRegion(mtl.Region{
|
||||
Origin: mtl.Origin{x, y, 0},
|
||||
Size: mtl.Size{width, height, 1},
|
||||
|
@ -75,7 +75,7 @@ type contextImpl struct {
|
||||
}
|
||||
|
||||
func (c *context) reset() error {
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
if c.init {
|
||||
return nil
|
||||
}
|
||||
@ -94,12 +94,12 @@ func (c *context) reset() error {
|
||||
c.lastViewportWidth = 0
|
||||
c.lastViewportHeight = 0
|
||||
c.lastCompositeMode = graphics.CompositeModeUnknown
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.Enable(gl.BLEND)
|
||||
return nil
|
||||
})
|
||||
c.blendFunc(graphics.CompositeModeSourceOver)
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
f := int32(0)
|
||||
gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f)
|
||||
c.screenFramebuffer = framebufferNative(f)
|
||||
@ -109,7 +109,7 @@ func (c *context) reset() error {
|
||||
}
|
||||
|
||||
func (c *context) blendFunc(mode graphics.CompositeMode) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
if c.lastCompositeMode == mode {
|
||||
return nil
|
||||
}
|
||||
@ -123,7 +123,7 @@ func (c *context) blendFunc(mode graphics.CompositeMode) {
|
||||
|
||||
func (c *context) newTexture(width, height int) (textureNative, error) {
|
||||
var texture textureNative
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
var t uint32
|
||||
gl.GenTextures(1, &t)
|
||||
// TODO: Use gl.IsTexture
|
||||
@ -137,7 +137,7 @@ func (c *context) newTexture(width, height int) (textureNative, error) {
|
||||
return 0, err
|
||||
}
|
||||
c.bindTexture(texture)
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
|
||||
@ -151,7 +151,7 @@ func (c *context) newTexture(width, height int) (textureNative, error) {
|
||||
}
|
||||
|
||||
func (c *context) bindFramebufferImpl(f framebufferNative) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BindFramebufferEXT(gl.FRAMEBUFFER, uint32(f))
|
||||
return nil
|
||||
})
|
||||
@ -159,12 +159,12 @@ func (c *context) bindFramebufferImpl(f framebufferNative) {
|
||||
|
||||
func (c *context) framebufferPixels(f *framebuffer, width, height int) ([]byte, error) {
|
||||
var pixels []byte
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.Flush()
|
||||
return nil
|
||||
})
|
||||
c.bindFramebuffer(f.native)
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
pixels = make([]byte, 4*width*height)
|
||||
gl.ReadPixels(0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(pixels))
|
||||
return nil
|
||||
@ -175,14 +175,14 @@ func (c *context) framebufferPixels(f *framebuffer, width, height int) ([]byte,
|
||||
}
|
||||
|
||||
func (c *context) bindTextureImpl(t textureNative) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BindTexture(gl.TEXTURE_2D, uint32(t))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) deleteTexture(t textureNative) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
tt := uint32(t)
|
||||
if !gl.IsTexture(tt) {
|
||||
return nil
|
||||
@ -197,7 +197,7 @@ func (c *context) deleteTexture(t textureNative) {
|
||||
|
||||
func (c *context) isTexture(t textureNative) bool {
|
||||
r := false
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
r = gl.IsTexture(uint32(t))
|
||||
return nil
|
||||
})
|
||||
@ -206,7 +206,7 @@ func (c *context) isTexture(t textureNative) bool {
|
||||
|
||||
func (c *context) texSubImage2D(t textureNative, p []byte, x, y, width, height int) {
|
||||
c.bindTexture(t)
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.TexSubImage2D(gl.TEXTURE_2D, 0, int32(x), int32(y), int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(p))
|
||||
return nil
|
||||
})
|
||||
@ -215,7 +215,7 @@ func (c *context) texSubImage2D(t textureNative, p []byte, x, y, width, height i
|
||||
func (c *context) newFramebuffer(texture textureNative) (framebufferNative, error) {
|
||||
var framebuffer framebufferNative
|
||||
var f uint32
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
gl.GenFramebuffersEXT(1, &f)
|
||||
// TODO: Use gl.IsFramebuffer
|
||||
if f <= 0 {
|
||||
@ -226,7 +226,7 @@ func (c *context) newFramebuffer(texture textureNative) (framebufferNative, erro
|
||||
return 0, err
|
||||
}
|
||||
c.bindFramebuffer(framebufferNative(f))
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
gl.FramebufferTexture2DEXT(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0)
|
||||
s := gl.CheckFramebufferStatusEXT(gl.FRAMEBUFFER)
|
||||
if s != gl.FRAMEBUFFER_COMPLETE {
|
||||
@ -247,14 +247,14 @@ func (c *context) newFramebuffer(texture textureNative) (framebufferNative, erro
|
||||
}
|
||||
|
||||
func (c *context) setViewportImpl(width, height int) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.Viewport(0, 0, int32(width), int32(height))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) deleteFramebuffer(f framebufferNative) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
ff := uint32(f)
|
||||
if !gl.IsFramebufferEXT(ff) {
|
||||
return nil
|
||||
@ -271,7 +271,7 @@ func (c *context) deleteFramebuffer(f framebufferNative) {
|
||||
|
||||
func (c *context) newShader(shaderType shaderType, source string) (shader, error) {
|
||||
var sh shader
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
s := gl.CreateShader(uint32(shaderType))
|
||||
if s == 0 {
|
||||
return fmt.Errorf("opengl: glCreateShader failed: shader type: %d", shaderType)
|
||||
@ -301,7 +301,7 @@ func (c *context) newShader(shaderType shaderType, source string) (shader, error
|
||||
}
|
||||
|
||||
func (c *context) deleteShader(s shader) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.DeleteShader(uint32(s))
|
||||
return nil
|
||||
})
|
||||
@ -309,7 +309,7 @@ func (c *context) deleteShader(s shader) {
|
||||
|
||||
func (c *context) newProgram(shaders []shader, attributes []string) (program, error) {
|
||||
var pr program
|
||||
if err := c.t.Run(func() error {
|
||||
if err := c.t.Call(func() error {
|
||||
p := gl.CreateProgram()
|
||||
if p == 0 {
|
||||
return errors.New("opengl: glCreateProgram failed")
|
||||
@ -340,14 +340,14 @@ func (c *context) newProgram(shaders []shader, attributes []string) (program, er
|
||||
}
|
||||
|
||||
func (c *context) useProgram(p program) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.UseProgram(uint32(p))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) deleteProgram(p program) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
if !gl.IsProgram(uint32(p)) {
|
||||
return nil
|
||||
}
|
||||
@ -367,7 +367,7 @@ func (c *context) getUniformLocationImpl(p program, location string) uniformLoca
|
||||
}
|
||||
|
||||
func (c *context) uniformInt(p program, location string, v int) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
l := int32(c.locationCache.GetUniformLocation(c, p, location))
|
||||
gl.Uniform1i(l, int32(v))
|
||||
return nil
|
||||
@ -375,7 +375,7 @@ func (c *context) uniformInt(p program, location string, v int) {
|
||||
}
|
||||
|
||||
func (c *context) uniformFloat(p program, location string, v float32) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
l := int32(c.locationCache.GetUniformLocation(c, p, location))
|
||||
gl.Uniform1f(l, v)
|
||||
return nil
|
||||
@ -383,7 +383,7 @@ func (c *context) uniformFloat(p program, location string, v float32) {
|
||||
}
|
||||
|
||||
func (c *context) uniformFloats(p program, location string, v []float32) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
l := int32(c.locationCache.GetUniformLocation(c, p, location))
|
||||
switch len(v) {
|
||||
case 2:
|
||||
@ -400,21 +400,21 @@ func (c *context) uniformFloats(p program, location string, v []float32) {
|
||||
}
|
||||
|
||||
func (c *context) vertexAttribPointer(p program, index int, size int, dataType dataType, stride int, offset int) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.VertexAttribPointer(uint32(index), int32(size), uint32(dataType), false, int32(stride), gl.PtrOffset(offset))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) enableVertexAttribArray(p program, index int) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.EnableVertexAttribArray(uint32(index))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) disableVertexAttribArray(p program, index int) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.DisableVertexAttribArray(uint32(index))
|
||||
return nil
|
||||
})
|
||||
@ -422,7 +422,7 @@ func (c *context) disableVertexAttribArray(p program, index int) {
|
||||
|
||||
func (c *context) newArrayBuffer(size int) buffer {
|
||||
var bf buffer
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
var b uint32
|
||||
gl.GenBuffers(1, &b)
|
||||
gl.BindBuffer(uint32(arrayBuffer), b)
|
||||
@ -435,7 +435,7 @@ func (c *context) newArrayBuffer(size int) buffer {
|
||||
|
||||
func (c *context) newElementArrayBuffer(size int) buffer {
|
||||
var bf buffer
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
var b uint32
|
||||
gl.GenBuffers(1, &b)
|
||||
gl.BindBuffer(uint32(elementArrayBuffer), b)
|
||||
@ -447,28 +447,28 @@ func (c *context) newElementArrayBuffer(size int) buffer {
|
||||
}
|
||||
|
||||
func (c *context) bindBuffer(bufferType bufferType, b buffer) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BindBuffer(uint32(bufferType), uint32(b))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) arrayBufferSubData(data []float32) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BufferSubData(uint32(arrayBuffer), 0, len(data)*4, gl.Ptr(data))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) elementArrayBufferSubData(data []uint16) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.BufferSubData(uint32(elementArrayBuffer), 0, len(data)*2, gl.Ptr(data))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (c *context) deleteBuffer(b buffer) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
bb := uint32(b)
|
||||
gl.DeleteBuffers(1, &bb)
|
||||
return nil
|
||||
@ -476,7 +476,7 @@ func (c *context) deleteBuffer(b buffer) {
|
||||
}
|
||||
|
||||
func (c *context) drawElements(len int, offsetInBytes int) {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.DrawElements(gl.TRIANGLES, int32(len), gl.UNSIGNED_SHORT, gl.PtrOffset(offsetInBytes))
|
||||
return nil
|
||||
})
|
||||
@ -484,7 +484,7 @@ func (c *context) drawElements(len int, offsetInBytes int) {
|
||||
|
||||
func (c *context) maxTextureSizeImpl() int {
|
||||
size := 0
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
s := int32(0)
|
||||
gl.GetIntegerv(gl.MAX_TEXTURE_SIZE, &s)
|
||||
size = int(s)
|
||||
@ -494,7 +494,7 @@ func (c *context) maxTextureSizeImpl() int {
|
||||
}
|
||||
|
||||
func (c *context) flush() {
|
||||
_ = c.t.Run(func() error {
|
||||
_ = c.t.Call(func() error {
|
||||
gl.Flush()
|
||||
return nil
|
||||
})
|
||||
|
@ -49,10 +49,10 @@ func (t *Thread) Loop(ch <-chan error) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Run calls f on the thread.
|
||||
// Call calls f on the thread.
|
||||
//
|
||||
// Do not call this from the same thread. This would block forever.
|
||||
func (t *Thread) Run(f func() error) error {
|
||||
func (t *Thread) Call(f func() error) error {
|
||||
if atomic.LoadInt32(&t.started) == 0 {
|
||||
panic("thread: the thread loop is not started yet")
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func (u *UserInterface) ScreenSizeInFullscreen() (int, int) {
|
||||
|
||||
var v *glfw.VidMode
|
||||
s := 0.0
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
v = u.currentMonitor().GetVideoMode()
|
||||
s = u.glfwScale()
|
||||
return nil
|
||||
@ -290,7 +290,7 @@ func (u *UserInterface) SetScreenSize(width, height int) {
|
||||
if !u.isRunning() {
|
||||
panic("ui: Run is not called yet")
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
// TODO: What if the window is maximized? (#320)
|
||||
u.setScreenSize(width, height, u.scale, u.isFullscreen(), u.vsync)
|
||||
return nil
|
||||
@ -301,7 +301,7 @@ func (u *UserInterface) SetScreenScale(scale float64) {
|
||||
if !u.isRunning() {
|
||||
panic("ui: Run is not called yet")
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
// TODO: What if the window is maximized? (#320)
|
||||
u.setScreenSize(u.width, u.height, scale, u.isFullscreen(), u.vsync)
|
||||
return nil
|
||||
@ -313,7 +313,7 @@ func (u *UserInterface) ScreenScale() float64 {
|
||||
return 0
|
||||
}
|
||||
s := 0.0
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
s = u.scale
|
||||
return nil
|
||||
})
|
||||
@ -333,7 +333,7 @@ func (u *UserInterface) IsFullscreen() bool {
|
||||
return u.isInitFullscreen()
|
||||
}
|
||||
b := false
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
b = u.isFullscreen()
|
||||
return nil
|
||||
})
|
||||
@ -345,7 +345,7 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
||||
u.setInitFullscreen(fullscreen)
|
||||
return
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
u.setScreenSize(u.width, u.height, u.scale, fullscreen, u.vsync)
|
||||
return nil
|
||||
})
|
||||
@ -370,7 +370,7 @@ func (u *UserInterface) SetVsyncEnabled(enabled bool) {
|
||||
u.m.Unlock()
|
||||
return
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
u.setScreenSize(u.width, u.height, u.scale, u.isFullscreen(), enabled)
|
||||
return nil
|
||||
})
|
||||
@ -387,7 +387,7 @@ func (u *UserInterface) SetWindowTitle(title string) {
|
||||
if !u.isRunning() {
|
||||
return
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
u.window.SetTitle(title)
|
||||
return nil
|
||||
})
|
||||
@ -398,7 +398,7 @@ func (u *UserInterface) SetWindowIcon(iconImages []image.Image) {
|
||||
u.setInitIconImages(iconImages)
|
||||
return
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
u.window.SetIcon(iconImages)
|
||||
return nil
|
||||
})
|
||||
@ -414,7 +414,7 @@ func (u *UserInterface) ScreenPadding() (x0, y0, x1, y1 float64) {
|
||||
}
|
||||
// The window width can be bigger than the game screen width (#444).
|
||||
ox := 0.0
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
ox = (float64(u.windowWidth)*u.actualScreenScale() - float64(u.width)*u.actualScreenScale()) / 2
|
||||
return nil
|
||||
})
|
||||
@ -427,7 +427,7 @@ func (u *UserInterface) ScreenPadding() (x0, y0, x1, y1 float64) {
|
||||
gs := 0.0
|
||||
vw := 0.0
|
||||
vh := 0.0
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
m := u.window.GetMonitor()
|
||||
d = devicescale.GetAt(m.GetPos())
|
||||
sx = float64(u.width) * u.actualScreenScale()
|
||||
@ -452,7 +452,7 @@ func (u *UserInterface) adjustPosition(x, y int) (int, int) {
|
||||
}
|
||||
ox, oy, _, _ := u.ScreenPadding()
|
||||
s := 0.0
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
s = u.actualScreenScale()
|
||||
return nil
|
||||
})
|
||||
@ -464,7 +464,7 @@ func (u *UserInterface) IsCursorVisible() bool {
|
||||
return u.isInitCursorVisible()
|
||||
}
|
||||
v := false
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
v = u.window.GetInputMode(glfw.CursorMode) == glfw.CursorNormal
|
||||
return nil
|
||||
})
|
||||
@ -476,7 +476,7 @@ func (u *UserInterface) SetCursorVisible(visible bool) {
|
||||
u.setInitCursorVisible(visible)
|
||||
return
|
||||
}
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
c := glfw.CursorNormal
|
||||
if !visible {
|
||||
c = glfw.CursorHidden
|
||||
@ -491,7 +491,7 @@ func (u *UserInterface) IsWindowDecorated() bool {
|
||||
return u.isInitWindowDecorated()
|
||||
}
|
||||
v := false
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
v = u.window.GetAttrib(glfw.Decorated) == glfw.True
|
||||
return nil
|
||||
})
|
||||
@ -509,7 +509,7 @@ func (u *UserInterface) SetWindowDecorated(decorated bool) {
|
||||
// TODO: Now SetAttrib doesn't exist on GLFW 3.2. Revisit later (#556).
|
||||
// If SetAttrib exists, the implementation would be:
|
||||
//
|
||||
// _ = u.t.Run(func() error {
|
||||
// _ = u.t.Call(func() error {
|
||||
// v := glfw.False
|
||||
// if decorated {
|
||||
// v = glfw.True
|
||||
@ -524,7 +524,7 @@ func (u *UserInterface) IsWindowResizable() bool {
|
||||
return u.isInitWindowResizable()
|
||||
}
|
||||
v := false
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
v = u.window.GetAttrib(glfw.Resizable) == glfw.True
|
||||
return nil
|
||||
})
|
||||
@ -548,7 +548,7 @@ func (u *UserInterface) DeviceScaleFactor() float64 {
|
||||
return devicescale.GetAt(u.initMonitor.GetPos())
|
||||
}
|
||||
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
m := u.currentMonitor()
|
||||
f = devicescale.GetAt(m.GetPos())
|
||||
return nil
|
||||
@ -584,7 +584,7 @@ func (u *UserInterface) RunWithoutMainLoop(width, height int, scale float64, tit
|
||||
}
|
||||
|
||||
func (u *UserInterface) run(width, height int, scale float64, title string, context driver.UIContext, graphics driver.Graphics) error {
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
u.graphics = graphics
|
||||
u.graphics.SetThread(u.t)
|
||||
|
||||
@ -686,7 +686,7 @@ func (u *UserInterface) run(width, height int, scale float64, title string, cont
|
||||
})
|
||||
|
||||
var w uintptr
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
w = u.nativeWindow()
|
||||
return nil
|
||||
})
|
||||
@ -732,7 +732,7 @@ func (u *UserInterface) updateSize(context driver.UIContext) {
|
||||
actualScale := 0.0
|
||||
sizeChanged := false
|
||||
// TODO: Is it possible to reduce 'runOnMainThread' calls?
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
actualScale = u.actualScreenScale()
|
||||
if u.lastActualScale != actualScale {
|
||||
u.forceSetScreenSize(u.width, u.height, u.scale, u.isFullscreen(), u.vsync)
|
||||
@ -754,7 +754,7 @@ func (u *UserInterface) updateSize(context driver.UIContext) {
|
||||
|
||||
func (u *UserInterface) update(context driver.UIContext) error {
|
||||
shouldClose := false
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
shouldClose = u.window.ShouldClose()
|
||||
return nil
|
||||
})
|
||||
@ -762,7 +762,7 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
||||
return driver.RegularTermination
|
||||
}
|
||||
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
if u.isInitFullscreen() {
|
||||
u.setScreenSize(u.width, u.height, u.scale, true, u.vsync)
|
||||
u.setInitFullscreen(false)
|
||||
@ -773,7 +773,7 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
||||
// This call is needed for initialization.
|
||||
u.updateSize(context)
|
||||
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
glfw.PollEvents()
|
||||
|
||||
u.input.update(u.window, u.getScale()*u.glfwScale())
|
||||
@ -799,7 +799,7 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
||||
}
|
||||
|
||||
// Update the screen size when the window is resizable.
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
w, h := u.reqWidth, u.reqHeight
|
||||
if w != 0 || h != 0 {
|
||||
u.setScreenSize(w, h, u.scale, u.isFullscreen(), u.vsync)
|
||||
@ -813,7 +813,7 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
||||
|
||||
func (u *UserInterface) loop(context driver.UIContext) error {
|
||||
defer func() {
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
glfw.Terminate()
|
||||
return nil
|
||||
})
|
||||
@ -827,7 +827,7 @@ func (u *UserInterface) loop(context driver.UIContext) error {
|
||||
vsync := u.vsync
|
||||
u.m.Unlock()
|
||||
|
||||
_ = u.t.Run(func() error {
|
||||
_ = u.t.Call(func() error {
|
||||
if !vsync {
|
||||
u.swapBuffers()
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user