我刚刚使用 glfw 创建了一个窗口并在 macOS 上运行。问题是:如果我拖动窗口并四处移动,窗口的移动最初是超级滞后的,但后来变得平滑。Linux (Ubuntu) 上不会出现此问题。为什么以及如何解决它?
系统:macOS 10.15.7 (19H2) 代码:
package main
import (
"fmt"
"runtime"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
)
func init() {
runtime.LockOSThread()
}
func main() {
err := glfw.Init()
if err != nil {
panic(fmt.Errorf("failed to initialize GLFW: %w", err))
}
defer glfw.Terminate()
glfw.WindowHint(glfw.Resizable, glfw.False)
glfw.WindowHint(glfw.ContextVersionMajor, 4)
glfw.WindowHint(glfw.ContextVersionMinor, 1)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
win, err := glfw.CreateWindow(800, 600, "glfw", nil, nil)
if err != nil {
panic(err)
}
defer win.Destroy()
win.MakeContextCurrent()
if err := gl.Init(); err != nil {
panic(err)
}
win.SetTitle(fmt.Sprintf("%s", gl.GoStr(gl.GetString(gl.VERSION))))
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
for !win.ShouldClose() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
win.SwapBuffers()
glfw.PollEvents()
}
}
拉丁的传说
相关分类