本文整理汇总了Golang中golang.org/x/mobile/gl.Context.Enable方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Enable方法的具体用法?Golang Context.Enable怎么用?Golang Context.Enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/mobile/gl.Context
的用法示例。
在下文中一共展示了Context.Enable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: onStart
func onStart(glctx gl.Context, sz size.Event) {
log.Printf("creating GL program")
var err error
keystate = map[touch.Sequence]int{}
program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
if err != nil {
log.Printf("error creating GL program: %v", err)
return
}
glctx.Enable(gl.DEPTH_TEST)
position = glctx.GetAttribLocation(program, "position")
texCordIn = glctx.GetAttribLocation(program, "texCordIn")
color = glctx.GetUniformLocation(program, "color")
drawi = glctx.GetUniformLocation(program, "drawi")
projection = glctx.GetUniformLocation(program, "projection")
camera = glctx.GetUniformLocation(program, "camera")
loadTexture(glctx)
glctx.UseProgram(program)
projectionMat := mgl32.Perspective(mgl32.DegToRad(75.0), float32(1), 0.5, 40.0)
glctx.UniformMatrix4fv(projection, projectionMat[:])
cameraMat := mgl32.LookAtV(mgl32.Vec3{0.5, 0, 1.5}, mgl32.Vec3{0, 0, 0}, mgl32.Vec3{0, 1, 0})
glctx.UniformMatrix4fv(camera, cameraMat[:])
board = NewBoard(glctx, float32(0.05), 10)
numKeys := len(board.bigKeys) + len(board.smallKeys)
InitializeSound(numKeys)
}
示例2: onStart
func onStart(ctx gl.Context) {
env.SetPalette(material.Palette{
Primary: material.BlueGrey500,
Dark: material.BlueGrey700,
Light: material.BlueGrey100,
Accent: material.DeepOrangeA200,
})
quits = []chan struct{}{}
sig = make(snd.Discrete, len(material.ExpSig))
copy(sig, material.ExpSig)
rsig := make(snd.Discrete, len(material.ExpSig))
copy(rsig, material.ExpSig)
rsig.UnitInverse()
sig = append(sig, rsig...)
sig.NormalizeRange(0, 1)
ctx.Enable(gl.BLEND)
ctx.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
ctx.Enable(gl.CULL_FACE)
ctx.CullFace(gl.BACK)
env.Load(ctx)
for i := range boxes {
boxes[i] = env.NewMaterial(ctx)
boxes[i].SetColor(material.BlueGrey200)
}
}
示例3: useOp
func useOp(glctx gl.Context, op draw.Op) {
if op == draw.Over {
glctx.Enable(gl.BLEND)
glctx.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
} else {
glctx.Disable(gl.BLEND)
}
}
示例4: main
func main() {
app.Main(func(a app.App) {
var glctx gl.Context
var sz size.Event
for e := range a.Events() {
switch e := a.Filter(e).(type) {
case lifecycle.Event:
switch e.Crosses(lifecycle.StageVisible) {
case lifecycle.CrossOn:
glctx, _ = e.DrawContext.(gl.Context)
// transparency of png
glctx.Enable(gl.BLEND)
glctx.BlendEquation(gl.FUNC_ADD)
glctx.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
onStart(glctx)
a.Send(paint.Event{})
case lifecycle.CrossOff:
onStop()
glctx = nil
}
case size.Event:
sz = e
case paint.Event:
if glctx == nil || e.External {
continue
}
switch sceneId {
case 0:
Title.Apply()
case 1:
Gopher.Apply()
Ball.MoveWithReflection()
Ball.Apply()
}
onPaint(glctx, sz)
a.Publish()
a.Send(paint.Event{}) // keep animating
case touch.Event:
switch sceneId {
case 1:
Gopher.Move(e.X, e.Y)
Gopher.Rotate(Gopher.radian + 5)
//Gopher.Size(Gopher.width, Gopher.height)
}
if e.Type == touch.TypeEnd {
sceneId = 1
loadScene(sceneId)
}
}
}
})
}
示例5: onStart
func onStart(glctx gl.Context) {
var err error
program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
if err != nil {
log.Printf("error creating GL program: %v", err)
return
}
glctx.Enable(gl.DEPTH_TEST)
triBuf = glctx.CreateBuffer()
glctx.BindBuffer(gl.ARRAY_BUFFER, triBuf)
glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)
position = glctx.GetAttribLocation(program, "vPos")
color = glctx.GetAttribLocation(program, "vCol")
normals = glctx.GetAttribLocation(program, "vNorm")
projection = glctx.GetUniformLocation(program, "proj")
view = glctx.GetUniformLocation(program, "view")
model = glctx.GetUniformLocation(program, "model")
tint = glctx.GetUniformLocation(program, "tint")
normalMatrix = glctx.GetUniformLocation(program, "normalMatrix")
lightIntensity = glctx.GetUniformLocation(program, "light.intensities")
lightPos = glctx.GetUniformLocation(program, "light.position")
arcball = NewArcBall(mgl32.Vec3{0, 0, 0}, mgl32.Vec3{0, 10, 10}, mgl32.Vec3{0, 1, 0})
white = mgl32.Vec4{1.0, 1.0, 1.0, 1.0}
red = mgl32.Vec4{1.0, 0.0, 0.0, 1.0}
lastUpdate = time.Now()
images = glutil.NewImages(glctx)
fps = debug.NewFPS(images)
err = al.OpenDevice()
if err != nil {
log.Printf("Err: %+v", err)
}
al.SetListenerPosition(al.Vector{0, 0, 0})
al.SetListenerGain(1.0)
piano = NewPiano()
}
示例6: onStart
func onStart(ctx gl.Context) {
ctx.Enable(gl.BLEND)
ctx.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
if err := al.OpenDevice(buffers); err != nil {
log.Fatal(err)
}
var err error
keymix = snd.NewMixer()
go makekeys()
lowpass = snd.NewLowPass(773, keymix)
keygain = snd.NewGain(snd.Decibel(-3).Amp(), lowpass)
dly := snd.NewDelay(29*time.Millisecond, keygain)
tap0 := snd.NewTap(19*time.Millisecond, dly)
tap1 := snd.NewTap(13*time.Millisecond, dly)
tap2 := snd.NewTap(7*time.Millisecond, dly)
cmb := snd.NewComb(snd.Decibel(-3).Amp(), 11*time.Millisecond, snd.NewMixer(dly, tap0, tap1, tap2))
reverb = snd.NewLowPass(2000, cmb)
dlymix := snd.NewMixer(reverb, keygain)
loop = snd.NewLoopFrames(loopdur, dlymix)
loop.SetBPM(bpm)
loopmix := snd.NewMixer(dlymix, loop)
master = snd.NewMixer(loopmix)
mastergain = snd.NewGain(snd.Decibel(-6).Amp(), master)
mixwf, err = snd.NewWaveform(ctx, 2, mastergain)
if err != nil {
log.Fatal(err)
}
pan := snd.NewPan(0, mixwf)
mtrosc := snd.NewOscil(sine, 440, nil)
mtrdmp := snd.NewDamp(bpm.Dur(), mtrosc)
metronome = snd.NewMixer(mtrdmp)
metronome.Off()
master.Append(metronome)
piano = NewPiano()
pianowf, err = snd.NewWaveform(ctx, 1, piano)
if err != nil {
log.Fatal(err)
}
al.AddSource(pan)
yoff := float32(-0) //.12)
btnreverb = snd.NewButton(ctx, -0.98, 0.96+yoff, 0.2, -0.2)
btnreverb.SetActiveColor(0, 1, 0, 0.5)
btnreverb.SetActive(true)
btnlowpass = snd.NewButton(ctx, -0.76, 0.96+yoff, 0.2, -0.2)
btnlowpass.SetActiveColor(0, 1, 1, 0.5)
btnlowpass.SetActive(true)
btnmetronome = snd.NewButton(ctx, -0.54, 0.96+yoff, 0.2, -0.2)
btnmetronome.SetActiveColor(0, 0, 1, 0.5)
btnloop = snd.NewLoopButton(snd.NewButton(ctx, -0.32, 0.96+yoff, 0.2, -0.2), loop)
btnloop.SetActiveColor(1, 0, 0, 0.5)
btnsndbank = snd.NewButton(ctx, 0.78, 0.96+yoff, 0.2, -0.2)
btnsndbank.SetActive(true)
btnsndbank.SetActiveColor(sndbankcolor())
}
示例7: onStart
func onStart(ctx gl.Context) {
ctx.Enable(gl.BLEND)
ctx.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
ctx.Enable(gl.CULL_FACE)
ctx.CullFace(gl.BACK)
if err := al.OpenDevice(buffers); err != nil {
log.Fatal(err)
}
env.Load(ctx)
env.LoadIcons(ctx)
env.LoadGlyphs(ctx)
toolbar = env.NewToolbar(ctx)
toolbar.Title.SetText("piano")
toolbar.Title.SetTextColor(material.White)
toolbar.Nav.SetIconColor(material.White)
btnLoop := env.NewButton(ctx)
toolbar.AddAction(btnLoop)
btnLoop.SetIcon(icon.AvFiberSmartRecord)
btnLoop.SetIconColor(material.White)
btnLoop.OnPress = func() {
if loop.Recording() {
btnLoop.SetIconColor(material.White)
loop.Stop()
} else {
btnLoop.SetIconColor(env.Palette().Accent)
loop.Record()
}
}
btnMetronome := env.NewButton(ctx)
toolbar.AddAction(btnMetronome)
btnMetronome.SetIcon(icon.AvSlowMotionVideo)
btnMetronome.SetIconColor(material.White)
btnMetronome.OnPress = func() {
if metronome.IsOff() {
metronome.On()
btnMetronome.SetIconColor(env.Palette().Accent)
} else {
metronome.Off()
btnMetronome.SetIconColor(material.White)
}
}
btnLowpass := env.NewButton(ctx)
toolbar.AddAction(btnLowpass)
btnLowpass.SetIcon(icon.AvSubtitles)
btnLowpass.SetIconColor(env.Palette().Accent)
btnLowpass.OnPress = func() {
lowpass.SetPassthrough(!lowpass.Passthrough())
if lowpass.Passthrough() {
btnLowpass.SetIconColor(material.White)
} else {
btnLowpass.SetIconColor(env.Palette().Accent)
}
}
btnReverb := env.NewButton(ctx)
toolbar.AddAction(btnReverb)
btnReverb.SetIcon(icon.AvSurroundSound)
btnReverb.SetIconColor(env.Palette().Accent)
btnReverb.OnPress = func() {
if reverb.IsOff() {
reverb.On()
keygain.SetAmp(snd.Decibel(-3).Amp())
btnReverb.SetIconColor(env.Palette().Accent)
} else {
reverb.Off()
keygain.SetAmp(snd.Decibel(3).Amp())
btnReverb.SetIconColor(material.White)
}
}
btnNext = env.NewFloatingActionButton(ctx)
btnNext.Mini = true
btnNext.SetColor(env.Palette().Accent)
btnNext.SetIcon(icon.AvSkipNext)
btnNext.OnPress = func() {
sndbankpos = (sndbankpos + 1) % len(sndbank)
go makekeys()
}
decor = env.NewMaterial(ctx)
decor.SetColor(material.BlueGrey900)
tseq := make(map[touch.Sequence]int)
for i := range btnkeys {
btnkeys[i] = env.NewButton(ctx)
j := i
btnkeys[i].OnTouch = func(ev touch.Event) {
switch ev.Type {
case touch.TypeBegin:
keys[j].Press()
tseq[ev.Sequence] = j
case touch.TypeMove:
// TODO drag finger off piano and it still plays, should stop
//.........这里部分代码省略.........