• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gl21.Clear函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/chsc/gogl/gl21.Clear函数的典型用法代码示例。如果您正苦于以下问题:Golang Clear函数的具体用法?Golang Clear怎么用?Golang Clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Clear函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
	}
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:30,代码来源:gameloop.go


示例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)
}
开发者ID:jacereda,项目名称:webmplay,代码行数:25,代码来源:webmplay.go


示例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()
	}
}
开发者ID:ajhager,项目名称:rog,代码行数:30,代码来源:backend.go


示例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()
}
开发者ID:jaredly,项目名称:rocks,代码行数:7,代码来源:draw.go


示例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()
		}
	}
}
开发者ID:gordonklaus,项目名称:gui,代码行数:32,代码来源:window.go


示例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()
		}
	}
}
开发者ID:gordonklaus,项目名称:flux,代码行数:33,代码来源:window.go


示例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()
	}
}
开发者ID:jayschwa,项目名称:groke,代码行数:33,代码来源:bspview.go


示例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()
}
开发者ID:runningwild,项目名称:arkanoid,代码行数:7,代码来源:level.go


示例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
}
开发者ID:runningwild,项目名称:jbot,代码行数:46,代码来源:main.go


示例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()
	}
}
开发者ID:runningwild,项目名称:jbot,代码行数:45,代码来源:main.go


示例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{})
}
开发者ID:runningwild,项目名称:jota,代码行数:10,代码来源:gui.go


示例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)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:11,代码来源:magnetization.go


示例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)
	}
}
开发者ID:dgthunder,项目名称:glop,代码行数:14,代码来源:gui.go


示例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()
}
开发者ID:dskinner,项目名称:cell,代码行数:16,代码来源:main.go


示例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
	}
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:47,代码来源:GOpenGL.go


示例16: draw

// draw draws the triangle.
func draw() {
	gl.ClearColor(0.3, 0.3, 0.3, 0.0)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.ShadeModel(gl.SMOOTH)

	gl.LoadIdentity()
	gl.Translatef(-15.0, -15.0, 0.0)

	gl.Begin(gl.TRIANGLES)

	gl.Color3f(1.0, 0.0, 0.0)
	gl.Vertex2f(0.0, 0.0)

	gl.Color3f(0.0, 1.0, 0.0)
	gl.Vertex2f(30.0, 0.0)

	gl.Color3f(0.0, 0.0, 1.0)
	gl.Vertex2f(0.0, 30.0)

	gl.End()

	win.SwapBuffers()
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:25,代码来源:opengl.go


示例17: DrawTestScene

func DrawTestScene() {

	ambient := []gl.Float{0.7, 0.7, 0.7, 1}
	diffuse := []gl.Float{1, 1, 1, 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)

	const r = 0.5
	const z = r
	red := color.NRGBA{R: 255, A: 255}
	blue := color.NRGBA{B: 255, A: 255}

	gl.Begin(gl.QUADS)
	(&Poly{[3]float32{0, 0, 0}, [4][3]float32{{-r, -r, z}, {r, -r, z}, {r, r, z}, {-r, r, z}}, red}).Render()
	(&Poly{[3]float32{0, 0, 0}, [4][3]float32{{-r, -r, -z}, {-r, r, -z}, {r, r, -z}, {r, -r, -z}}, blue}).Render()
	gl.End()

}
开发者ID:shenyp09,项目名称:mx3,代码行数:24,代码来源:testscene.go


示例18: main

func main() {
	f, err := os.Create("Go.pprof") // Create file for profiling
	if err != nil {
		panic(err)
	}

	glfw.SetErrorCallback(errorCallback)
	if !glfw.Init() {
		panic("Can't init glfw!")
	}
	defer glfw.Terminate()
	glfw.WindowHint(glfw.Samples, 2)
	glfw.WindowHint(glfw.ContextVersionMajor, 2)
	glfw.WindowHint(glfw.ContextVersionMinor, 1)
	window, err := glfw.CreateWindow(Width, Height, Title, nil, nil)
	if err != nil {
		panic(err)
	}
	window.MakeContextCurrent()

	glfw.SwapInterval(0) // No limit on FPS
	gl.Init()
	initScene()
	loadCubeToGPU()
	for !window.ShouldClose() {
		frameInitT = time.Now()
		movPts(frameDur)
		doWind()
		if spwnTmr >= SpawnInterval {
			spwnPts(SpawnInterval)
			spwnTmr -= SpawnInterval
		}
		if cleanupTmr >= float64(MaxLife)/1000 {
			cleanupPtPool()
			cleanupTmr = 0
		}
		checkColls()
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

		gpuInitT = time.Now()
		renderPts()
		window.SwapBuffers()
		gpuEndT = time.Now()
		glfw.PollEvents()

		frameEndT = time.Now()
		frameDur = frameEndT.Sub(frameInitT).Seconds() // Calculate the length of the previous frame
		spwnTmr += frameDur
		cleanupTmr += frameDur
		runTmr += frameDur
		if runTmr > MaxLife/1000 { // Start collecting framerate data and profiling after a full MaxLife worth of particles have been spawned
			frames[curFrame] = frameDur
			gpuTimes[curFrame] = gpuEndT.Sub(gpuInitT).Seconds()
			curFrame += 1
			pprof.StartCPUProfile(f)
		}
		if runTmr >= RunningTime { // Animation complete; calculate framerate mean and standard deviation
			pprof.StopCPUProfile()
			var sum float64
			var i uint64
			for i = 0; i < curFrame; i++ {
				sum += frames[i]
			}
			frameTimeMean := sum / float64(curFrame)
			fmt.Println("Average framerate was:", 1/frameTimeMean, "frames per second.")

			sum = 0
			for i = 0; i < curFrame; i++ {
				sum += gpuTimes[i]
			}
			gpuTimeMean := sum / float64(curFrame)
			fmt.Println("Average cpu time was-", frameTimeMean-gpuTimeMean, "seconds per frame.")

			sumDiffs := 0.0
			for i = 0; i < curFrame; i++ {
				sumDiffs += math.Pow(1/frames[i]-1/frameTimeMean, 2)
			}
			variance := sumDiffs / float64(curFrame)
			sd := math.Sqrt(variance)
			fmt.Println("The standard deviation was:", sd, "frames per second.")
			if PrintFrames == true {
				fmt.Print("--:")
				for i = 0; i < curFrame; i++ {
					fmt.Print(1 / frames[i])
					fmt.Print(",")
				}
				fmt.Print(".--")
			}
			break
		}

	}
	gl.DisableClientState(gl.NORMAL_ARRAY)
	gl.DisableClientState(gl.VERTEX_ARRAY)
}
开发者ID:ReneSac,项目名称:ParticleBench,代码行数:95,代码来源:Go.go


示例19: main


//.........这里部分代码省略.........

	var chooser gui.Widget
	// curdir := GetStoreVal("curdir")
	// if curdir == "" {
	//   curdir = "."
	// } else {
	//   _,err := os.Stat(filepath.Join(datadir, curdir))
	//   if err == nil {
	//     go func() {
	//       anim, err := sprite.LoadSprite(filepath.Join(datadir, curdir))
	//       loaded <- loadResult{ anim, err }
	//     } ()
	//   } else {
	//     curdir = "."
	//   }
	// }
	// var profile_output *os.File
	then := time.Now()
	sys.Think()
	for key_map["quit"].FramePressCount() == 0 {
		event_handler.box1 = &box
		event_handler.box2 = &box_other
		now := time.Now()
		dt := (now.Nanosecond() - then.Nanosecond()) / 1000000
		then = now
		render.Queue(func() {
			sys.Think()
			if box1.sb.s != nil {
				box1.sb.s.Think(int64(float64(dt) * float64(speed) / 100))
			}
			if box2.sb.s != nil {
				box2.sb.s.Think(int64(float64(dt) * float64(speed) / 100))
			}
			gl.ClearColor(1, 0, 0, 1)
			gl.Clear(gl.COLOR_BUFFER_BIT)
			ui.Draw()
			sys.SwapBuffers()
		})
		render.Purge()
		select {
		case load := <-loaded:
			if load.err != nil {
				error_msg.SetText(load.err.Error())
				current_anim.SetText("")
			} else {
				box.sb.s = load.anim
				error_msg.SetText("")
			}
		default:
		}
		// if box.sb.s != nil {
		//   box.sb.s.Think()
		//   current_anim.SetText(fmt.Sprintf("%d: %s", box.sb.s.Facing(), box.sb.s.Anim()))
		//   current_state.SetText(box.sb.s.AnimState())
		// }

		if box.sb.s != nil {
			if key_map["reset"].FramePressCount() > 0 {
				box.load(box.dir)
				box_other.load(box_other.dir)
			}
		}

		// if key_map["profile"].FramePressCount() > 0 {
		//   if profile_output == nil {
		//     var err error
开发者ID:runningwild,项目名称:tester,代码行数:67,代码来源:main.go


示例20: standardHookup

func standardHookup() {
	g := g2.Make(0, 0, wdx, wdy)
	var tm g2.ThunderMenu
	tm.Subs = make(map[string]*g2.ThunderSubMenu)
	triggers := map[gin.KeyId]struct{}{
		gin.AnyReturn: struct{}{},
		gin.In().GetKeyFlat(gin.ControllerButton0+2, gin.DeviceTypeController, gin.DeviceIndexAny).Id(): struct{}{},
	}
	action := ""
	tm.Subs[""] = g2.MakeThunderSubMenu(
		[]g2.Widget{
			&g2.Button{Size: 50, Triggers: triggers, Name: "Debug", Callback: func() { tm.Push("debug") }},
			&g2.Button{Size: 50, Triggers: triggers, Name: "Host LAN game", Callback: func() { base.Log().Printf("HOST"); print("HOST\n") }},
			&g2.Button{Size: 50, Triggers: triggers, Name: "Join LAN game", Callback: func() { base.Log().Printf("JOIN"); print("JOIN\n") }},
			&g2.Button{Size: 50, Triggers: triggers, Name: "Quit", Callback: func() { action = "Quit" }},
		})

	tm.Subs["debug"] = g2.MakeThunderSubMenu(
		[]g2.Widget{
			&g2.Button{Size: 50, Triggers: triggers, Name: "Standard", Callback: func() { action = "standard" }},
			&g2.Button{Size: 50, Triggers: triggers, Name: "Moba", Callback: func() { action = "moba" }},
			&g2.Button{Size: 50, Triggers: triggers, Name: "Back", Callback: func() { tm.Pop() }},
		})

	tm.Start(500)
	g.AddChild(&tm, g2.AnchorDeadCenter)
	g.AddChild(g2.MakeConsole(wdx, wdy), g2.AnchorDeadCenter)

	t := texture.LoadFromPath(filepath.Join(base.GetDataDir(), "background/buttons1.jpg"))
	for {
		sys.Think()
		if action == "Quit" {
			return
		}
		if action == "standard" || action == "moba" {
			g.StopEventListening()
			engine, local := debugHookup(action)
			mainLoop(engine, local, action)
			g.RestartEventListening()
			action = ""
		}
		render.Queue(func() {
			gl.ClearColor(0, 0, 0, 1)
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
			if true {
				ratio := float64(wdx) / float64(wdy)
				t.RenderAdvanced(-1+(1-1/ratio), -1, 2/ratio, 2, 0, false)
			}
			gl.Disable(gl.TEXTURE_2D)
			base.GetDictionary("luxisr").RenderString("INvASioN!!!", 0, 0.5, 0, 0.03, gui.Center)
		})
		render.Queue(func() {
			g.Draw()
			sys.SwapBuffers()
		})
		render.Purge()
	}
	// 1 Start with a title screen
	// 2 Option to host or join
	// 3a If host then wait for a connection
	// 3b If join then ping and connect
	// 4 Once joined up the 'game' will handle choosing sides and whatnot
}
开发者ID:runningwild,项目名称:magnus,代码行数:63,代码来源:main.go



注:本文中的github.com/chsc/gogl/gl21.Clear函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gl21.Color4ub函数代码示例发布时间:2022-05-23
下一篇:
Golang gl21.BindTexture函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap