最近在看看一个Golang的项目,里面使用了GLFW和GL来写UI,之前从来没有接触过这两个库,安装官方文档写了一个例子。
package main
import (
"runtime"
"github.com/go-gl/glfw/v3.1/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()
}
}
这个例子可以直接run,一切都很正常。后来看到一个C库的例子,想照猫画一下,但是就遇到问题了。
按照这个例子添加了如下代码:

本文介绍了作者在使用Golang结合GLFW和OpenGL进行UI开发时遇到的错误情况。在尝试复制一个C库的例子后,运行代码出现报错。文章将探讨这个问题的解决过程。
最低0.47元/天 解锁文章
398

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



