Example #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
}
Example #2
0
// Enables UNICODE translation.
func EnableUNICODE(enable int) int {
	GlobalMutex.Lock()
	previous := int(C.SDL_EnableUNICODE(C.int(enable)))
	GlobalMutex.Unlock()
	return previous
}
Example #3
0
// Enables UNICODE translation.
func EnableUNICODE(enable int) int { return int(C.SDL_EnableUNICODE(C.int(enable))) }