Ejemplo n.º 1
0
func (c *cloudState) tick(delta float64) {
	if !DrawClouds {
		return
	}
	c.offset += delta
	tex := GetTexture("steven:environment/clouds")
	r := tex.Rect()

	c.program.Use()
	c.shader.PerspectiveMatrix.Matrix4(&perspectiveMatrix)
	c.shader.CameraMatrix.Matrix4(&cameraMatrix)
	c.shader.SkyOffset.Float(SkyOffset)
	c.shader.LightLevel.Float(LightLevel)
	c.shader.Offset.Float3(float32(int(Camera.X)), 0, float32(int(Camera.Z)))
	c.shader.TextureInfo.Float4(
		float32(r.X),
		float32(r.Y),
		float32(r.Width),
		float32(r.Height),
	)
	c.shader.Atlas.Float(float32(tex.Atlas()))
	c.shader.CloudOffset.Float(float32(c.offset / 60.0))

	c.shader.Textures.Int(0)

	gl.ActiveTexture(1)
	c.texture.Bind(gl.Texture2D)
	if c.dirty {
		c.texture.SubImage2D(0, 0, 0, 512, 512, gl.Red, gl.UnsignedByte, c.data)
		c.dirty = false
	}
	c.shader.CloudMap.Int(1)
	c.array.Bind()
	gl.DrawArrays(gl.Points, 0, c.numPoints)
}
Ejemplo n.º 2
0
Archivo: trans.go Proyecto: num5/steven
func transDraw() {
	gl.ActiveTexture(0)
	accum.Bind(gl.Texture2D)
	gl.ActiveTexture(1)
	revealage.Bind(gl.Texture2D)
	gl.ActiveTexture(2)
	fbColor.Bind(gl.Texture2DMultisample)

	transState.program.Use()
	transState.shader.Accum.Int(0)
	transState.shader.Revealage.Int(1)
	transState.shader.Color.Int(2)
	transState.shader.Samples.Int(rSamples.Value())
	transState.array.Bind()
	gl.DrawArrays(gl.Triangles, 0, 6)
}
Ejemplo n.º 3
0
Archivo: line.go Proyecto: num5/steven
func drawLines() {
	if lineState.count > 0 {
		gl.Enable(gl.Blend)
		lineState.program.Use()
		lineState.shader.PerspectiveMatrix.Matrix4(&perspectiveMatrix)
		lineState.shader.CameraMatrix.Matrix4(&cameraMatrix)
		lineState.array.Bind()
		lineState.buffer.Bind(gl.ArrayBuffer)
		if len(lineState.data) > lineState.prevSize {
			lineState.prevSize = len(lineState.data)
			lineState.buffer.Data(lineState.data, gl.DynamicDraw)
		} else {
			target := lineState.buffer.Map(gl.WriteOnly, len(lineState.data))
			copy(target, lineState.data)
			lineState.buffer.Unmap()
		}
		gl.DrawArrays(gl.Triangles, 0, lineState.count)
		lineState.count = 0
		lineState.data = lineState.data[:0]
		gl.Disable(gl.Blend)
	}
}