如何在 MacOS (Lion-10.8) 上的 Go 中创建 OpenGL 3.2 上下文

我正在尝试在 MacOS 上的 Go 中编写 OpenGL 应用程序,但无法弄清楚如何使用高于OpenGL 2.1的版本创建上下文


我试过在那里使用多个 OpenGL 绑定,但最终选择了 github.com/go-gl/gl


下面的例子将输出2.1 NVIDIA-8.12.47 310.40.00.05f01. 我需要做什么来创建 OpenGL 3.2 上下文?


package main


import (

    "fmt"

    "github.com/go-gl/gl"

    glfw "github.com/go-gl/glfw3"

)

func main() {

    //request 3.2 context

    glfw.WindowHint(glfw.ContextVersionMajor, 3)

    glfw.WindowHint(glfw.ContextVersionMinor, 2)

    glfw.WindowHint(glfw.OpenglProfile, glfw.OpenglCoreProfile)

    if !glfw.Init() {

        panic("glfw init failed")

    }

    defer glfw.Terminate()


    //create and set window context

    window, err := glfw.CreateWindow(64, 64, "foo", nil, nil)

    if err != nil {

        panic(err)

    }

    window.MakeContextCurrent()


    //check version

    version := gl.GetString(gl.VERSION)

    fmt.Println(version)

}


茅侃侃
浏览 200回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go