/
draw.go
26 lines (23 loc) · 850 Bytes
/
draw.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
package gli
import (
"unsafe"
"github.com/go-gl/gl/v3.3-core/gl"
)
func Draw(program Program, vao VertexArrayObject, object Object) {
Current.Draw(program, vao, object)
}
func (context iContext) Draw(program Program, vao VertexArrayObject, object Object) {
context.BindVertexArrayObject(vao)
context.BindProgram(program)
if object.IndexType != 0 {
if object.IndexBase > 0 {
gl.DrawElementsBaseVertex(uint32(object.Mode), int32(object.Vertices), uint32(object.IndexType), unsafe.Pointer(uintptr(object.Start)), int32(object.IndexBase))
} else {
gl.DrawElements(uint32(object.Mode), int32(object.Vertices), uint32(object.IndexType), unsafe.Pointer(uintptr(object.Start)))
}
} else {
gl.DrawArrays(uint32(object.Mode), int32(object.Start), int32(object.Vertices))
}
context.UnbindProgram()
context.UnbindVertexArrayObject()
}