Skip to content

Commit

Permalink
Merge pull request #27 from EngoEngine/wasm-fixes
Browse files Browse the repository at this point in the history
Wasm fixes
  • Loading branch information
Noofbiz authored Feb 22, 2020
2 parents 45b145a + 9f48c27 commit 5334bf6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
33 changes: 16 additions & 17 deletions gl_webgl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
"errors"
"image"
"log"

"github.com/gopherjs/gopherwasm/js"
"syscall/js"
)

type Texture struct{ js.Value }
Expand Down Expand Up @@ -789,21 +788,21 @@ func (c *Context) ActiveTexture(target int) {
// If no array is provided, the contents of the buffer is initialized to 0.
func (c *Context) BufferData(target int, data interface{}, usage int) {
buf, ok := data.([]uint8)
d := js.TypedArrayOf([]uint8{})
d := js.TypeOf([]uint8{})
if ok {
d = js.TypedArrayOf(buf)
d = js.TypeOf(buf)
}
buf2, ok := data.([]uint16)
if ok {
d = js.TypedArrayOf(buf2)
d = js.TypeOf(buf2)
}
buf3, ok := data.([]uint32)
if ok {
d = js.TypedArrayOf(buf3)
d = js.TypeOf(buf3)
}
buff32, ok := data.([]float32)
if ok {
d = js.TypedArrayOf(buff32)
d = js.TypeOf(buff32)
}
c.Call("bufferData", target, d, usage)
d.Release()
Expand All @@ -812,21 +811,21 @@ func (c *Context) BufferData(target int, data interface{}, usage int) {
// Used to modify or update some or all of a data store for a bound buffer object.
func (c *Context) BufferSubData(target int, offset int, data interface{}) {
buf, ok := data.([]uint8)
d := js.TypedArrayOf([]uint8{})
d := js.TypeOf([]uint8{})
if ok {
d = js.TypedArrayOf(buf)
d = js.TypeOf(buf)
}
buf2, ok := data.([]uint16)
if ok {
d = js.TypedArrayOf(buf2)
d = js.TypeOf(buf2)
}
buf3, ok := data.([]uint32)
if ok {
d = js.TypedArrayOf(buf3)
d = js.TypeOf(buf3)
}
buff32, ok := data.([]float32)
if ok {
d = js.TypedArrayOf(buff32)
d = js.TypeOf(buff32)
}
c.Call("bufferSubData", target, offset, d)
d.Release()
Expand Down Expand Up @@ -1277,11 +1276,11 @@ func (c *Context) ShaderSource(shader *Shader, source string) {
func (c *Context) TexImage2D(target, level, internalFormat, format, kind int, data interface{}) {
switch img := data.(type) {
case *image.NRGBA:
d := js.TypedArrayOf(img.Pix)
d := js.TypeOf(img.Pix)
c.Call("texImage2D", target, level, internalFormat, img.Bounds().Dx(), img.Bounds().Dy(), 0, format, kind, d)
d.Release()
case *image.RGBA:
d := js.TypedArrayOf(img.Pix)
d := js.TypeOf(img.Pix)
c.Call("texImage2D", target, level, internalFormat, img.Bounds().Dx(), img.Bounds().Dy(), 0, format, kind, d)
d.Release()
default:
Expand Down Expand Up @@ -1355,22 +1354,22 @@ func (c *Context) Uniform4i(location *UniformLocation, x, y, z, w int) {
// Sets values for a 2x2 floating point vector matrix into a
// uniform location as a matrix or a matrix array.
func (c *Context) UniformMatrix2fv(location *UniformLocation, transpose bool, value []float32) {
d := js.TypedArrayOf(value)
d := js.TypeOf(value)
c.Call("uniformMatrix2fv", location.Value, transpose, d)
d.Release()
}

// Sets values for a 3x3 floating point vector matrix into a
// uniform location as a matrix or a matrix array.
func (c *Context) UniformMatrix3fv(location *UniformLocation, transpose bool, value []float32) {
d := js.TypedArrayOf(value)
d := js.TypeOf(value)
c.Call("uniformMatrix3fv", location.Value, transpose, d)
}

// Sets values for a 4x4 floating point vector matrix into a
// uniform location as a matrix or a matrix array.
func (c *Context) UniformMatrix4fv(location *UniformLocation, transpose bool, value []float32) {
d := js.TypedArrayOf(value)
d := js.TypeOf(value)
c.Call("uniformMatrix4fv", location.Value, transpose, d)
}

Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/engoengine/gl

go 1.13

require (
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
golang.org/x/mobile v0.0.0-20200212152714-2b26a4705d24
)
27 changes: 27 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20200212152714-2b26a4705d24 h1:vuOuHxlnNE2cEdI537Gb/9ygmbn1Ne7R9hAiLGLLk0g=
golang.org/x/mobile v0.0.0-20200212152714-2b26a4705d24/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

0 comments on commit 5334bf6

Please sign in to comment.