func NewContext(canvas js.Value) (*Context, error) {
	if js.Global().Get("WebGLRenderingContext").Equal(js.Undefined()) {
		return nil, errors.New("Your browser doesn't appear to support webgl.")
	}

	gl := canvas.Call("getContext", "webgl")
	if gl.IsNull() {
		gl = canvas.Call("getContext", "experimental-webgl")
		if gl.IsNull() {
			return nil, errors.New("Creating a webgl context has failed.")
		}
	}
	ctx := new(Context)
	ctx.Value = gl

	rctx := reflect.TypeOf(*ctx)
	for i := 0; i < rctx.NumField(); i++ {
		field := rctx.Field(i)

		if _, ok := field.Tag.Lookup("js"); ok {
			val := gl.Get(field.Tag.Get("js"))
			reflect.ValueOf(ctx).Elem().Field(i).Set(reflect.ValueOf(val))
		}
	}
	return ctx, nil
}
// NewContext takes an HTML5 canvas object and optional context attributes.
// If an error is returned it means you won't have access to WebGL
// functionality.
NewContext takes an HTML5 canvas object and optional context attributes.
If an error is returned it means you won't have access to WebGL
functionality.
// NewContext takes an HTML5 canvas object and optional context attributes . // If an error is returned it means you won ' t have access to WebGL // functionality .
func NewContext(canvas js.Value) (*Context, error) {
	if js.Global().Get("WebGLRenderingContext").Equal(js.Undefined()) {
		return nil, errors.New("Your browser doesn't appear to support webgl.")
	}
	gl := canvas.Call("getContext", "webgl")
	if gl.IsNull() {
		gl = canvas.Call("getContext", "experimental-webgl")
		if gl.IsNull() {
			return nil, errors.New("Creating a webgl context has failed.")
		}
	}
	ctx := new(Context)
	ctx.Value = gl
	rctx := reflect.TypeOf(*ctx)
	for i := 0; i < rctx.NumField(); i++ {
		field := rctx.Field(i)
		if _, ok := field.Tag.Lookup("js"); ok {
			val := gl.Get(field.Tag.Get("js"))
			reflect.ValueOf(ctx).Elem().Field(i).Set(reflect.ValueOf(val))
		}
	}
	return ctx, nil
}
func NewContext ( canvas js . Value ) ( * Context , error ) { if js . Global ( ) . Get ( " " ) . Equal ( js . Undefined ( ) ) { return nil , errors . New ( " " ) } gl := canvas . Call ( " " , " " ) if gl . IsNull ( ) { gl = canvas . Call ( " " , " " ) if gl . IsNull ( ) { return nil , errors . New ( " " ) } } ctx := new ( Context ) ctx . Value = gl rctx := reflect . TypeOf ( * ctx ) for i := 0 ; i < rctx . NumField ( ) ; i ++ { field := rctx . Field ( i ) if _ , ok := field . Tag . Lookup ( " " ) ; ok { val := gl . Get ( field . Tag . Get ( " " ) ) reflect . ValueOf ( ctx ) . Elem ( ) . Field ( i ) . Set ( reflect . ValueOf ( val ) ) } } return ctx , nil }
NewContext takes an HTML5 canvas object and optional context attributes.
NewContext takes an HTML5 canvas object and optional context attributes .