// // print OpenGl Version Info // Prints the OpenGL Version to the Console // func printOpenGlVersionInfo() { version := gl.GoStr(gl.GetString(gl.VERSION)) renderer := gl.GoStr(gl.GetString(gl.RENDERER)) shaderVersion := gl.GoStr(gl.GetString(gl.SHADING_LANGUAGE_VERSION)) fmt.Println("OpenGL version", version) fmt.Println("OpenGL renderer", renderer) fmt.Println("Max supported shader language version", shaderVersion) }
func (glr *GlRenderer) initSystem() { // Lock goroutine to main thread - required for GL runtime.LockOSThread() var err error if err = glfw.Init(); err != nil { panic(err) } glfw.WindowHint(glfw.Resizable, glfw.False) glfw.WindowHint(glfw.ContextVersionMajor, 3) glfw.WindowHint(glfw.ContextVersionMinor, 3) glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile) glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True) glr.window, err = glfw.CreateWindow(glr.width, glr.height, "rt", nil, nil) if err != nil { panic(err) } glr.window.MakeContextCurrent() if err = gl.Init(); err != nil { panic(err) } version := gl.GoStr(gl.GetString(gl.VERSION)) fmt.Println("OpenGL version", version) }
func CreateRenderer(windowWidth, windowHeight int) *Renderer { if err := glfw.Init(); err != nil { log.Fatalln("failed to initialize glfw:", err) } // defer glfw.Terminate() glfw.WindowHint(glfw.Resizable, glfw.False) glfw.WindowHint(glfw.ContextVersionMajor, 4) glfw.WindowHint(glfw.ContextVersionMinor, 1) glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile) glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True) if windowWidth == 0 && windowHeight == 0 { windowWidth, windowHeight = glfw.GetPrimaryMonitor().GetPhysicalSize() } fmt.Println("Window Width -", windowWidth, "Window Height -", windowHeight) window, err := glfw.CreateWindow(windowWidth, windowHeight, "Karma", glfw.GetPrimaryMonitor(), nil) if err != nil { panic(err) } window.MakeContextCurrent() window.SetKeyCallback(testCallback) // Initialize Glow if err := gl.Init(); err != nil { panic(err) } version := gl.GoStr(gl.GetString(gl.VERSION)) fmt.Println("OpenGL version", version) shaders := Shaders{} textureFlatUniforms := []string{"projection", "camera", "modelView", "tex"} textureFlatAttributes := []string{"vert", "vertTexCoord"} fmt.Println(textureFlatUniforms) fmt.Println(textureFlatAttributes) shader, err := createProgram("./assets/shaders/texture_flat.vs", "./assets/shaders/texture_flat.fs", textureFlatUniforms, textureFlatAttributes) if err != nil { panic(err) } shaders.textureFlat = shader meshes := []*Mesh{} previousTime := glfw.GetTime() return &Renderer{ PreviousTime: previousTime, Window: window, Shaders: &shaders, Meshes: meshes, } }