示例#1
0
func NewDynamicShape(glctx gl.Context, bufSize int) *DynamicShape {
	shape := &DynamicShape{StaticShape{glctx: glctx}}
	shape.VBO = glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, shape.VBO)
	glctx.BufferInit(gl.ARRAY_BUFFER, bufSize, gl.DYNAMIC_DRAW)

	return shape
}
示例#2
0
func ParticleEmitter(glctx gl.Context, origin mgl.Vec3, num int, rate float32) Emitter {
	bufSize := num * particleLen * vecSize
	vbo := glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, vbo)
	glctx.BufferInit(gl.ARRAY_BUFFER, bufSize, gl.DYNAMIC_DRAW)

	return &particleEmitter{
		glctx:     glctx,
		VBO:       vbo,
		origin:    origin,
		rate:      rate,
		particles: make([]*particle, 0, num),
		num:       num,
	}
}