package main
import (
"runtime"
"github.com/go-gl/glfw/v3.2/glfw"
)
func init() {
// This is needed to arrange that main() runs on main thread.
// See documentation for functions that are only allowed to be called from the main thread.
runtime.LockOSThread()
}
func main() {
err := glfw.Init()
if err != nil {
panic(err)
}
defer glfw.Terminate()
window, err := glfw.CreateWindow(640, 480, "Testing", nil, nil)
if err != nil {
panic(err)
}
window.MakeContextCurrent()
for !window.ShouldClose() {
// Do OpenGL stuff.
window.SwapBuffers()
glfw.PollEvents()
}
}
这个也是网上看到的,就不赘述了,仅作备忘。
该博客展示了如何利用Go语言的glfw库初始化并创建一个640x480像素的图形窗口,包括设置窗口上下文、交换缓冲区和处理窗口关闭事件的基本流程。
1129

被折叠的 条评论
为什么被折叠?



