void start_race(void) { Uint32 simtime = SDL_GetTicks(); //set simulated time to realtime start_time = simtime; //how long it took for race to start //start printlog (0, "Starting Race (multithreaded)"); ode_mutex = SDL_CreateMutex(); //create mutex for ode locking sdl_mutex = SDL_CreateMutex(); //only use sdl in 1 thread sync_mutex = SDL_CreateMutex(); sync_cond = SDL_CreateCond(); runlevel = running; //launch threads SDL_Thread *physics = SDL_CreateThread (physics_loop, NULL); SDL_Thread *events = SDL_CreateThread (events_loop, NULL); graphics_loop(); //we already got opengl context in main thread //wait for threads SDL_WaitThread (events, NULL); SDL_WaitThread (physics, NULL); //cleanup SDL_DestroyMutex(ode_mutex); SDL_DestroyMutex(sdl_mutex); SDL_DestroyMutex(sync_mutex); SDL_DestroyCond(sync_cond); //done! }
int main(int argc, char **argv) { init_cv_buffers(); context = init_kinect(); if (context == NULL) { return 1; } if (freenect_open_device(context, &device, 0) < 0) { printf("could not open device\n"); freenect_shutdown(context); return 1; } int capture_loop_failed = pthread_create(&kinect_thread, NULL, capture_loop, NULL); if (capture_loop_failed) { printf("pthread_create failed\n"); freenect_shutdown(context); return 1; } handle_sigint(); graphics_loop(argc, argv); pthread_join(kinect_thread, NULL); printf("thanks for shooting down quads!\n"); }
void core_run() { /* Setup. */ core_assets_init(); /* Loop until the user closes the window */ graphics_loop(&core_global->graphics); /* Release assets. */ core_release(); /* Free OpenAL. */ sound_free(&core_global->sound); /* If we reach here, quit the core. */ graphics_free(&core_global->graphics); /* Release game memory */ free(core_global->shared_memory.game_memory); }
int main(int argc, char** argv) { audio_init(); graphics_init(argc, argv); graphics_loop(); return 0; }