Kaynağa Gözat

Adapt to WASM version

Daniel Salvadori 6 yıl önce
ebeveyn
işleme
8168e57010
2 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 1 1
      geometry/geometry.go
  2. 6 0
      math32/array.go

+ 1 - 1
geometry/geometry.go

@@ -541,7 +541,7 @@ func (g *Geometry) RenderSetup(gs *gls.GLS) {
 	// Update Indices buffer if necessary
 	if g.indices.Size() > 0 && g.updateIndices {
 		gs.BindBuffer(gls.ELEMENT_ARRAY_BUFFER, g.handleIndices)
-		gs.BufferData(gls.ELEMENT_ARRAY_BUFFER, g.indices.Bytes(), g.indices, gls.STATIC_DRAW)
+		gs.BufferData(gls.ELEMENT_ARRAY_BUFFER, g.indices.Bytes(), g.indices.ToUint32(), gls.STATIC_DRAW)
 		g.updateIndices = false
 	}
 }

+ 6 - 0
math32/array.go

@@ -245,3 +245,9 @@ func (a *ArrayU32) Append(v ...uint32) {
 
 	*a = append(*a, v...)
 }
+
+// ToUint32 converts this array to an array of uint32
+func (a ArrayU32) ToUint32() []uint32 {
+
+	return (*[1 << 27]uint32)(unsafe.Pointer(&a[0]))[:len(a)]
+}