大佬教程收集整理的这篇文章主要介绍了Golang glfw中使用opengl库的问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
最近在看看一个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库的例子,想照猫画一下,但是就遇到问题了。
gl.begin(gl.TRIANGLES) gl.Color3f(1.0,0.0,0.0) //red gl.Vertex3f(0.0,1.0,0.0) gl.Color3f(0.0,0.0) //Green gl.Vertex3f(-1.0,-1.0,1.0) //blue gl.Vertex3f(1.0,0.0) gl.End()
直接运行会报错:
Fatal error: unexpected signal during runtime execution
以上是大佬教程为你收集整理的Golang glfw中使用opengl库的问题全部内容,希望文章能够帮你解决Golang glfw中使用opengl库的问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。