Git Product home page Git Product logo

webgl's Introduction

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.

webgl's People

Contributors

ajhager avatar dmitshur avatar konstantin8105 avatar neelance avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webgl's Issues

Wishlist: binding for: new Image

Want constructor for javascript Image.

I am currently using this work-around:

func newImage() *js.Object {
    return js.Global.Call("eval", "(new Image())")
}

image := newImage()
image.Set("onload", func() {
    //go onLoad(gl, t, textureURL) // call onload handling goroutine
})
image.Set("src", textureURL)

Type-agnostic GetProgramParameter missing

There are methods such as GetShaderParameter() returning the actual result, but for program parameter, only type specific methods exist.

In my case of wrapping WebGL behind a OpenGL ES generic interface I'd like to support the original signature returning int. For the program parameter I'm currently calling the JS method directly (not via the WebGL interface).

Is the type-agnostic variant missing or are you planning to have only specific methods (and calling the function directly is the preferred way)?

My code in question is here

UniformMatrix4fv (and other *v functions) have vararg parameters

The matrix parameters of the *v functions are parameter lists, both according to OpenGL ES 2 and the WebGL specification. The current signature of the wrapper specifies only one slice.

Is there a specific reason that they only take one parameter?

In my code to wrap WebGL behind an OpenGL ES 2 interface I'm calling the JS function directly, as seen here.

Additionally: Should the signature be changed, may I suggest to have array types as parameters instead of slices? go-gl does that for instance.

Wishlist: binding for byte-slice aware gl.texImage2D

Want: gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, rbga)

Current work-around: gl.Call("texImage2D", gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, rgba)

rgba type is []byte

LICENSE file not found

While the comment says

// Copyright 2014 Joseph Hager. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

, LICENSE file is not present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.