Avoid copying arrays

This commit is contained in:
Hajime Hoshi 2015-01-04 22:26:20 +09:00
parent 265a85e922
commit 8994ffad9b

View File

@ -19,13 +19,12 @@ import (
) )
func glMatrix(m *[4][4]float64) []float32 { func glMatrix(m *[4][4]float64) []float32 {
result := make([]float32, 16) return []float32{
for j := 0; j < 4; j++ { float32(m[0][0]), float32(m[1][0]), float32(m[2][0]), float32(m[3][0]),
for i := 0; i < 4; i++ { float32(m[0][1]), float32(m[1][1]), float32(m[2][1]), float32(m[3][1]),
result[i+j*4] = float32(m[i][j]) float32(m[0][2]), float32(m[1][2]), float32(m[2][2]), float32(m[3][2]),
float32(m[0][3]), float32(m[1][3]), float32(m[2][3]), float32(m[3][3]),
} }
}
return result
} }
type Matrix interface { type Matrix interface {