-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvertex.go
58 lines (50 loc) · 1.16 KB
/
vertex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package vulkanRenderSystem
import (
vk "github.com/vulkan-go/vulkan"
"github.com/go-gl/mathgl/mgl32"
)
// vec2 position
// vec3 color
// vec2 texcoord
type vertex []float32
func (v *vertex) getBindingDescription() vk.VertexInputBindingDescription {
return vk.VertexInputBindingDescription{
Binding: 0,
Stride: 7 * 4,
InputRate: vk.VertexInputRateVertex,
}
}
func (v *vertex) getAttributeDescriptions() []vk.VertexInputAttributeDescription {
var a []vk.VertexInputAttributeDescription
a = append(a, vk.VertexInputAttributeDescription{
Binding: 0,
Location: 0,
Format: vk.FormatR32g32Sfloat,
Offset: 0,
})
a = append(a, vk.VertexInputAttributeDescription{
Binding: 0,
Location: 1,
Format: vk.FormatR32g32b32Sfloat,
Offset: 2 * 4,
})
a = append(a, vk.VertexInputAttributeDescription{
Binding: 0,
Location: 2,
Format: vk.FormatR32g32Sfloat,
Offset: 5 * 4,
})
return a
}
var vertices = vertex{
-0.5, -0.5, 1, 0, 0, 1, 0,
0.5, -0.5, 0, 1, 0, 0, 0,
0.5, 0.5, 0, 0, 1, 0, 1,
-0.5, 0.5, 1, 1, 1, 1, 1,
}
var indices = []uint16{
0, 1, 2, 2, 3, 0,
}
type UniformBufferObject struct {
model, view, projection mgl32.Mat4
}