コード例 #1
0
func Draw(renData *RenderData) {
	numverts := renData.Numverts
	if renData.InstanceData == 0 {
		if renData.Indices == 0 {
			gl.DrawArrays(renData.Mode, 0, renData.Numverts)
		} else {
			gl.DrawElements(renData.Mode, numverts, renData.IndexType, uintptr(0))
		}
	} else {
		if renData.Indices == 0 {
			gl.DrawArraysInstanced(renData.Mode, 0, renData.Numverts, renData.NumInstances)
		} else {
			gl.DrawElementsInstanced(renData.Mode, renData.Numverts, renData.IndexType, 0, renData.NumInstances)
		}
	}
}
コード例 #2
0
func (ps *ParticleSystem) Render(Proj mgl.Mat4, View mgl.Mat4, clippingPlane mgl.Vec4) {
	gl.PointSize(64)

	ps.VaoRender1.Bind()

	ps.RenderProg.Use()
	Loc := ps.RenderLoc

	Loc.Proj.UniformMatrix4f(false, (*[16]float32)(&Proj))
	Loc.View.UniformMatrix4f(false, (*[16]float32)(&View))
	Loc.MaxLifetime.Uniform1f(ps.MaxLifetime)
	Loc.Image.Uniform1i(constants.TextureFireBall)
	Loc.ClippingPlane_ws.Uniform4f(clippingPlane[0], clippingPlane[1], clippingPlane[2], clippingPlane[3])

	gl.DepthMask(false)
	gl.DrawArraysInstanced(gl.TRIANGLE_FAN, 0, 4, ps.NumParticles)
	gl.DepthMask(true)
}