当前位置: 首页>>代码示例>>Golang>>正文


Golang sdl.Quit函数代码示例

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


在下文中一共展示了Quit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {

	flag.Parse()

	var done bool
	var keys []uint8

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(640, 480, 16, sdl.OPENGL|sdl.RESIZABLE)

	if screen == nil {
		sdl.Quit()
		panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
	}

	sdl.WM_SetCaption("Gears", "gears")

	init_()
	reshape(int(screen.W), int(screen.H))
	done = false
	for !done {
		var event sdl.Event

		idle()
		for event.Poll() {
			switch event.Type {
			case sdl.VIDEORESIZE:
				screen = sdl.SetVideoMode(int(event.Resize().W), int(event.Resize().H), 16,
					sdl.OPENGL|sdl.RESIZABLE)
				if screen != nil {
					reshape(int(screen.W), int(screen.H))
				} else {
					panic("we couldn't set the new video mode??")
				}
				break

			case sdl.QUIT:
				done = true
				break
			}
		}
		keys = sdl.GetKeyState()

		handleKeyPress(keys)
		if keys[sdl.K_ESCAPE] != 0 {
			done = true
		}

		draw()
	}
	sdl.Quit()
	return

}
开发者ID:yohcop,项目名称:cubopolis.go,代码行数:55,代码来源:main.go

示例2: Quit

// release/destroy our resources and restoring the old desktop
func Quit(status int) {
	// clean up the window
	sdl.Quit()

	// and exit appropriately
	os.Exit(status)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:8,代码来源:lesson01.go

示例3: initdec

func initdec() {
	initnum--

	if initnum == 0 {
		sdl.Quit()
	}
}
开发者ID:GunioRobot,项目名称:Go-SDL,代码行数:7,代码来源:gui.go

示例4: main

func main() {

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(640, 480, 32, sdl.OPENGL)

	if screen == nil {
		panic("sdl error")
	}

	if gl.Init() != 0 {
		panic("glew error")
	}

	pen := Pen{}

	gl.MatrixMode(gl.PROJECTION)

	gl.Viewport(0, 0, gl.GLsizei(screen.W), gl.GLsizei(screen.H))
	gl.LoadIdentity()
	gl.Ortho(0, gl.GLdouble(screen.W), gl.GLdouble(screen.H), 0, -1.0, 1.0)

	gl.ClearColor(1, 1, 1, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	var running = true

	for running {

		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
				break
			case sdl.KEYDOWN:
				running = false
				break
			case sdl.MOUSEMOTION:
				me := e.MouseMotion()
				if me.State != 0 {
					pen.lineTo(Point{int(me.X), int(me.Y)})
				} else {
					pen.moveTo(Point{int(me.X), int(me.Y)})
				}
				break
			}
		}

		sdl.GL_SwapBuffers()
		sdl.Delay(25)
	}

	sdl.Quit()

}
开发者ID:krakensden,项目名称:Go-OpenGL,代码行数:57,代码来源:draw.go

示例5: main

func main() {
	initialWidth, initialHeight := 1280, 720
	runtime.LockOSThread()
	if sdlInit := sdl.Init(sdl.INIT_VIDEO); sdlInit != 0 {
		panic("SDL init error")
	}
	reinitScreen(initialWidth, initialHeight)
	defer cleanExit(true, false)
	if err := gl.Init(); err != nil {
		panic(err)
	}
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Enable(gl.DEPTH)
	defer cleanExit(false, true)
	glSetupShaderProg(&shaderTextureCreator, false)
	glSetupShaderProg(&shaderTextureDisplay, true)
	glFillBuffer(rttVerts, &rttVertBuf)
	glFillBuffer(dispVerts, &dispVertBuf)
	gl.GenTextures(1, &rttFrameTex)
	gl.BindTexture(gl.TEXTURE_2D, rttFrameTex)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
	if doRtt {
		gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize, texSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, nil)
		gl.GenFramebuffers(1, &rttFrameBuf)
		gl.BindFramebuffer(gl.FRAMEBUFFER, rttFrameBuf)
		gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, rttFrameTex, 0)
		gl.BindFramebuffer(gl.FRAMEBUFFER, 0)
	} else {
		glFillTextureFromImageFile("texture.jpg")
	}
	gl.BindTexture(gl.TEXTURE_2D, 0)
	gl.ClearColor(0.3, 0.6, 0.9, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.ActiveTexture(gl.TEXTURE0)
	for {
		if evt := sdl.PollEvent(); evt != nil {
			switch event := evt.(type) {
			case *sdl.ResizeEvent:
				reinitScreen(int(event.W), int(event.H))
			case *sdl.QuitEvent:
				return
			}
		} else {
			if doRtt {
				renderToTexture()
			}
			renderToScreen()
			sdl.GL_SwapBuffers()
		}
	}

	sdl.Quit()
}
开发者ID:hyl87,项目名称:2011_Go_Geo_Gfx,代码行数:57,代码来源:basicglfw.go

示例6: main

func main() {

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(640, 480, 32, sdl.OPENGL)

	if screen == nil {
		panic("sdl error")
	}

	if gl.Init() != 0 {
		panic("gl error")
	}

	pen := Pen{}

	gl.MatrixMode(gl.PROJECTION)

	gl.Viewport(0, 0, int(screen.W), int(screen.H))
	gl.LoadIdentity()
	gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)

	gl.ClearColor(1, 1, 1, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	var running = true

	for running {

		for e := sdl.PollEvent(); e != nil; e = sdl.PollEvent() {
			switch ev := e.(type) {
			case *sdl.QuitEvent:
				running = false
			case *sdl.KeyboardEvent:
				if ev.Keysym.Sym == sdl.K_ESCAPE {
					running = false
				}
			case *sdl.MouseMotionEvent:
				if ev.State != 0 {
					pen.lineTo(Point{int(ev.X), int(ev.Y)})
				} else {
					pen.moveTo(Point{int(ev.X), int(ev.Y)})
				}
			}
		}

		sdl.GL_SwapBuffers()
		sdl.Delay(25)
	}

	sdl.Quit()

}
开发者ID:losinggeneration,项目名称:opengl,代码行数:53,代码来源:draw.go

示例7: Init

func (engine *SDLEngine) Init(settings *GraphicsSettings) os.Error {
	runtime.LockOSThread()

	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		return os.NewError("unable to initialize sdl.")
	}

	if sdl.GL_SetAttribute(sdl.GL_DOUBLEBUFFER, 1) != 0 {
		sdl.Quit()
		return os.NewError("double buffering not available.")
	}

	engine.screen = sdl.SetVideoMode(settings.Width, settings.Height, 16, sdl.OPENGL|sdl.RESIZABLE)
	if engine.screen == nil {
		sdl.Quit()
		return os.NewError("unable to set video mode.")
	}

	sdl.WM_SetCaption(settings.Caption, settings.Caption)

	engine.gdevice = NewOpenGLGraphicsDevice()

	return nil
}
开发者ID:chsc,项目名称:g3,代码行数:24,代码来源:sdl_engine.go

示例8: main

func main() {
	if sdl.Init(sdl.INIT_VIDEO) != 0 {
		fmt.Println(sdl.GetError())
		return
	}
	defer sdl.Quit()

	if sdl.SetVideoMode(200, 200, 32, 0) == nil {
		fmt.Println(sdl.GetError())
		return
	}

	for e := new(sdl.Event); e.Wait() && e.Type != sdl.QUIT; {
	}
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:15,代码来源:window-creation-2.go

示例9: Exit

//Release all resources
func (game *Game) Exit() {
	freeResources()

	//Destroy the renderer
	game.renderer.Release()

	//Destroy the window
	sdl.DestroyWindow(game.window)

	//Quit SDL_ttf
	sdl.QuitTTF()

	//Quit SDL
	sdl.Quit()
}
开发者ID:WaylandGod,项目名称:Go2D,代码行数:16,代码来源:game.go

示例10: main

func main() {

	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}

	var screen = sdl.SetVideoMode(640, 480, 32, 0)

	if screen == nil {
		panic(sdl.GetError())
	}

	sdl.WM_SetCaption("Template", "")

	running := true

	for running {

		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
				break
			default:
			}
		}

		screen.FillRect(nil, 0x000000)

		//screen.Blit(&sdl.Rect{x,y, 0, 0}, image, nil)

		screen.Flip()
		sdl.Delay(25)

	}

	sdl.Quit()

}
开发者ID:Daminvar,项目名称:Go-SDL,代码行数:41,代码来源:template.go

示例11: main

func main() {
	fmt.Println("loaded", len(blokus.Tiles), "shapes")
	blokus.Board[2][4] = blokus.Red
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}
	resize(640, 480)
	sdl.WM_SetCaption("Blokus", "")

	for running {
		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
			case sdl.KEYDOWN:
				keyDown(e.Keyboard())
			case sdl.KEYUP:
				keyUp(e.Keyboard())
			case sdl.MOUSEBUTTONDOWN:
				mouseDown(e.MouseButton())
			case sdl.VIDEORESIZE:
				r := e.Resize()
				resize(int(r.W), int(r.H))
			default:
			}
			if !running {
				break
			}
		}

		draw()

		sdl.Delay(25)
	}

	sdl.Quit()
}
开发者ID:thejoshwolfe,项目名称:blokus,代码行数:39,代码来源:main.go

示例12: main

func main() {

	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}

	if ttf.Init() != 0 {
		panic(sdl.GetError())
	}

	if mixer.OpenAudio(mixer.DEFAULT_FREQUENCY, mixer.DEFAULT_FORMAT,
		mixer.DEFAULT_CHANNELS, 4096) != 0 {
		panic(sdl.GetError())
	}

	var screen = sdl.SetVideoMode(640, 480, 32, sdl.RESIZABLE)

	if screen == nil {
		panic(sdl.GetError())
	}

	var video_info = sdl.GetVideoInfo()

	println("HW_available = ", video_info.HW_available)
	println("WM_available = ", video_info.WM_available)
	println("Video_mem = ", video_info.Video_mem, "kb")

	sdl.EnableUNICODE(1)

	sdl.WM_SetCaption("Go-SDL SDL Test", "")

	image := sdl.Load("test.png")

	if image == nil {
		panic(sdl.GetError())
	}

	sdl.WM_SetIcon(image, nil)

	running := true

	font := ttf.OpenFont("Fontin Sans.otf", 72)

	if font == nil {
		panic(sdl.GetError())
	}

	font.SetStyle(ttf.STYLE_UNDERLINE)
	white := sdl.Color{255, 255, 255, 0}
	text := ttf.RenderText_Blended(font, "Test (with music)", white)
	music := mixer.LoadMUS("test.ogg")
	sound := mixer.LoadWAV("sound.ogg")

	if music == nil || sound == nil {
		panic(sdl.GetError())
	}

	music.PlayMusic(-1)

	if sdl.GetKeyName(270) != "[+]" {
		panic("GetKeyName broken")
	}

	worm_in := make(chan Point)
	draw := make(chan Point, 64)

	var out chan Point
	var in chan Point

	out = worm_in

	in = out
	out = make(chan Point)
	go worm(in, out, draw)

	for running {
		for ev := sdl.PollEvent(); ev != nil; ev = sdl.PollEvent() {
			switch e := ev.(type) {
			case *sdl.QuitEvent:
				running = false
				break
			case *sdl.KeyboardEvent:
				println("")
				println(e.Keysym.Sym, ": ", sdl.GetKeyName(sdl.Key(e.Keysym.Sym)))

				if e.Keysym.Sym == 27 {
					running = false
				}

				fmt.Printf("%04x ", e.Type)

				for i := 0; i < len(e.Pad0); i++ {
					fmt.Printf("%02x ", e.Pad0[i])
				}
				println()

				fmt.Printf("Type: %02x Which: %02x State: %02x Pad: %02x\n", e.Type, e.Which, e.State, e.Pad0[0])
				fmt.Printf("Scancode: %02x Sym: %08x Mod: %04x Unicode: %04x\n", e.Keysym.Scancode, e.Keysym.Sym, e.Keysym.Mod, e.Keysym.Unicode)
			case *sdl.MouseButtonEvent:
				if e.Type == sdl.MOUSEBUTTONDOWN {
//.........这里部分代码省略.........
开发者ID:GunioRobot,项目名称:Go-SDL,代码行数:101,代码来源:test.go

示例13: ExitProgram

//=================================
//Praktiske Funktioner
//=================================
func ExitProgram() {
	sdl.Quit()
	os.Exit(0)
	fmt.Println("kage")
}
开发者ID:zozor,项目名称:Cecils-Adventure,代码行数:8,代码来源:main.go

示例14: main

func main() {
	sch = sched.NewScheduler(0)

	flag.Parse()

	cmd := selectCommand(CmdNum)

	SetupVideo()

	// Let the selected command initialize
	cmd.OnSetup()

	// Extract sleep time between frames for this command
	sleeptime := cmd.SleepTime()

	var frames uint32 = 0
	// var t0 uint32 = sdl.GetTicks()
	// 	gt := sdl.GetTicks

	if ShowFPS {
		sch.AddInterval(1.0, 2, func(tc sched.TaskChan, sc *sched.Scheduler) {

			val := <-tc
			if val != sched.RUNNING {
				sc.C <- sched.TaskResult{val, tc}
				return
			}
			sc.C <- sched.TaskResult{sched.COMPLETED, tc}

			// seconds := (t - t0) / 1000.0
			// fps := float(frames) / float(1.0)
			// os.Stdout.WriteString("Fdafsda")
			//sch.LOG <- "FPS"
			// fmt.Println("FPS")
			return
			// t0 = t
			frames = 0

		})
	}

	var running = true

	for running {

		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
				break
			case sdl.KEYDOWN:
				kb := e.Keyboard()
				KeySym = kb.Keysym.Sym
				if KeySym == sdl.K_ESCAPE {
					running = false
				}
				break
			case sdl.MOUSEBUTTONUP, sdl.MOUSEBUTTONDOWN:
				me := e.MouseButton()
				MouseState = me.State
				break
			case sdl.MOUSEMOTION:
				me := e.MouseMotion()
				MouseX = int(me.X)
				MouseY = int(me.Y)
				MouseState = me.State
				break
			case sdl.VIDEORESIZE:
				me := (*sdl.ResizeEvent)(cast(e))
				sdl.SetVideoMode(int(me.W), int(me.H), 32, SDL_FLAGS)
				ResizeWindow(me.W, me.H)
			}
		}

		// sch.Update()
		cmd.OnUpdate()
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		cmd.OnDraw()
		sdl.GL_SwapBuffers()

		if sleeptime != 0 {
			sdl.Delay(uint32(sleeptime))
		}
		frames++
	}

	sdl.Quit()

}
开发者ID:jcd,项目名称:go-gamelib,代码行数:91,代码来源:main.go

示例15: main

func main() {

	flag.Parse()

	var done bool
	var keys []uint8

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(300, 300, 16, sdl.OPENGL|sdl.RESIZABLE)

	if screen == nil {
		sdl.Quit()
		panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
	}

	sdl.WM_SetCaption("Gears", "gears")

	init_()
	reshape(int(screen.W), int(screen.H))
	done = false
	for !done {
		var event sdl.Event

		idle()
		for event.Poll() {
			switch event.Type {
			case sdl.VIDEORESIZE:
				screen = sdl.SetVideoMode(int(event.Resize().W), int(event.Resize().H), 16,
					sdl.OPENGL|sdl.RESIZABLE)
				if screen != nil {
					reshape(int(screen.W), int(screen.H))
				} else {
					panic("we couldn't set the new video mode??")
				}
				break

			case sdl.QUIT:
				done = true
				break
			}
		}
		keys = sdl.GetKeyState()

		if keys[sdl.K_ESCAPE] != 0 {
			done = true
		}
		if keys[sdl.K_UP] != 0 {
			view_rotx += 5.0
		}
		if keys[sdl.K_DOWN] != 0 {
			view_rotx -= 5.0
		}
		if keys[sdl.K_LEFT] != 0 {
			view_roty += 5.0
		}
		if keys[sdl.K_RIGHT] != 0 {
			view_roty -= 5.0
		}
		if keys[sdl.K_z] != 0 {
			if (sdl.GetModState() & sdl.KMOD_RSHIFT) != 0 {
				view_rotz -= 5.0
			} else {
				view_rotz += 5.0
			}
		}

		draw()
	}
	sdl.Quit()
	return

}
开发者ID:DeedleFake,项目名称:Go-OpenGL,代码行数:73,代码来源:gogears.go


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