示例#1
0
文件: main.go 项目: shogg/glvox
func initVoxels() {

	s := 164096

	voxels := glvox.NewOctree(s)

	glvox.ReadBinvox("../res/skull256.binvox", voxels, 896, 896, 896)

	data := voxels.Index
	buf := gl.GenBuffer()
	buf.Bind(gl.TEXTURE_BUFFER)
	gl.BufferData(gl.TEXTURE_BUFFER, len(data)*4, data, gl.STATIC_DRAW)

	gl.ActiveTexture(gl.TEXTURE0)
	tex := gl.GenTexture()
	tex.Bind(gl.TEXTURE_BUFFER)
	gl.TexBuffer(gl.TEXTURE_BUFFER, gl.R32I, buf)

	voxelsLoc := prg.GetUniformLocation("voxels")
	voxelsLoc.Uniform1i(0)

	var value [1]int32
	gl.GetIntegerv(gl.MAX_TEXTURE_BUFFER_SIZE, value[:])
	fmt.Println("max texture buffer size:", value[0]/1024/1024, "MiB")

	sizeLoc := prg.GetUniformLocation("size")
	sizeLoc.Uniform1i(int(voxels.Size))
	fmt.Println("voxel data uploaded:", len(voxels.Index)*4/1024/1024, "MiB")
}
示例#2
0
文件: gl_test.go 项目: shogg/gl
func newBuffer(bytes int) gl.Buffer {
	buf := gl.GenBuffer()
	buf.Bind(gl.ARRAY_BUFFER)
	gl.BufferData(gl.ARRAY_BUFFER, bytes, slice, gl.STATIC_READ)
	return buf
}