コード例 #1
0
ファイル: preference.c プロジェクト: XiaZhang0414/TuxRider
static void preference_loop( scalar_t time_step )
{
    check_gl_error();
    
    update_audio();
    
    set_gl_options( GUI );
    
    clear_rendering_context();
    
    ui_setup_display();
    
    if (getparam_ui_snow()) {
        update_ui_snow( time_step, False );
        draw_ui_snow();
    }
    
    ui_draw_menu_decorations();
    
    draw_preference();
    
    ui_draw();
    
    reshape( getparam_x_resolution(), getparam_y_resolution() );
    
    winsys_swap_buffers();
}
コード例 #2
0
ファイル: race_select.c プロジェクト: XiaZhang0414/TuxRider
 /*! 
  Mode loop function
  \author  jfpatry
  \date    Created:  2000-09-24
  \date    Modified: 2000-09-24
  */
 static void race_select_loop( scalar_t time_step )
 {
     check_gl_error();
     
     update_audio();
     
     set_gl_options( GUI );
     
     clear_rendering_context();
     
     ui_setup_display();
     
     if (getparam_ui_snow()) {
         update_ui_snow( time_step, 
                        (bool_t) ( wind_ssbtn != NULL && 
                                  ssbutton_get_state( wind_ssbtn ) ) );
         draw_ui_snow();
     }
     
     ui_draw_menu_decorations();
     
     set_widget_positions_and_draw_decorations();
     
     ui_draw();
     
     reshape( getparam_x_resolution(), getparam_y_resolution() );
     
     winsys_swap_buffers();
 }
コード例 #3
0
ファイル: credits.c プロジェクト: FeeJai/Tux-Racer-4-iOS
static void credits_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();
    
    draw_credits_text( time_step );
    
    if (getparam_ui_snow()) {
        update_ui_snow( time_step, False );
        draw_ui_snow();
    }
    
    ui_draw_menu_decorations();
    
    ui_draw();
    
    reshape( width, height );
    
    winsys_swap_buffers();
} 
コード例 #4
0
ファイル: ui_mgr.c プロジェクト: LeifAndersen/TuxRider
/*! 
  Draws all UI widgets
  \return  None
  \author  jfpatry
  \date    Created:  2000-09-17
  \date    Modified: 2000-09-17
*/
void ui_draw( )
{
    hash_search_t iter;
    ui_callback_data_t *cb_data;

    ui_setup_display();

    begin_hash_scan( widget_draw_cbs, &iter );
    while ( next_hash_entry( iter, NULL, (hash_entry_t*)&cb_data ) ) {
	((widget_draw_cb_t)cb_data->cb)( cb_data->widget );
	check_assertion( !is_mode_change_pending(),
			 "widget draw callback changed the mode" );
    }
    end_hash_scan( iter );

    ui_draw_cursor();
}
コード例 #5
0
ファイル: race_select.c プロジェクト: Jisby/TuxRacer-SDL2
/*! 
 Mode loop function
 \author  jfpatry
 \date    Created:  2000-09-24
 \date    Modified: 2000-09-24
 */
static void race_select_loop( scalar_t time_step )
{
    use_hud_program();
    
    check_gl_error();
    
    update_audio();
    
    set_gl_options( GUI );
    
    clear_rendering_context();
    
    ui_setup_display();
    
    if (getparam_ui_snow()) {
        update_ui_snow( time_step, False );
        draw_ui_snow();
    }
    
    ui_draw_menu_decorations(False);
	
	if (price_update)
	{
		update_text();
		price_update = False;
	}
    
	GameMenu_draw();

	draw_preview();
    
	winsys_update_joysticks();

    ui_draw();
    
    reshape( getparam_x_resolution(), getparam_y_resolution() );
    
    winsys_swap_buffers();
}
コード例 #6
0
ファイル: ui_snow.c プロジェクト: Jisby/TuxRacer-SDL2
void draw_ui_snow( void )
{
    GLuint   texture_id;
    char *binding;
    point2d_t *pt, *tex_min, *tex_max;
    scalar_t size;
    scalar_t xres, yres;
    int i;

    xres = getparam_x_resolution();
    yres = getparam_y_resolution();
    
    ui_setup_display();

    binding = "snow_particle";
    if (!get_texture_binding( "snow_particle", &texture_id ) ) {
	print_warning( IMPORTANT_WARNING,
		       "Couldn't get texture for binding %s", 
		       binding );
	texture_id = 0;
    }

    glBindTexture( GL_TEXTURE_2D, texture_id );
    
    shader_set_color(particle_colour);
    
    {
        GLfloat* vertices=(GLfloat*)malloc(8*num_particles*sizeof(GLfloat));
        GLfloat* tex_coords=(GLfloat*)malloc(8*num_particles*sizeof(GLfloat));
        GLushort* indices=(GLushort*)malloc(6*num_particles*sizeof(GLushort));
        
        for ( i=0; i<num_particles; i++) {
            init_arrays_for_particle(particles[i], vertices+i*8, tex_coords+i*8);
            int firstvert=i*4;
            int firstindex=i*6;
            indices[0+firstindex]=0+firstvert;
            indices[1+firstindex]=1+firstvert;
            indices[2+firstindex]=2+firstvert;
            indices[3+firstindex]=2+firstvert;
            indices[4+firstindex]=3+firstvert;
            indices[5+firstindex]=0+firstvert;

        }
        
        //print_debug(DEBUG_OTHER, "indices %d %d %d %d %d %d %d %d %d %d %d %d", indices[0], indices[1], indices[2], indices[3], indices[4], indices[5], indices[6], indices[7], indices[8], indices[9], indices[10], indices[11]);
        //print_debug(DEBUG_OTHER, "vertices %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f", vertices[0], vertices[1], vertices[2], vertices[3], vertices[4], vertices[5], vertices[6], vertices[7], vertices[8], vertices[9], vertices[10], vertices[11], vertices[12], vertices[13], vertices[14], vertices[15]);
        
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        
        glVertexAttribPointer(shader_get_attrib_location(SHADER_VERTEX_NAME), 2, GL_FLOAT, GL_FALSE, 0, vertices);
        glEnableVertexAttribArray(shader_get_attrib_location(SHADER_VERTEX_NAME));
        
        glVertexAttribPointer(shader_get_attrib_location(SHADER_TEXTURE_COORD_NAME), 2, GL_FLOAT, GL_FALSE, 0, tex_coords);
        glEnableVertexAttribArray(shader_get_attrib_location(SHADER_TEXTURE_COORD_NAME));
        
        glDrawElements(GL_TRIANGLES, num_particles*6, GL_UNSIGNED_SHORT, indices);
        
        glVertexAttribPointer(shader_get_attrib_location(SHADER_VERTEX_NAME), 2, GL_FLOAT, GL_FALSE, 0, 0);
        glDisableVertexAttribArray(shader_get_attrib_location(SHADER_VERTEX_NAME));
        
        glVertexAttribPointer(shader_get_attrib_location(SHADER_TEXTURE_COORD_NAME), 2, GL_FLOAT, GL_FALSE, 0, 0);
        glDisableVertexAttribArray(shader_get_attrib_location(SHADER_TEXTURE_COORD_NAME));

        free(vertices);
        free(tex_coords);
    }
} 
コード例 #7
0
ファイル: ui_mgr.c プロジェクト: LeifAndersen/TuxRider
/*! 
  Draws the mouse cursor
  \author  jfpatry
  \date    Created:  2000-09-29
  \date    Modified: 2000-09-29
*/
static void ui_draw_cursor( void )
{
    GLuint texobj;
    char *binding;

    binding = "mouse_cursor";
    if ( !get_texture_binding( binding, &texobj ) ) {
	texobj = 0;
    }

    ui_setup_display();

    glBindTexture( GL_TEXTURE_2D, texobj );
    
	#ifdef __APPLE__DISABLED__
	
	   const GLfloat vertices []=
	   {
	       cursor_pos.x, cursor_pos.y,
	       cursor_pos.x, cursor_pos.y - CURSOR_TEX_SIZE,
	       cursor_pos.x + CURSOR_TEX_SIZE, cursor_pos.y - CURSOR_TEX_SIZE,
	       cursor_pos.x + CURSOR_TEX_SIZE, cursor_pos.y
	   };

		const GLfloat texCoords []=
	   {
	       0,1,
	       0,0,
	       1,0,
	       1,1
	   };

	   glEnableClientState (GL_VERTEX_ARRAY);
	   glVertexPointer (2, GL_FLOAT , 0, vertices);	
	   glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
	   glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

	#else
	
    glBegin( GL_QUADS );
    {
	glTexCoord2f( 0, 1 );
	glVertex2f( cursor_pos.x, 
		    cursor_pos.y );

	glTexCoord2f( 0, 0 );
	glVertex2f( cursor_pos.x, 
		    cursor_pos.y - CURSOR_TEX_SIZE );

	glTexCoord2f( 1, 0 );
	glVertex2f( cursor_pos.x + CURSOR_TEX_SIZE, 
		    cursor_pos.y - CURSOR_TEX_SIZE );

	glTexCoord2f( 1, 1 );
	glVertex2f( cursor_pos.x + CURSOR_TEX_SIZE, 
		    cursor_pos.y );

    }
    glEnd();
    
    #endif
}
コード例 #8
0
ファイル: game_over.c プロジェクト: anil11/Tux-Racer-4-iOS
void game_over_loop( scalar_t time_step )
{
    player_data_t *plyr = get_player_data( local_player() );
    int width, height;
    width = getparam_x_resolution();
    height = getparam_y_resolution();

    check_gl_error();

    /* Check joystick */
    if ( is_joystick_active() ) {
        update_joystick();

        if ( is_joystick_continue_button_down() )
        {
            set_game_mode( NEXT_MODE );
            winsys_post_redisplay();
            return;
        }
    }

    new_frame_for_fps_calc();

    update_audio();

    clear_rendering_context();

    setup_fog();

    update_player_pos( plyr, 0 );
    update_view( plyr, 0 );

    setup_view_frustum( plyr, NEAR_CLIP_DIST,
                        getparam_forward_clip_distance() );

    draw_sky(plyr->view.pos);

    draw_fog_plane();

    set_course_clipping( True );
    set_course_eye_point( plyr->view.pos );
    setup_course_lighting();
    render_course();
    draw_trees();

    if ( getparam_draw_particles() ) {
        draw_particles( plyr );
    }

    draw_tux();
    draw_tux_shadow();

    set_gl_options( GUI );

    ui_setup_display();

    draw_game_over_text();

#ifndef __APPLE__
    draw_hud( plyr );
#endif
    draw_hud_training(plyr);
    reshape( width, height );

    winsys_swap_buffers();
}
コード例 #9
0
ファイル: loading.c プロジェクト: wosigh/tuxracer
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);
    }

}