本文整理汇总了Golang中github.com/veandco/go-sdl2/sdl.Quit函数的典型用法代码示例。如果您正苦于以下问题:Golang Quit函数的具体用法?Golang Quit怎么用?Golang Quit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Quit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
func main() {
sdl.Init(sdl.INIT_VIDEO)
defer sdl.Quit()
window, err := sdl.CreateWindow("Tank", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, windowWidth, windowHeight, 0)
if err != nil {
panic(err)
}
defer window.Destroy()
mainloop:
for {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch event.(type) {
case *sdl.QuitEvent:
break mainloop
}
}
windowSurface, _ := window.GetSurface()
windowSurface.FillRect(nil, sdl.MapRGB(windowSurface.Format, 0, 0, 0))
window.UpdateSurface()
sdl.Delay(1000)
}
}
开发者ID:Oralordos,项目名称:Tank,代码行数:24,代码来源:in.go
示例17: main
func main() {
fmt.Print()
sdl.SetHint(sdl.HINT_RENDER_VSYNC, "1")
check(sdl.Init(sdl.INIT_EVERYTHING))
defer sdl.Quit()
window, r, err := sdl.CreateWindowAndRenderer(
640, 480,
sdl.WINDOW_RESIZABLE,
)
check(err)
renderer = r
defer renderer.Destroy()
defer window.Destroy()
window.SetTitle("Gophette's Adventures - Level Editor")
window.SetPosition(50, 50)
window.SetSize(1800, 900)
window.SetFullscreen(sdl.WINDOW_FULLSCREEN_DESKTOP)
renderer.SetDrawBlendMode(sdl.BLENDMODE_BLEND)
if len(LevelImages) == 0 {
for i, id := range []string{
"grass left",
"grass right",
"grass center 1",
"grass center 2",
"grass center 3",
"small tree",
} {
images = append(images, image{id, loadImage(id), 0, i * 50})
}
} else {
for i := range LevelImages {
id := LevelImages[i].ID
x, y := LevelImages[i].X, LevelImages[i].Y
img := loadImage(id)
images = append(images, image{id, img, x, y})
}
}
leftDown := false
middleDown := false
rightDown := false
selectedImage := -1
selectedObject := -1
var lastX, lastY int
moveImage := func(dx, dy int) {
if selectedImage != -1 {
images[selectedImage].x += dx
images[selectedImage].y += dy
}
}
stretchObject := func(dx, dy int) {
if selectedObject != -1 {
if sdl.GetKeyboardState()[sdl.SCANCODE_LCTRL] != 0 {
dx *= 20
dy *= 20
}
obj := &LevelObjects[selectedObject]
obj.W += dx
obj.H += dy
}
}
running := true
for running {
for e := sdl.PollEvent(); e != nil; e = sdl.PollEvent() {
switch event := e.(type) {
case *sdl.QuitEvent:
running = false
case *sdl.MouseButtonEvent:
if event.Button == sdl.BUTTON_LEFT {
leftDown = event.State == sdl.PRESSED
if !leftDown {
draggingImage = false
draggingObject = false
} else {
selectedObject = -1
selectedImage = -1
for i := range images {
if images[i].contains(
int(event.X)-cameraX,
int(event.Y)-cameraY,
) {
draggingImage = true
selectedImage = i
}
}
if selectedImage == -1 {
for i := range LevelObjects {
if contains(LevelObjects[i],
int(event.X)-cameraX,
int(event.Y)-cameraY,
) {
draggingObject = true
//.........这里部分代码省略.........
开发者ID:gophergala2016,项目名称:gophette,代码行数:101,代码来源:main.go
示例18: Close
func (w Window) Close() {
sdl.GL_DeleteContext(w.contextSDL)
w.windowSDL.Destroy()
sdl.Quit()
}
开发者ID:xladykiller,项目名称:GT,代码行数:5,代码来源:window.go
示例19: main
func main() {
var window *sdl.Window
var context sdl.GLContext
var event sdl.Event
var running bool
var err error
runtime.LockOSThread()
if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
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.Init()
gl.Viewport(0, 0, gl.Sizei(winWidth), gl.Sizei(winHeight))
// OPENGL FLAGS
gl.ClearColor(0.0, 0.1, 0.0, 1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LESS)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
// VERTEX BUFFER
var vertexbuffer gl.Uint
gl.GenBuffers(1, &vertexbuffer)
gl.BindBuffer(gl.ARRAY_BUFFER, vertexbuffer)
gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(len(triangle_vertices)*4), gl.Pointer(&triangle_vertices[0]), gl.STATIC_DRAW)
// COLOUR BUFFER
var colourbuffer gl.Uint
gl.GenBuffers(1, &colourbuffer)
gl.BindBuffer(gl.ARRAY_BUFFER, colourbuffer)
gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(len(triangle_colours)*4), gl.Pointer(&triangle_colours[0]), gl.STATIC_DRAW)
// GUESS WHAT
program := createprogram()
// VERTEX ARRAY
var VertexArrayID gl.Uint
gl.GenVertexArrays(1, &VertexArrayID)
gl.BindVertexArray(VertexArrayID)
gl.EnableVertexAttribArray(0)
gl.BindBuffer(gl.ARRAY_BUFFER, vertexbuffer)
gl.VertexAttribPointer(0, 3, gl.FLOAT, gl.FALSE, 0, nil)
// VERTEX ARRAY HOOK COLOURS
gl.EnableVertexAttribArray(1)
gl.BindBuffer(gl.ARRAY_BUFFER, colourbuffer)
gl.VertexAttribPointer(1, 3, gl.FLOAT, gl.FALSE, 0, nil)
//UNIFORM HOOK
unistring := gl.GLString("scaleMove")
UniScale = gl.GetUniformLocation(program, unistring)
fmt.Printf("Uniform Link: %v\n", UniScale+1)
gl.UseProgram(program)
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:
xrot = float32(t.Y) / 2
yrot = float32(t.X) / 2
fmt.Printf("[%dms]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,代码行数:86,代码来源:opengl3.go
示例20: main
func main() {
runtime.LockOSThread()
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
sdl.GL_SetAttribute(sdl.GL_MULTISAMPLESAMPLES, 4)
sdl.GL_SetAttribute(sdl.GL_CONTEXT_MAJOR_VERSION, 3)
sdl.GL_SetAttribute(sdl.GL_CONTEXT_MINOR_VERSION, 3)
sdl.GL_SetAttribute(sdl.GL_CONTEXT_PROFILE_MASK, sdl.GL_CONTEXT_PROFILE_CORE)
sdl.GL_SetAttribute(sdl.GL_DOUBLEBUFFER, 1)
sdl.GL_SetAttribute(sdl.GL_DEPTH_SIZE, 24)
sdl.GL_SetAttribute(sdl.GL_CONTEXT_FLAGS, sdl.GL_CONTEXT_DEBUG_FLAG|sdl.GL_CONTEXT_FORWARD_COMPATIBLE_FLAG)
window, err := sdl.CreateWindow("TOW", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, 1024, 768, sdl.WINDOW_OPENGL|sdl.WINDOW_SHOWN|sdl.WINDOW_RESIZABLE)
if err != nil {
log.Fatal("can't create window", err)
}
defer window.Destroy()
//defer renderer.Destroy()
glcontext, err := sdl.GL_CreateContext(window)
if err != nil {
log.Fatal("can't create context", err)
}
defer sdl.GL_DeleteContext(glcontext)
sdl.GL_MakeCurrent(window, glcontext)
//err := gl.GlewInit()
//fmt.Println(gl.GlewGetErrorString(err))
//glew init
gl.Init()
sdl.GL_SetSwapInterval(1)
fmt.Println("glVersion", gl.GetString(gl.VERSION))
tw.Init(tw.OPENGL_CORE, nil)
defer tw.Terminate()
gl.GetError() // Ignore error
debugContext.InitDebugContext()
world := generation.GenerateWorld(64, 64, 2)
gs := gamestate.NewGameState(window, world)
defer gs.Delete()
worldRenderer := rendering.NewWorldRenderer(window, gs.World)
defer worldRenderer.Delete()
gs.Bar.AddButton("screen shot", worldRenderer.ScreenShot, "")
MainLoop(gs, worldRenderer)
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
panic(err)
}
pprof.WriteHeapProfile(f)
f.Close()
return
}
}
开发者ID:krux02,项目名称:turnt-octo-wallhack,代码行数:75,代码来源:main.go
注:本文中的github.com/veandco/go-sdl2/sdl.Quit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论