fix NewMultiShape

This commit is contained in:
faiface 2016-12-20 14:56:45 +01:00
parent e54a3b8f38
commit ef0c51a473
1 changed files with 22 additions and 1 deletions

View File

@ -192,7 +192,28 @@ func NewMultiShape(parent pixelgl.Doer, shapes ...*Shape) *MultiShape {
var vertices []map[pixelgl.Attr]interface{} var vertices []map[pixelgl.Attr]interface{}
for _, shape := range shapes { for _, shape := range shapes {
vertices = append(vertices, shape.VertexArray().Vertices()...) shapeVertices := shape.VertexArray().Vertices()
for vertex := range shapeVertices {
if pos, ok := shapeVertices[vertex][positionVec2]; ok {
pos := pos.(mgl32.Vec2)
pos = shape.Transform().Mat3().Mul3x1(mgl32.Vec3{pos.X(), pos.Y(), 1}).Vec2()
shapeVertices[vertex][positionVec2] = pos
}
if color, ok := shapeVertices[vertex][colorVec4]; ok {
color := color.(mgl32.Vec4)
r, g, b, a := colorToRGBA(shape.Color())
color = mgl32.Vec4{
color[0] * r,
color[1] * g,
color[2] * b,
color[3] * a,
}
shapeVertices[vertex][colorVec4] = color
}
}
vertices = append(vertices, shapeVertices...)
} }
parent.Do(func(ctx pixelgl.Context) { parent.Do(func(ctx pixelgl.Context) {