本文整理匯總了Golang中github.com/remogatto/mandala.Window.SwapBuffers方法的典型用法代碼示例。如果您正苦於以下問題:Golang Window.SwapBuffers方法的具體用法?Golang Window.SwapBuffers怎麽用?Golang Window.SwapBuffers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/remogatto/mandala.Window
的用法示例。
在下文中一共展示了Window.SwapBuffers方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: renderLoopFunc
// Run runs renderLoop. The loop renders a frame and swaps the buffer
// at each tick received.
func renderLoopFunc(control *renderLoopControl) loop.LoopFunc {
return func(loop loop.Loop) error {
var window mandala.Window
// Lock/unlock the loop to the current OS thread. This is
// necessary because OpenGL functions should be called from
// the same thread.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
// Create an instance of ticker and immediately stop
// it because we don't want to swap buffers before
// initializing a rendering state.
ticker := time.NewTicker(time.Duration(1e9 / int(FRAMES_PER_SECOND)))
ticker.Stop()
for {
select {
case window = <-control.window:
ticker.Stop()
window.MakeContextCurrent()
width, height := window.GetSize()
gl.Viewport(0, 0, width, height)
mandala.Logf("Restarting rendering loop...")
ticker = time.NewTicker(time.Duration(1e9 / int(FRAMES_PER_SECOND)))
// Compute window radius
windowRadius = math.Sqrt(math.Pow(float64(height), 2) + math.Pow(float64(width), 2))
//gl.Init()
gl.Disable(gl.DEPTH_TEST)
// antialiasing
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
//gl.Enable(gl.LINE_SMOOTH)
// At each tick render a frame and swap buffers.
case <-ticker.C:
draw()
window.SwapBuffers()
case event := <-control.pause:
ticker.Stop()
event.Paused <- true
case <-control.resume:
case <-loop.ShallStop():
ticker.Stop()
return nil
}
}
}
}
示例2: renderLoopFunc
// Run runs renderLoop. The loop renders a frame and swaps the buffer
// at each tick received.
func renderLoopFunc(control *renderLoopControl) loop.LoopFunc {
return func(loop loop.Loop) error {
var window mandala.Window
// Lock/unlock the loop to the current OS thread. This is
// necessary because OpenGL functions should be called from
// the same thread.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
// Create an instance of ticker and immediately stop
// it because we don't want to swap buffers before
// initializing a rendering state.
ticker := time.NewTicker(time.Duration(1e9 / int(FRAMES_PER_SECOND)))
ticker.Stop()
for {
select {
case window = <-control.window:
ticker.Stop()
window.MakeContextCurrent()
width, height := window.GetSize()
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
mandala.Logf("Restarting rendering loop...")
ticker = time.NewTicker(time.Duration(1e9 / int(FRAMES_PER_SECOND)))
// At each tick render a frame and swap buffers.
case <-ticker.C:
draw()
window.SwapBuffers()
case event := <-control.pause:
ticker.Stop()
event.Paused <- true
case <-control.resume:
case <-loop.ShallStop():
ticker.Stop()
return nil
}
}
}
}