示例#1
0
func (mtrl *Material) reloadProgram(ctx gl.Context) {
	mtrl.prg0.CreateAndLink(ctx, glutil.ShaderAsset(gl.VERTEX_SHADER, "material-vert.glsl"), glutil.ShaderAsset(gl.FRAGMENT_SHADER, "material-frag.glsl"))
	mtrl.uw0 = mtrl.prg0.Uniform(ctx, "world")
	mtrl.uv0 = mtrl.prg0.Uniform(ctx, "view")
	mtrl.up0 = mtrl.prg0.Uniform(ctx, "proj")
	mtrl.uc0 = mtrl.prg0.Uniform(ctx, "color")
	mtrl.ap0 = mtrl.prg0.Attrib(ctx, "position")
	mtrl.utex0 = mtrl.prg0.Uniform(ctx, "tex0")
	mtrl.atc0 = mtrl.prg0.Attrib(ctx, "tc0")
	mtrl.uicon = mtrl.prg0.Uniform(ctx, "icon")
	mtrl.ucirc0 = mtrl.prg0.Uniform(ctx, "circle")

	mtrl.prg1.CreateAndLink(ctx, glutil.ShaderAsset(gl.VERTEX_SHADER, "material-shadow-vert.glsl"), glutil.ShaderAsset(gl.FRAGMENT_SHADER, "material-shadow-frag.glsl"))
	mtrl.uw1 = mtrl.prg1.Uniform(ctx, "world")
	mtrl.uv1 = mtrl.prg1.Uniform(ctx, "view")
	mtrl.up1 = mtrl.prg1.Uniform(ctx, "proj")
	mtrl.uc1 = mtrl.prg1.Uniform(ctx, "color")
	mtrl.us1 = mtrl.prg1.Uniform(ctx, "size")
	mtrl.ucirc1 = mtrl.prg1.Uniform(ctx, "circle")
	mtrl.ap1 = mtrl.prg1.Attrib(ctx, "position")
}
示例#2
0
文件: waveform.go 项目: dskinner/snd
// TODO just how many samples do we want/need to display something useful?
func NewWaveform(ctx gl.Context, n int, in snd.Sound) (*Waveform, error) {
	wf := &Waveform{Material: env.NewMaterial(ctx), Sound: in}
	wf.Drawer = wf.Draw

	wf.outs = make([][]float64, n)
	for i := range wf.outs {
		wf.outs[i] = make([]float64, in.BufferLen()*in.Channels())
	}
	wf.samples = make([]float64, in.BufferLen()*in.Channels()*n)
	wf.verts = make([]float32, len(wf.samples)*2)

	wf.prg.CreateAndLink(ctx,
		glutil.ShaderAsset(gl.VERTEX_SHADER, "basic-vert.glsl"),
		glutil.ShaderAsset(gl.FRAGMENT_SHADER, "basic-frag.glsl"))

	wf.vbuf = glutil.NewFloatBuffer(ctx, wf.verts, gl.STREAM_DRAW)
	wf.uw = wf.prg.Uniform(ctx, "world")
	wf.uv = wf.prg.Uniform(ctx, "view")
	wf.up = wf.prg.Uniform(ctx, "proj")
	wf.uc = wf.prg.Uniform(ctx, "color")
	wf.ap = wf.prg.Attrib(ctx, "position")
	return wf, nil
}