Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 1017 Bytes

File metadata and controls

44 lines (30 loc) · 1017 Bytes

webgl

GoDoc Go Report Card

change from https://godoc.org/github.com/gopherjs/webgl support "syscall/js"

Example

Screenshot

webgl_example.go:

package main

import (
	"syscall/js"
	"github.com/n2d/webgl"
)

func main() {
	var canvas js.Value = js.
		Global().
		Get("document").
		Call("getElementById", "canvas")


	canvas.Set("height", 600)
	canvas.Set("width", 800)

	gl, _ := webgl.NewContext(canvas)

	gl.ClearColor(1, 0, 0, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
}

webgl_example.html:

<html><body><script src="webgl_example.js"></script><canvas id='canvas'></canvas></br></body></html>

To produce webgl_example.js file, run gopherjs build webgl_example.go.