Skip to content
Gopherjs binding to the webgl context
Branch: master
Clone or download
dmitshur README: Specify WebGL 1.0 as the version. (#17)
Also update the link to GopherJS repository.

Fixes #15.
Latest commit 39bd6d4 May 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md README: Specify WebGL 1.0 as the version. (#17) May 8, 2018
webgl.go Port to new js.Object struct. Feb 21, 2015

README.md

webgl

GoDoc Go Report Card

GopherJS bindings for WebGL 1.0 context.

Example

Screenshot

webgl_example.go:

package main

import (
	"github.com/gopherjs/gopherjs/js"
	"github.com/gopherjs/webgl"
)

func main() {
	document := js.Global.Get("document")
	canvas := document.Call("createElement", "canvas")
	document.Get("body").Call("appendChild", canvas)

	attrs := webgl.DefaultAttributes()
	attrs.Alpha = false

	gl, err := webgl.NewContext(canvas, attrs)
	if err != nil {
		js.Global.Call("alert", "Error: "+err.Error())
	}

	gl.ClearColor(0.8, 0.3, 0.01, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
}

webgl_example.html:

<html><body><script src="webgl_example.js"></script></body></html>

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

You can’t perform that action at this time.