Golang glfw中使用opengl库的问题

本文介绍了作者在使用Golang结合GLFW和OpenGL进行UI开发时遇到的错误情况。在尝试复制一个C库的例子后,运行代码出现报错。文章将探讨这个问题的解决过程。
摘要由CSDN通过智能技术生成

最近在看看一个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库的例子ÿ

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值