OpenGL: Difference between revisions
→{{header|Go}}: Updated example so it now works - at least on Ubuntu.
(→{{header|Go}}: Updated example so it now works - at least on Ubuntu.) |
|||
Line 1,000:
=={{header|Go}}==
{{libheader|GoGL}}
{{libheader|GLFW 3.2 for Go}}
{{works with|Ubuntu 16.04}}
<lang go>package main▼
▲package main
import (
"log"▼
"runtime"▼
▲ gl "github.com/chsc/gogl/gl21"
▲ "github.com/mewmew/glfw/win"
)
// Window dimensions.
const (
)
func check(err error) {
log.Fatal(err)
}
}▼
func main() {
err := glfw.Init()
// Open window with the specified dimensions.▼
check(err)
err := win.Open(Width, Height)▼
defer glfw.Terminate()
▲ if err != nil {
// Initiate viewport.▼
check(err)
window.MakeContextCurrent()
// Register that we are interested in receiving close and resize events.▼
err = gl.Init()
check(err)
window.SetCloseCallback(func(w *glfw.Window) {
})
window.SetSizeCallback(func(w *glfw.Window, width, height int) {
resize(width, height)
draw()▼
})
for !window.ShouldClose() {
glfw.PollEvents()
}
}
// resize resizes the window to the specified dimensions.
func resize(width, height int) {
}
// draw draws the triangle.
func draw() {
gl.Flush()
▲ win.SwapBuffers()
}</lang>▼
▲}
▲</lang>
=={{header|Haskell}}==
|