本文整理匯總了Golang中github.com/chsc/gogl/gl21.Clear函數的典型用法代碼示例。如果您正苦於以下問題:Golang Clear函數的具體用法?Golang Clear怎麽用?Golang Clear使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Clear函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GameLoop
func GameLoop() {
t := 0.0
dt := 0.1
CreateUniverse()
camera.PositionCamera(0, 0, 1000, 900)
for glfw.WindowParam(glfw.Opened) == 1 {
t += dt
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.Clear(gl.DEPTH_BUFFER_BIT | gl.LIGHTING_BIT)
for i := range universe.Systems {
for j := range universe.Systems[i].Planets {
BufferPlanet(universe.Systems[i].Planets[j])
ai.PlanetOrbit(universe.Systems[i].Planets[j], t)
}
for j := range universe.Systems[i].Stars {
BufferStar(universe.Systems[i].Stars[j])
ai.StarStationary(universe.Systems[i].Stars[j], t)
}
}
glfw.SwapBuffers()
}
}
示例2: draw
func (a *app) draw(t time.Time) {
gl.Clear(gl.COLOR_BUFFER_BIT)
img := a.img
w := img.Rect.Dx()
h := img.Rect.Dy()
gl.ActiveTexture(gl.TEXTURE0)
upload(1, img.Y, img.YStride, w, h)
gl.ActiveTexture(gl.TEXTURE1)
upload(2, img.Cb, img.CStride, w/2, h/2)
gl.ActiveTexture(gl.TEXTURE2)
upload(3, img.Cr, img.CStride, w/2, h/2)
if *blend {
pimg := a.pimg
gl.Uniform1f(a.factorloc, factor(t,
a.tbase.Add(pimg.Timecode),
a.tbase.Add(img.Timecode)))
gl.ActiveTexture(gl.TEXTURE3)
upload(4, pimg.Y, pimg.YStride, w, h)
gl.ActiveTexture(gl.TEXTURE4)
upload(5, pimg.Cb, pimg.CStride, w/2, h/2)
gl.ActiveTexture(gl.TEXTURE5)
upload(6, pimg.Cr, pimg.CStride, w/2, h/2)
}
gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
}
示例3: Render
func (w *glfwBackend) Render(console *Console) {
if w.Running() {
w.mouse.Left.Released = false
w.mouse.Right.Released = false
w.mouse.Middle.Released = false
w.key = NOKEY
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.BindTexture(gl.TEXTURE_2D, textures[1])
for y := 0; y < console.Height(); y++ {
for x := 0; x < console.Width(); x++ {
_, bg, _ := console.Get(x, y)
w.letter(x, y, 0, bg)
}
}
gl.BindTexture(gl.TEXTURE_2D, textures[0])
for y := 0; y < console.Height(); y++ {
for x := 0; x < console.Width(); x++ {
fg, _, ch := console.Get(x, y)
if position, ok := w.font.Map(ch); ok {
w.letter(x, y, position, fg)
}
}
}
glfw.SwapBuffers()
}
}
示例4: drawScene
func drawScene(draw func()) {
// gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
draw()
gl.Finish()
}
示例5: run
func (w *Window) run(init func(w *Window)) {
runtime.LockOSThread()
glfw.MakeContextCurrent(w.w)
defer glfw.MakeContextCurrent(nil)
init(w)
// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
w.resized(w.w.Size())
w.framebufferResized(w.w.FramebufferSize())
gl.Enable(gl.SCISSOR_TEST)
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
for !w.close {
select {
case f := <-w.do:
f()
case <-w.paint:
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Scissor(0, 0, w.bufWidth, w.bufHeight)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.base().paint()
w.w.SwapBuffers()
}
}
}
示例6: run
func (w *Window) run() {
runtime.LockOSThread()
glfw.MakeContextCurrent(w.w)
defer glfw.MakeContextCurrent(nil)
// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
width, height := w.w.Size()
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(width), 0, gl.Double(height), -1, 1)
Resize(w, Pt(float64(width), float64(height)))
width, height = w.w.FramebufferSize()
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
for !w.close {
select {
case f := <-w.do:
f()
case <-w.paint:
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.base().paint()
w.w.SwapBuffers()
}
}
}
示例7: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Rotated(-90, 1, 0, 0)
//gl.Rotated(90, 0, 0, 1)
gl.Rotated(gl.Double(-viewAngles[2]), 1, 0, 0)
gl.Rotated(gl.Double(-viewAngles[0]), 0, 1, 0)
gl.Rotated(gl.Double(-viewAngles[1]), 0, 0, 1)
gl.Translated(gl.Double(viewOrg[0]), gl.Double(viewOrg[1]), gl.Double(viewOrg[2]))
var r, g, b gl.Ubyte
for i, face := range model.Faces {
r = gl.Ubyte(i) + 100
g = gl.Ubyte(i>>1) + 100
b = gl.Ubyte(i>>2) + 100
if model.Triangle {
gl.Begin(gl.TRIANGLES)
} else {
gl.Begin(gl.LINES)
}
gl.Color4ub(r, g, b, 0xff)
for _, v := range face.Verts {
gl.Vertex3d(gl.Double(v.Pos[0]), gl.Double(v.Pos[1]), gl.Double(v.Pos[2]))
}
gl.End()
}
}
示例8: Render
func (l *Level) Render() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
SetUpCamera(800, 600, l.LevelBlueprint, 0)
l.levelVertexBuffer.Render(Point3{0, 0, 0})
l.Paddle.Render()
l.Ball.Render()
}
示例9: getPlayers
func getPlayers(console *base.Console) []gin.DeviceId {
var ct controllerTracker
gin.In().RegisterEventListener(&ct)
defer gin.In().UnregisterEventListener(&ct)
ticker := time.Tick(time.Millisecond * 17)
start := time.Time{}
readyDuration := time.Second * 2
for start.IsZero() || time.Now().Sub(start) < readyDuration {
<-ticker
sys.Think()
if ct.Ready() && start.IsZero() {
start = time.Now()
}
if !ct.Ready() {
start = time.Time{}
}
render.Queue(func() {
defer console.Draw(0, 0, wdx, wdy)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Disable(gl.DEPTH_TEST)
gui.SetFontColor(1, 1, 1, 1)
gl.Disable(gl.TEXTURE_2D)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num players: %d", len(ct.ids)), float64(wdx)/2, 300, 0, 100, gui.Center)
base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num ready: %d", ct.NumReady()), float64(wdx)/2, 400, 0, 100, gui.Center)
if !start.IsZero() {
base.GetDictionary("crackin").RenderString(fmt.Sprintf("Starting in %2.2f", (readyDuration-time.Now().Sub(start)).Seconds()), float64(wdx)/2, 500, 0, 100, gui.Center)
}
})
render.Queue(func() {
sys.SwapBuffers()
})
render.Purge()
}
var devices []gin.DeviceId
for id := range ct.ids {
devices = append(devices, id)
}
return devices
}
示例10: mainLoop
func mainLoop(client sgf.ClientEngine, controllers []gin.DeviceId, console *base.Console) {
client.MakeRequest(game.Join{Rebels: make([]*game.RebelPlayer, 2)})
ticker := time.Tick(time.Millisecond * 17)
render.Queue(func() {
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
})
for {
<-ticker
if gin.In().GetKey(gin.AnyEscape).FramePressCount() != 0 {
return
}
sys.Think()
render.Queue(func() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Disable(gl.DEPTH_TEST)
gui.SetFontColor(1, 1, 1, 1)
gl.Disable(gl.TEXTURE_2D)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
base.GetDictionary("crackin").RenderString("Waiting on some nubs", float64(wdx)/2, 300, 0, 100, gui.Center)
})
client.RLock()
g := client.Game().(*game.Game)
mode := g.Mode
client.RUnlock()
if mode == game.ModeWaiting {
} else if mode == game.ModeProgram {
programLoop(client, controllers, console)
} else if mode == game.ModeRun {
}
render.Queue(func() {
sys.SwapBuffers()
})
render.Purge()
}
}
示例11: Draw
func (g *Gui) Draw() {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(gl.Double(g.region.X), gl.Double(g.region.X+g.region.Dx), gl.Double(g.region.Y+g.region.Dy), gl.Double(g.region.Y), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
g.root.Draw(g.region, &styleStack{})
}
示例12: ClearScene
func ClearScene() {
ambient := []gl.Float{0.7, 0.7, 0.7, 1}
diffuse := []gl.Float{0.9, 0.9, 0.9, 1}
lightpos := []gl.Float{0.2, 0.5, 1, 1}
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0])
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0])
gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightpos[0])
gl.Enable(gl.LIGHT0)
gl.ClearColor(1, 1, 1, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
}
示例13: Draw
func (g *Gui) Draw() {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
region := g.root.Render_region
gl.Ortho(gl.Double(region.X), gl.Double(region.X+region.Dx), gl.Double(region.Y), gl.Double(region.Y+region.Dy), 1000, -1000)
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
g.root.Draw(region)
if g.FocusWidget() != nil {
g.FocusWidget().DrawFocused(region)
}
}
示例14: drawScene
func drawScene() {
fps()
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
if input.Zoom > 0 {
gl.Ortho(0, gl.Double(float64(*flagSize)/input.Zoom), gl.Double(float64(*flagSize)/input.Zoom), 0, -1, 1.0)
}
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(gl.Float(input.TransX*1), gl.Float(input.TransY*1), 0)
drawGrid()
drawCells()
}
示例15: Init
func (o *OpenGl) Init() {
if err := glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.Terminate()
if err := glfw.OpenWindow(o.width, o.height, 0, 0, 0, 0, 16, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "glfw: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(o.title)
if err := gl.Init(); err != nil {
fmt.Fprintf(os.Stderr, "gl: %s\n", err)
}
glfw.SetKeyCallback(glfw.KeyHandler(o.keyboard))
glfw.SetMouseButtonCallback(glfw.MouseButtonHandler(o.mouseClick))
glfw.SetMousePosCallback(glfw.MousePosHandler(o.mouseMove))
glfw.SetMouseWheelCallback(glfw.MouseWheelHandler(o.mouseWheel))
if err := o.initScene(); err != nil {
fmt.Fprintf(os.Stderr, "init: %s\n", err)
return
}
for glfw.WindowParam(glfw.Opened) == 1 {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
if o.display3d != nil {
o.set3dView()
o.display3d()
}
if o.display2d != nil {
o.set2dView()
o.display2d()
}
glfw.SwapBuffers()
time.Sleep(20 * time.Millisecond)
//<-o.redisplay
}
}