Exemplo n.º 1
0
func mainLoop(width, height int) {
	// SDL window must be created in the same thread where the events are
	// polled. Hence this stuff must be in a separate goroutine along with the
	// event loop.

	initFlags := int64(C.SDL_INIT_VIDEO) | int64(C.SDL_INIT_AUDIO)
	screenFlags := 0

	if C.SDL_Init(C.Uint32(initFlags)) == C.int(-1) {
		panic(getError())
	}

	screen := C.SDL_SetVideoMode(
		C.int(width), C.int(height), 32, C.Uint32(screenFlags))
	if screen == nil {
		panic(getError())
	}
	C.SDL_EnableUNICODE(1)
	C.SDL_EnableKeyRepeat(C.SDL_DEFAULT_REPEAT_DELAY, C.SDL_DEFAULT_REPEAT_INTERVAL)

	initAudio()

	// Synchronize with Run function.
	coord <- true

	eventLoop()
	C.SDL_Quit()

	// Synchronize with Stop function.
	coord <- true
	runLevel = off
}
Exemplo n.º 2
0
// Sets keyboard repeat rate.
func EnableKeyRepeat(delay, interval int) int {
	GlobalMutex.Lock()
	status := int(C.SDL_EnableKeyRepeat(C.int(delay), C.int(interval)))
	GlobalMutex.Unlock()
	return status
}
Exemplo n.º 3
0
// Sets keyboard repeat rate.
func EnableKeyRepeat(delay, interval int) int {
	return int(C.SDL_EnableKeyRepeat(C.int(delay), C.int(interval)))
}