Example #1
0
scalar_t get_clock_time()
{
#if defined( TARGET_OS_IPHONE )
    uint64_t nanosec = udate();

    return (scalar_t) nanosec * 1.e-9;


#elif defined( HAVE_GETTIMEOFDAY )

    struct timeval tv;
    gettimeofday( &tv, NULL );

    return (scalar_t) tv.tv_sec + (scalar_t) tv.tv_usec * 1.e-6;

#elif defined( HAVE_SDL ) 

    return SDL_GetTicks() * 1.e-3;

#else

#   error "We have no way to determine the time on this system."

#endif /* defined( HAVE_GETTIMEOFDAY ) */
} 
Example #2
0
void * load_course_thread(void * unused)
{
#ifdef TR_DEBUG_MODE
    uint64_t load_start = udate();
#endif
    /* Load the course */
    load_course_core( g_game.race.course );
    
    pthread_mutex_lock(&load_mutex);
    loading_done = true;
    pthread_mutex_unlock(&load_mutex);

#ifdef TR_DEBUG_MODE
    TRDebugLog("(loading thread) Loading took %dms\n", (int32_t)(((int64_t)udate() - (int64_t)load_start) / 1000000));
#endif

    return NULL;
}
Example #3
0
void loading_loop( scalar_t time_step )
{
    int width, height;
    width = getparam_x_resolution();
    height = getparam_y_resolution();

    check_gl_error();
    
    update_audio();
    
    clear_rendering_context();
    
    set_gl_options( GUI );
    
    ui_setup_display();
    
	//disabled for sponsors
    /*if (getparam_ui_snow()) {
        update_ui_snow( time_step, g_game.race.windy );
        draw_ui_snow();
    }*/
    
    draw_sponsor_loading();
    
	//disabled for sponsors
    //draw_loading_text();
    
    reshape( width, height );
    
    winsys_swap_buffers();

#ifndef ASYNC_LOADING
    if(passInLoop++ < 2) return;
#endif

    if ( loaded_course == NULL ||
        loaded_course != g_game.race.course ||
        loaded_conditions != g_game.race.conditions ) 
    {
        if(!loading_thread) {
            loading_done = false;
#ifdef TR_DEBUG_MODE
            abs_load_start = udate();
#endif
            preload_course(g_game.race.course);
            winsys_set_high_framerate(false);
#ifdef ASYNC_LOADING
            pthread_create(&loading_thread, NULL, load_course_thread, NULL);
#else
            load_course_thread(NULL);
#endif
        }
        pthread_mutex_lock(&load_mutex);
        bool done = loading_done;
        pthread_mutex_unlock(&load_mutex);
        if(done) {
#ifdef ASYNC_LOADING
            pthread_join(loading_thread, NULL);
#endif
            loading_thread = 0;

#ifdef TR_DEBUG_MODE
            TRDebugLog("(main thread) loading thread took %dms\n", (int32_t)(((int64_t)udate() - (int64_t)abs_load_start) / 1000000));
#endif

            postload_course(g_game.race.course);

            loaded_course = g_game.race.course;
            loaded_conditions = g_game.race.conditions;
            
            set_course_mirroring( g_game.race.mirrored );
    
            winsys_set_high_framerate(true);

            /* We're done here, enter INTRO mode */
            set_game_mode(INTRO);
#ifdef TR_DEBUG_MODE
            TRDebugLog("Total loading took %dms\n", (int32_t)(((int64_t)udate() - (int64_t)abs_load_start) / 1000000));
#endif

        }
    } else {
        winsys_set_high_framerate(true);

        set_course_mirroring( g_game.race.mirrored );

        set_game_mode(INTRO);
    }

}