Esempio n. 1
0
func (s Sprite) getGLVertexInfo() Opengl.OpenGLVertexInfo {
	// vertexInfo := Opengl.OpenGLVertexInfo{}
	w, h := s.GetImageSection().GetDimensions()

	vertexInfo := Opengl.OpenGLVertexInfo{
		Translations: []float32{float32(s.x), float32(s.y), 0, float32(s.x), float32(s.y), 0, float32(s.x), float32(s.y), 0, float32(s.x), float32(s.y), 0},
		Rotations:    []float32{0, 0, 1, s.rot, 0, 0, 1, s.rot, 0, 0, 1, s.rot, 0, 0, 1, s.rot},
		Scales:       []float32{s.xS, s.yS, 0, s.xS, s.yS, 0, s.xS, s.yS, 0, s.xS, s.yS, 0},
		Colors:       []float32{s.r, s.g, s.b, s.a, s.r, s.g, s.b, s.a, s.r, s.g, s.b, s.a, s.r, s.g, s.b, s.a},
	}

	// for i := 0; i < 4; i = i + 1 {
	// 	vertexInfo.Translations = append(vertexInfo.Translations, float32(s.x), float32(s.y), 0)
	// 	vertexInfo.Rotations = append(vertexInfo.Rotations, 0, 0, 1, s.rot)
	// 	vertexInfo.Scales = append(vertexInfo.Scales, s.xS, s.yS, 0)
	// 	vertexInfo.Colors = append(vertexInfo.Colors, s.r, s.g, s.b, s.a)

	// }

	vertexInfo.Vertices = []float32{-0.5 * w, 0.5 * h, 1.0, 0.5 * w, 0.5 * h, 1.0, 0.5 * w, -0.5 * h, 1.0, -0.5 * w, -0.5 * h, 1.0}

	vertexInfo.Elements = []uint32{uint32(0), uint32(1), uint32(2), uint32(0), uint32(2), uint32(3)}

	return vertexInfo
}