本文整理汇总了Golang中golang.org/x/mobile/gl.Context.Uniform4f方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Uniform4f方法的具体用法?Golang Context.Uniform4f怎么用?Golang Context.Uniform4f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/mobile/gl.Context
的用法示例。
在下文中一共展示了Context.Uniform4f方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PaintKey
// PaintKey will paint the key 1) its own color or 2) red if they key is pressed.
func (k *PianoKey) PaintKey(glctx gl.Context, frameData util.FrameData) {
glctx.BindBuffer(gl.ARRAY_BUFFER, k.glBuf)
glctx.VertexAttribPointer(frameData.Position, coordsPerVertex, gl.FLOAT, false, 0, 0)
if k.pressed {
// Paint Red if pressed
glctx.Uniform4f(frameData.Color, 1, 0, 0, 1)
} else {
// Paint white if not pressed
glctx.Uniform4f(frameData.Color, k.keyColor.Red, k.keyColor.Green, k.keyColor.Blue, 1)
}
if frameData.Orientation == util.Portrait {
glctx.DrawArrays(gl.TRIANGLES, 6, vertexCount)
} else if frameData.Orientation == util.Landscape {
glctx.DrawArrays(gl.TRIANGLES, 0, vertexCount)
}
}
示例2: onPaint
func onPaint(glctx gl.Context, sz size.Event) {
glctx.ClearColor(0.5, 0.5, 0.5, 1)
glctx.Clear(gl.COLOR_BUFFER_BIT)
glctx.UseProgram(frameData.Program)
glctx.Uniform4f(frameData.Color, 0.5, 0.5, 0.5, 1)
// Put ourselves in the +x/+y quadrant (upper right quadrant)
glctx.Uniform2f(frameData.Offset, 0.0, 1.0)
glctx.EnableVertexAttribArray(frameData.Position)
manager.PaintLayers(sz, frameData)
// End drawing
glctx.DisableVertexAttribArray(frameData.Position)
}
示例3: onPaint
func onPaint(glctx gl.Context, sz size.Event) {
glctx.ClearColor(1, 0, 0, 1)
glctx.Clear(gl.COLOR_BUFFER_BIT)
glctx.UseProgram(program)
green += 0.01
if green > 1 {
green = 0
}
glctx.Uniform4f(color, 0, green, 0, 1)
glctx.Uniform2f(offset, touchX/float32(sz.WidthPx), touchY/float32(sz.HeightPx))
glctx.BindBuffer(gl.ARRAY_BUFFER, buf)
glctx.EnableVertexAttribArray(position)
glctx.VertexAttribPointer(position, coordsPerVertex, gl.FLOAT, false, 0, 0)
glctx.DrawArrays(gl.TRIANGLES, 0, vertexCount)
glctx.DisableVertexAttribArray(position)
fps.Draw(sz)
}
示例4: Paint
func (wf *Waveform) Paint(ctx gl.Context, xps, yps, width, height float32) {
// TODO this is racey and samples can be in the middle of changing
// move the slice copy to Prepare and sync with playback, or feed over chan
// TODO assumes mono
var (
xstep float32 = width / float32(len(wf.samples))
xpos float32 = xps
)
for i, x := range wf.samples {
// clip
if x > 1 {
x = 1
} else if x < -1 {
x = -1
}
wf.verts[i*3] = float32(xpos)
wf.verts[i*3+1] = yps + (height * float32((x+1)/2))
wf.verts[i*3+2] = 0
xpos += xstep
}
for i, x := range wf.verts {
u := math.Float32bits(x)
wf.data[4*i+0] = byte(u >> 0)
wf.data[4*i+1] = byte(u >> 8)
wf.data[4*i+2] = byte(u >> 16)
wf.data[4*i+3] = byte(u >> 24)
}
ctx.UseProgram(wf.program)
ctx.Uniform4f(wf.color, 1, 1, 1, 1)
// update hw buf and draw
ctx.BindBuffer(gl.ARRAY_BUFFER, wf.buf)
ctx.EnableVertexAttribArray(wf.position)
ctx.VertexAttribPointer(wf.position, 3, gl.FLOAT, false, 0, 0)
ctx.BufferSubData(gl.ARRAY_BUFFER, 0, wf.data)
ctx.DrawArrays(gl.LINE_STRIP, 0, len(wf.samples))
ctx.DisableVertexAttribArray(wf.position)
}
示例5: appPaint
// This is the main rendering call that updates the current scene and all children in the scene
func appPaint(glctx gl.Context, sz size.Event, delta float32) {
glctx.ClearColor(currentScene.BGColor.R, currentScene.BGColor.G, currentScene.BGColor.B, currentScene.BGColor.A)
glctx.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
for _, child := range currentScene.Children {
child.act(delta)
child.draw(tempBatch, 1.0)
if len(InputChannel) > 0 {
for e := range InputChannel {
if child.Input != nil {
child.Input(child, e)
}
if len(InputChannel) == 0 {
break
}
}
}
}
glctx.UseProgram(program)
green += 0.01
if green > 1 {
green = 0
}
glctx.Uniform4f(color, 0, green, 0, 1)
glctx.Uniform2f(offset, touchX/float32(sz.WidthPx), touchY/float32(sz.HeightPx))
glctx.BindBuffer(gl.ARRAY_BUFFER, buf)
glctx.EnableVertexAttribArray(position)
glctx.VertexAttribPointer(position, coordsPerVertex, gl.FLOAT, false, 0, 0)
glctx.DrawArrays(gl.TRIANGLES, 0, vertexCount)
glctx.DisableVertexAttribArray(position)
fps.Draw(sz)
}
示例6: U4f
func (prg Program) U4f(ctx gl.Context, dst gl.Uniform, v0, v1, v2, v3 float32) {
ctx.Uniform4f(dst, v0, v1, v2, v3)
}