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


Golang sdl.Quit函数代码示例

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


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

示例1: Run

func (dmg *DMG) Run(file string, width, height int) {
	sdl.Init(sdl.INIT_VIDEO)
	defer sdl.Quit()

	dmg.init(file, width, height)
	dmg.exec()
}
开发者ID:jlukacs,项目名称:gameboy,代码行数:7,代码来源:DMG.go

示例2: main

func main() {
	if err := sdl.Init(sdl.INIT_AUDIO); err != nil {
		log.Println(err)
		return
	}

	if err := mix.Init(mix.INIT_MP3); err != nil {
		log.Println(err)
		return
	}
	defer sdl.Quit()
	defer mix.Quit()
	defer mix.CloseAudio()

	if err := mix.OpenAudio(22050, mix.DEFAULT_FORMAT, 2, 4096); err != nil {
		log.Println(err)
		return
	}

	if music, err := mix.LoadMUS("test.mp3"); err != nil {
		log.Println(err)
	} else if err = music.Play(1); err != nil {
		log.Println(err)
	} else {
		sdl.Delay(5000)
		music.Free()
	}
}
开发者ID:4gophers,项目名称:go-sdl2,代码行数:28,代码来源:audio_mp3.go

示例3: Destroy

/*
Destroy the controller object.
*/
func (c *Controller) Destroy() {
	c.window.Destroy()
	// TODO can I call this anywhere? is this... ok?
	sdl.Quit()
	// MUST unlock OS thread
	runtime.UnlockOSThread()
}
开发者ID:xamino,项目名称:orbengine,代码行数:10,代码来源:controller.go

示例4: Start

func (gui *Gui) Start() {
	window, err := sdl.CreateWindow(
		"nice life",
		sdl.WINDOWPOS_UNDEFINED,
		sdl.WINDOWPOS_UNDEFINED,
		gui.cam.width,
		gui.cam.height,
		sdl.WINDOW_SHOWN|sdl.WINDOW_RESIZABLE)

	if err != nil {
		panic(err)
	}

	surface, err := window.GetSurface()
	if err != nil {
		panic(err)
	}

	gui.sdlWindow = window
	gui.sdlSurface = surface

	go gui.handleInput()

	gui.mainLoop()
	sdl.Quit()
}
开发者ID:jrforrest,项目名称:go-nicelife,代码行数:26,代码来源:gui.go

示例5: Close

func (d *Display) Close() {
	if d.renderer != nil {
		d.renderer.Destroy()
	}

	if d.window != nil {
		d.window.Destroy()
	}

	sdl.Quit()
}
开发者ID:kierdavis,项目名称:anna,代码行数:11,代码来源:display.go

示例6: main

func main() {
	var winTitle string = "Go-SDL2 + Go-GL"
	var winWidth, winHeight int = 800, 600
	var window *sdl.Window
	var context sdl.GLContext
	var event sdl.Event
	var running bool
	var err error

	if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
		panic(err)
	}
	defer sdl.Quit()

	if err = gl.Init(); err != nil {
		panic(err)
	}

	window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
		winWidth, winHeight, sdl.WINDOW_OPENGL)
	if err != nil {
		panic(err)
	}
	defer window.Destroy()
	context, err = sdl.GL_CreateContext(window)
	if err != nil {
		panic(err)
	}
	defer sdl.GL_DeleteContext(context)

	gl.Enable(gl.DEPTH_TEST)
	gl.ClearColor(0.2, 0.2, 0.3, 1.0)
	gl.ClearDepth(1)
	gl.DepthFunc(gl.LEQUAL)
	gl.Viewport(0, 0, int32(winWidth), int32(winHeight))

	running = true
	for running {
		for event = sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
			switch t := event.(type) {
			case *sdl.QuitEvent:
				running = false
			case *sdl.MouseMotionEvent:
				fmt.Printf("[%d ms] MouseMotion\tid:%d\tx:%d\ty:%d\txrel:%d\tyrel:%d\n", t.Timestamp, t.Which, t.X, t.Y, t.XRel, t.YRel)
			}
		}
		drawgl()
		sdl.GL_SwapWindow(window)
	}
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:50,代码来源:opengl.go

示例7: main

func main() {
	flag.Parse()
	//	go doesMyCodeWork()
	//	go doesMyCodeWork2()

	var x, y int
	if len(os.Args) < 3 {
		fmt.Println("No size was specified, using defaults")
		x = int(640 * 1.5)
		y = int(480 * 1.5)
	} else {
		var err error
		x, err = strconv.Atoi(os.Args[1])
		if err != nil {
			fmt.Println("Could not parse " + os.Args[1] + " to int!")
			return
		}
		y, err = strconv.Atoi(os.Args[2])
		if err != nil {
			fmt.Println("Could not parse " + os.Args[2] + " to int!")
			return
		}
	}
	window, err := sdl.CreateWindow("Campus Fighter I", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, x, y, sdl.WINDOWPOS_UNDEFINED)
	if err != nil {
		panic(err)
	}
	defer window.Destroy()
	//sdl.ShowCursor(0)
	window.UpdateSurface()

	renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
	if err != nil {
		panic(err)
	}
	surface, err := window.GetSurface()
	if err != nil {
		panic(err)
	}

	controlManager := inputManager.GetControlManager()

	updateFunctionsToStartWith := make([]inputManager.Update, 1)
	updateFunctionsToStartWith[0] = menus.CreateMenus(window, surface, renderer, &controlManager)
	inputManager.StateMachine(controlManager.ReadInput(), updateFunctionsToStartWith)

	sdl.Quit()
}
开发者ID:ITR13,项目名称:campusFighterI,代码行数:48,代码来源:CampusFighterI.go

示例8: main

func main() {
	sdlInit()

	gm := gamemanager.GGameManager
	gc := gamecontext.GContext

	createMainWindow()
	defer gc.MainWindow.Destroy()

	intro := &introstate.IntroState{}
	play := &playstate.PlayState{}

	gm.RegisterMode(gamemanager.GameModeIntro, intro)
	gm.RegisterMode(gamemanager.GameModePlay, play)

	done := false

	// Keep handy for use in the loop
	mainWindow := gc.MainWindow
	mainWindowSurface := gc.MainSurface

	gm.SetMode(gamemanager.GameModeIntro)

	gm.SetEventMode(gamemanager.GameManagerEventDriven)

	for done == false {
		event := gm.GetNextEvent()
		for ; event != nil; event = sdl.PollEvent() {
			done = done || gm.HandleEvent(&event)

			switch event := event.(type) {
			case *sdl.WindowEvent:
				//fmt.Printf("Window: %#v\n", event)
				//fmt.Printf("Event: %t %t\n", event.Event, sdl.WINDOWEVENT_CLOSE)
				if event.Event == sdl.WINDOWEVENT_CLOSE {
					done = done || true
				}
			}
		}

		gm.Render(mainWindowSurface)
		mainWindow.UpdateSurface()

		gm.DelayToNextFrame()
	}

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

示例9: Destroy

// Destroys SDL and releases the memory
func (e *Engine) Destroy() {
	for _, v := range e.StateText {
		v.Texture.Destroy()
	}

	e.Sprite.Destroy()
	e.Font.Close()
	e.Music.Free()
	e.Sound.Free()
	e.Renderer.Destroy()
	e.Window.Destroy()

	ttf.Quit()
	mix.CloseAudio()
	mix.Quit()
	sdl.Quit()
}
开发者ID:yukiisbored,项目名称:Kaori-Android,代码行数:18,代码来源:example.go

示例10: main

func main() {
	if err := sdl.Init(sdl.INIT_AUDIO); err != nil {
		log.Println(err)
		return
	}
	defer sdl.Quit()

	spec := &sdl.AudioSpec{
		Freq:     sampleHz,
		Format:   sdl.AUDIO_U8,
		Channels: 2,
		Samples:  sampleHz,
		Callback: sdl.AudioCallback(C.SineWave),
	}
	sdl.OpenAudio(spec, nil)
	sdl.PauseAudio(false)
	time.Sleep(1 * time.Second)
}
开发者ID:emlai,项目名称:go-sdl2,代码行数:18,代码来源:audio.go

示例11: main

// The programs main function
func main() {
	// ---- This is the start of Owen's graphics setup code ----

	// First we have to initalise the SDL library, before we can use it
	sdl.Init(sdl.INIT_EVERYTHING)
	// defer is a go keyword and a special feature.
	// This means that go will automatically call the function sdl.Quit() before
	// the program exits for us. We don't have to remember to put this at the end!
	defer sdl.Quit()

	// if you want to change these try 800 for the width and 600 for the height
	windowWidth = 1024
	windowHeight = 768

	// Now we have to create the window we want to use.
	// We need to tell the SDL library how big to make the window of the correct
	// size - that's what the bit in the brackets does
	window = createWindow(windowWidth, windowHeight)
	// automatically destroy the window when the program finishes
	defer window.Destroy()
	// Now we have a window we need to create a renderer so we can draw into
	// it. In this case we want to use the first graphics card that supports faster
	// drawing
	renderer = createRenderer(window)
	// automatically destroy the renderer when the program exits.
	defer renderer.Destroy()

	// Set a black i.e. RGBA (0,0,0,0) background colour and clear the window
	renderer.SetDrawColor(0, 0, 0, 0)
	renderer.Clear()
	// ---- This is the end of Owen's graphics setup code ----

	// defer any cleanup actions
	defer cleanup()
	// initialise the games variables.
	initialise()
	// render everything initially so that we can see the game before it starts
	render()
	// now start the main game loop of the game.
	gameMainLoop()
}
开发者ID:gophercoders,项目名称:pong,代码行数:42,代码来源:pong.go

示例12: main

func main() {
	var (
		err     error
		window  *sdl.Window
		context sdl.GLContext
	)

	if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
		panic(err)
	}
	defer sdl.Quit()

	sdl.GL_SetAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 3)
	sdl.GL_SetAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 2)
	sdl.GL_SetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_CORE)

	window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, winWidth, winHeight, sdl.WINDOW_OPENGL)
	if err != nil {
		panic(err)
	}
	defer window.Destroy()

	context, err = sdl.GL_CreateContext(window)
	if err != nil {
		panic(err)
	}
	defer sdl.GL_DeleteContext(context)

	if err = sdl.GL_MakeCurrent(window, context); err != nil {
		panic(err)
	}

	if err = gl.Init(); err != nil {
		panic(err)
	}

	printGLInfo()
	cameraMatrixUniform := setupGL()
	windowLoop(window, cameraMatrixUniform)
}
开发者ID:sweco-secfbr,项目名称:octatron,代码行数:40,代码来源:raytracer.go

示例13: main

func main() {
	var (
		err     error
		window  *sdl.Window
		context sdl.GLContext
	)

	if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
		panic(err)
	}
	defer sdl.Quit()

	sdl.GL_SetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_COMPATIBILITY)

	window, err = sdl.CreateWindow(winTitle, sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, winWidth, winHeight, sdl.WINDOW_OPENGL)
	if err != nil {
		panic(err)
	}
	defer window.Destroy()

	context, err = sdl.GL_CreateContext(window)
	if err != nil {
		panic(err)
	}
	defer sdl.GL_DeleteContext(context)

	if err = sdl.GL_MakeCurrent(window, context); err != nil {
		panic(err)
	}

	if err = gl.Init(); err != nil {
		panic(err)
	}

	sdl.GL_SetSwapInterval(1)

	printGLInfo()
	setupGL()
	windowLoop(window)
}
开发者ID:sweco-secfbr,项目名称:octatron,代码行数:40,代码来源:debugger.go

示例14: TestTexture

func TestTexture(t *testing.T) {
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		panic(sdl.GetError())
	}
	defer sdl.Quit()

	window := sdl.CreateWindow("test", 0, 0, 320, 200, sdl.WINDOW_HIDDEN|sdl.WINDOW_OPENGL)
	defer window.Destroy()

	sdl.GL_SetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_ES)
	sdl.GL_SetAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2)
	sdl.GL_SetAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 0)

	glctx := sdl.GL_CreateContext(window)
	defer sdl.GL_DeleteContext(glctx)

	tex := gl.CreateTexture()
	gl.BindTexture(gl.TEXTURE_2D, tex)
	if !gl.IsTexture(tex) {
		t.Error(tex, "is not a texture")
	}
}
开发者ID:jackscan,项目名称:go-gles3,代码行数:22,代码来源:texture_test.go

示例15: main

func main() {
	sdl.Init(sdl.INIT_EVERYTHING)

	window, err := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
		800, 600, sdl.WINDOW_SHOWN)
	if err != nil {
		panic(err)
	}
	defer window.Destroy()

	surface, err := window.GetSurface()
	if err != nil {
		panic(err)
	}

	rect := sdl.Rect{0, 0, 200, 200}
	surface.FillRect(&rect, 0xffff0000)
	window.UpdateSurface()

	sdl.Delay(1000)
	sdl.Quit()
}
开发者ID:cztchoice,项目名称:testrepo,代码行数:22,代码来源:main.go


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