Example #1
0
func uploadGeometry(mesh *geometry) {
	gl.GenVertexArrays(1, &mesh.glVao)
	gl.BindVertexArray(mesh.glVao)
	gl.GenBuffers(1, &mesh.glVertBuf)
	gl.BindBuffer(gl.ARRAY_BUFFER, mesh.glVertBuf)
	gl.EnableVertexAttribArray(progPosAttrLoc)
	gl.VertexAttribPointer(progPosAttrLoc, 3, gl.FLOAT, gl.FALSE, 0, gl.Ptr(nil))
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(4*len(mesh.glVerts)), gl.Ptr(&mesh.glVerts[0]), gl.STATIC_DRAW)
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)
	gl.BindVertexArray(0)
}
Example #2
0
func renderGeometry(mesh *geometry) {
	gl.BindVertexArray(mesh.glVao)
	gl.DrawArrays(mesh.glMode, 0, mesh.glNumVerts)
	gl.BindVertexArray(0)
}
Example #3
0
func (_ *GlCache) BindVertexArray(glHandle gl.Uint) {
	if Cache.bindVertexArray != glHandle {
		Cache.bindVertexArray = glHandle
		gl.BindVertexArray(glHandle)
	}
}