func (t *TestSuite) BeforeAll() { gorgasm.Verbose = true gorgasm.Debug = true // Create rendering loop control channels t.rlControl = newRenderLoopControl() // Start the rendering loop loop.GoRecoverable( t.renderLoopFunc(t.rlControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { gorgasm.Logf("%s", r.Reason) gorgasm.Logf("%s", gorgasm.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) // Start the event loop loop.GoRecoverable( t.eventLoopFunc(t.rlControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { gorgasm.Logf("%s", r.Reason) gorgasm.Logf("%s", gorgasm.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) }
func main() { runtime.GOMAXPROCS(runtime.NumCPU()) mandala.Verbose = true mandala.Debug = true // Create rendering loop control channels renderLoopControl := newRenderLoopControl() // Start the rendering loop loop.GoRecoverable( renderLoopFunc(renderLoopControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { mandala.Logf("%s", r.Reason) mandala.Logf("%s", mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) // Start the event loop loop.GoRecoverable( eventLoopFunc(renderLoopControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { mandala.Logf("%s", r.Reason) mandala.Logf("%s", mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) }
func main() { size := flag.String("size", "320x480", "set the size of the window") flag.Parse() dims := strings.Split(strings.ToLower(*size), "x") width, err := strconv.Atoi(dims[0]) if err != nil { panic(err) } height, err := strconv.Atoi(dims[1]) if err != nil { panic(err) } controlCh := newControlCh() controlCh.eglState <- initEGL(controlCh, width, height) // Start the rendering loop loop.GoRecoverable( renderLoopFunc(controlCh), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { log.Println(r.Reason) log.Println(string(debug.Stack())) } return rs, fmt.Errorf("Unrecoverable loop error\n") }, ).Wait() }
//export onCreate func onCreate(act *C.ANativeActivity, savedState unsafe.Pointer, savedStateSize C.size_t) { defer func() { handleCallbackError(act, recover()) }() internalEvent = make(chan interface{}) looperCh := make(chan *C.ALooper) // Create a new state for the current activity and store it in // states global map. setState(act, &state{act, nil}) loop.GoRecoverable( androidEventLoopFunc(internalEvent, looperCh), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { Logf("%s", r.Reason) Logf("%s", Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) activity <- unsafe.Pointer(act) looper = <-looperCh event <- CreateEvent{unsafe.Pointer(act), savedState, int(savedStateSize)} }
func (t *TestSuite) BeforeAll() { // Create rendering loop control channels t.rlControl = newRenderLoopControl() // Start the rendering loop loop.GoRecoverable( t.renderLoopFunc(t.rlControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { mandala.Logf("%s", r.Reason) mandala.Logf("%s", mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) // Start the event loop loop.GoRecoverable( t.eventLoopFunc(t.rlControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { mandala.Logf("%s", r.Reason) mandala.Logf("%s", mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) if t.timeout != nil { // Start the timeout loop loop.GoRecoverable( t.timeoutLoopFunc(), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { mandala.Logf("%s", r.Reason) mandala.Logf("%s", mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) } }
func init() { event = make(chan interface{}, NumOfBufferedEvents) request = make(chan interface{}) activity = make(chan unsafe.Pointer, 1) loop.GoRecoverable( assetLoopFunc(activity, request), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { Logf("%s", r.Reason) Logf("%s", Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) }
//export onCreate func onCreate(act *C.ANativeActivity, savedState unsafe.Pointer, savedStateSize C.size_t) { defer func() { handleCallbackError(act, recover()) }() Debugf("onCreate...") internalEvent = make(chan interface{}) looperCh := make(chan *C.ALooper) // Create a new state for the current activity and store it in // states global map. setState(act, &state{act, nil}) // Initialize the native sound library err := initOpenSL() if err != nil { Logf(err.Error()) } else { Debugf("OpenSL successfully initialized") } // Initialize the native event loop loop.GoRecoverable( androidEventLoopFunc(internalEvent, looperCh), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { Logf("%s", r.Reason) Logf("%s", Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) activity <- unsafe.Pointer(act) looper = <-looperCh event <- CreateEvent{unsafe.Pointer(act), savedState, int(savedStateSize)} Debugf("onCreate done.") }
func main() { runtime.LockOSThread() verbose := flag.Bool("verbose", false, "produce verbose output") debug := flag.Bool("debug", false, "produce debug output") size := flag.String("size", "320x480", "set the size of the window") flag.Parse() if *verbose { mandala.Verbose = true } if *debug { mandala.Debug = true } dims := strings.Split(strings.ToLower(*size), "x") width, err := strconv.Atoi(dims[0]) if err != nil { panic(err) } height, err := strconv.Atoi(dims[1]) if err != nil { panic(err) } if !glfw.Init() { panic("Can't init glfw!") } defer glfw.Terminate() // Enable OpenGL ES 2.0. glfw.WindowHint(glfw.ClientApi, glfw.OpenglEsApi) glfw.WindowHint(glfw.ContextVersionMajor, 2) window, err := glfw.CreateWindow(width, height, "MyApp", nil, nil) if err != nil { panic(err) } mandala.Init(window) // Create a rendering loop control struct containing a set of // channels that control rendering. renderLoopControl := newRenderLoopControl() // Start the rendering loop loop.GoRecoverable( renderLoopFunc(renderLoopControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { log.Printf("%s\n%s", r.Reason, mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) // Start the event loop loop.GoRecoverable( eventLoopFunc(renderLoopControl), func(rs loop.Recoverings) (loop.Recoverings, error) { for _, r := range rs { log.Printf("%s\n%s", r.Reason, mandala.Stacktrace()) } return rs, fmt.Errorf("Unrecoverable loop\n") }, ) for !window.ShouldClose() { glfw.WaitEvents() } }