func (ps *ParticleSystem) DoStep(gs *gamestate.GameState) {
	ps.TransformProg.Use()
	ps.VaoTff1.Bind()

	gl.Enable(gl.RASTERIZER_DISCARD)
	defer gl.Disable(gl.RASTERIZER_DISCARD)

	// ps.Data1.Bind(gl.ARRAY_BUFFER)
	// SetAttribPointers(&ps.TransformLoc, &ParticleVertex{}, false)

	//var orientation mgl.Quat = gs.Player.Camera.Orientation
	var model mgl.Mat4 = gs.Camera.Model()
	pPos := model.Mul4x1(mgl.Vec4{1, -1, 0, 1})
	ps.TransformLoc.Origin.Uniform3f(pPos[0], pPos[1], pPos[2])
	dir := model.Mul4x1(mgl.Vec4{0, 0, 100, 0})
	ps.TransformLoc.Dir.Uniform3f(dir[0], dir[1], dir[2])

	ps.Data2.BindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0)

	gl.BeginTransformFeedback(gl.POINTS)
	gl.DrawArrays(gl.POINTS, 0, ps.NumParticles)
	gl.EndTransformFeedback()

	ps.Data1, ps.Data2 = ps.Data2, ps.Data1
	ps.VaoRender1, ps.VaoRender2 = ps.VaoRender2, ps.VaoRender1
	ps.VaoTff1, ps.VaoTff2 = ps.VaoTff2, ps.VaoTff1
}
示例#2
0
func (e *Entity) SetView(m mgl.Mat4) {
	e.SetModel(m.Inv())
}