本文整理匯總了Golang中github.com/banthar/Go-SDL/sdl.Quit函數的典型用法代碼示例。如果您正苦於以下問題:Golang Quit函數的具體用法?Golang Quit怎麽用?Golang Quit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Quit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Destroy
func (self *AppStateManager) Destroy() {
sdl.Quit()
if *FLAG_profile {
pprof.StopCPUProfile()
}
}
示例2: initScreen
func initScreen() {
sdl.Init(sdl.INIT_VIDEO)
const (
resx int = 640
resy int = 480
)
var (
screen = sdl.SetVideoMode(resx, resy, 16, sdl.OPENGL)
)
if screen == nil {
sdl.Quit()
panic("Couldn't set GL video mode: " + sdl.GetError() + "\n")
}
if gl.Init() != 0 {
panic("gl error")
}
gl.MatrixMode(gl.PROJECTION)
//gl.MatrixMode(gl.MODELVIEW)
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.DepthRange(-1, 1)
gl.ClearColor(0, 0, 0, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
}
示例3: main
func main() {
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
panic(sdl.GetError())
}
defer sdl.Quit()
screen := sdl.SetVideoMode(640, 480, 32, 0)
if screen == nil {
panic(sdl.GetError())
}
sdl.WM_SetCaption("Ohai", "")
sdl.EnableKeyRepeat(20, 20)
fmt.Println("Launching mainloop")
loadTextures()
loadLevel()
gameloop(screen)
}
示例4: run
// Runs everything, calling the methods required to get the game
// running, runs the main loop, and then cleanly exits.
func (g *game) run() (err error) {
err = g.load()
if err != nil {
return
}
defer g.quit()
if sdl.Init(sdl.INIT_EVERYTHING) < 0 {
return errors.New(sdl.GetError())
}
defer sdl.Quit()
g.screen = sdl.SetVideoMode(640, 480, 32, sdl.DOUBLEBUF)
if g.screen == nil {
return errors.New(sdl.GetError())
}
sdl.WM_SetCaption(WinCap, "")
err = g.main()
if err != nil {
return
}
return
}
示例5: initdec
func initdec() {
initnum--
if initnum == 0 {
sdl.Quit()
}
}
示例6: 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)
}
示例7: wrap
// Wrap the SDL into one single thread
func (s SdlWrap) wrap() {
runtime.LockOSThread()
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
panic("Unable to init SDL. Cause: " + sdl.GetError())
}
sdl.EnableUNICODE(1)
s.InitDone <- struct{}{}
for {
select {
case t := <-s.Title:
sdl.WM_SetCaption(t, t)
case <-s.Quit:
close(s.Events)
sdl.Quit()
case sz := <-s.Size:
s.Surface <- sdl.SetVideoMode(int(sz.X), int(sz.Y), 32, sdl.HWSURFACE|sdl.DOUBLEBUF|sdl.RESIZABLE)
default:
e := sdl.PollEvent()
if e != nil {
s.Events <- e
}
}
}
}
示例8: Setup
func (self *AppStateManager) Setup(state AppState, caption string) {
if *FLAG_profile {
pfile, _ := os.Create("gowar.prof")
pprof.StartCPUProfile(pfile)
}
// Lock, so we got no GL-in-wrong-thread foolery
sdl.Init(sdl.INIT_VIDEO)
self.Screen = sdl.SetVideoMode(800, 600, 32, sdl.OPENGL|sdl.RESIZABLE)
gl.Init()
if self.Screen == nil {
sdl.Quit()
panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
}
sdl.WM_SetCaption(caption, caption)
Setup()
GetViewport().SetScreenSize(float32(self.Screen.W), float32(self.Screen.H))
self.Push(state)
}
示例9: main
func main() {
var done bool
sdl.Init(sdl.INIT_VIDEO)
var screen = sdl.SetVideoMode(300, 300, 18, sdl.OPENGL|sdl.RESIZABLE)
if screen == nil {
sdl.Quit()
panic("Couldn't set 300x300 GL video mode: " + sdl.GetError() + "\n")
}
gl.Init()
//if gl.Init() != nil {
//panic("gl error")
//}
init_()
reshape(int32(screen.W), int32(screen.H))
done = false
for !done {
for e := sdl.PollEvent(); e != nil; e = sdl.PollEvent() {
switch e.(type) {
case *sdl.ResizeEvent:
re := e.(*sdl.ResizeEvent)
screen = sdl.SetVideoMode(int(re.W), int(re.H), 16,
sdl.OPENGL|sdl.RESIZABLE)
if screen != nil {
reshape(int32(screen.W), int32(screen.H))
} else {
panic("we couldn't set the new video mode??")
}
break
case *sdl.QuitEvent:
done = true
break
}
}
done = key_handler()
draw()
}
sdl.Quit()
return
}
示例10: Release
func (c *Screen) Release() {
if c.font != nil {
c.font.Close()
}
if c.surface != nil {
c.surface.Free()
}
ttf.Quit()
sdl.Quit()
/* log.Printf("sdl Released...") */
}
示例11: main
func main() {
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
panic(sdl.GetError())
}
defer sdl.Quit()
println("unpause with space or p")
println("while paused you can place cells with the three mouse buttons")
rand.Seed(time.Now().UnixNano())
Screen = NewSurface(Width*Scale, Height*Scale)
Setup()
HandleEvents()
}
示例12: main
func main() {
globalState.Mouse = make(map[int]bool)
flag.Parse()
var err error
if sdl.Init(sdl.INIT_VIDEO) != 0 {
log.Printf("Unable to init SDL")
return
}
if len(flag.Args()) == 0 {
old := flag.Usage
flag.Usage = func() {
old()
fmt.Fprintf(os.Stderr, "You MUST pass the name of the file to view\n")
}
flag.Usage()
return
}
mesh, err = wfobj.LoadMeshFromFile(flag.Args()[0])
if err != nil {
flag.Usage()
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer sdl.Quit()
screen := sdl.SetVideoMode(1024, 600, 32, sdl.OPENGL|sdl.RESIZABLE)
if screen == nil {
log.Printf("Unable to init sdl Screen")
}
sdl.GL_SetAttribute(sdl.GL_DOUBLEBUFFER, 1)
initGL()
sdl.WM_SetCaption("sdlviewer", "sdlviewer")
running = true
for running {
handleInput()
drawScene()
}
}
示例13: main
func main() {
sdl.Init(sdl.INIT_VIDEO)
defer sdl.Quit()
screen := sdl.SetVideoMode(width, height, 32, sdl.OPENGL)
if screen == nil {
panic("Couldn't set video mode: " + sdl.GetError() + "\n")
}
if err := gl.Init(); err != 0 {
panic("gl error")
}
initGl()
initShaders()
mainLoop()
}
示例14: main
func main() {
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
panic(sdl.GetError())
}
// The actual resolution (screenspace)
W := 800
H := 600
// The virtual resolution (worldspace)
MAXX := 400
MAXY := 300
screen := sdl.SetVideoMode(W, H, 32, sdl.FULLSCREEN)
if screen == nil {
panic(sdl.GetError())
}
sdl.EnableUNICODE(1)
sdl.ShowCursor(0)
sdl.WM_SetCaption("Random Lines", "")
red := sdl.Color{255, 0, 0, 255}
color := red
rand.Seed(time.Now().UnixNano())
for {
color = sdl.Color{uint8(rand.Intn(255)), uint8(rand.Intn(255)), uint8(rand.Intn(255)), 255}
DoublePixelLine(screen, rand.Intn(MAXX), rand.Intn(MAXY), rand.Intn(MAXX), rand.Intn(MAXY), color)
if escPressed() {
break
}
screen.Flip()
sdl.PollEvent()
//sdl.Delay(10)
}
sdl.Quit()
}
示例15: main
func main() {
sdl.Init(sdl.INIT_VIDEO)
ttf.Init()
screen := sdl.SetVideoMode(480, 560, 16, sdl.OPENGL|sdl.RESIZABLE)
sdl.WM_SetCaption("Flappy Bird", "")
bg := utils.TextureFromFile("./bg.png")
font := utils.LoadFont("/usr/share/fonts/truetype/DroidSans.ttf", 32)
reshape(int(screen.W), int(screen.H))
renderBackground(screen, bg)
font.Printf(110, 50, "Click to play")
sdl.GL_SwapBuffers()
for {
OuterLoop:
for {
e := sdl.WaitEvent()
switch e.(type) {
case *sdl.MouseButtonEvent:
if e.(*sdl.MouseButtonEvent).Type == sdl.MOUSEBUTTONUP {
break OuterLoop
}
}
}
score, quit := playGame(screen, bg, font)
if quit {
break
}
quit = gameOverScreen(screen, strconv.Itoa(score), bg, font)
if quit {
break
}
}
screen.Free()
ttf.Quit()
sdl.Quit()
return
}