void RenderSingleFrame (double timestep) {
	if (!must_render) return;
	check_gl_error ();

	// ------------------ 3d scenery ----------------------------------
	set_gl_options (TUX);
    ClearRenderContext (colDDBackgr);

	string hlname = TestFrame.GetHighlightName (curr_joint);
	TestChar.highlight_node = TestChar.GetNodeName (hlname);

	glPushMatrix ();
 	SetToolLight ();
	GluCamera.Update (timestep);

	TestFrame.CalcKeyframe (curr_frame, &TestChar, ref_position);
	TestChar.Draw ();
	glPopMatrix ();

	// ----------------- 2d screen ------------------------------------
	SetupGuiDisplay ();
	set_gl_options (TEXFONT);

	if (FrameHasChanged ()) DrawChanged ();

	FT.SetFont ("bold");
	FT.SetSize (20);
	FT.SetColor (colYellow);
	FT.DrawString (-1, 10, "Keyframe mode");

	FT.SetFont ("normal");
	FT.SetSize (16);
	int xl, yt;
	for (int i=0; i<TestFrame.numFrames; i++) {
		if (i != curr_frame) {
			FT.SetColor (colLGrey); 
			FT.SetFont ("normal");
		} else {
			FT.SetColor (colYellow);
			FT.SetFont ("bold");
		}
		xl = ITrunc (i, framebase) * 100 + 20;
		yt = IFrac (i, framebase) * 18 + 20;
		FT.DrawString (xl, yt, Int_StrN (i));		
	}

	FT.SetFont ("normal");
	FT.SetColor (colLGrey); 
	PrintFrameParams (param.y_resolution - 330, TestFrame.GetFrame (curr_frame));

	if (ToolsFinalStage ()) {
		FT.SetSize (20);
		FT.SetColor (colYellow);
		FT.DrawString (-1, param.y_resolution - 50, "Quit program. Save character list (y/n)");
	}

	Reshape (param.x_resolution, param.y_resolution);
    Winsys.SwapBuffers();
	must_render = false;
}
Exemple #2
0
void TestLoop (double timestep) {
	check_gl_error();

	// ------------- 3d scenery ---------------------------------------
	set_gl_options (TUX);
    ClearRenderContext (colDDBackgr);

	glLoadIdentity ();
	glPushMatrix ();
 	SetTestLight ();

/*
	glTranslatef (xposition, yposition, zposition);	
	glRotatef (xrotation, 1, 0, 0);
	glRotatef (yrotation, 0, 1, 0);
	glRotatef (zrotation, 0, 0, 1);
*/
	glPopMatrix ();

	// --------------- 2d screen --------------------------------------
	SetupGuiDisplay ();
	set_gl_options (TEXFONT);
	FT.SetFont ("bold");
	FT.SetSize (24);
	FT.SetColor (colWhite);
	FT.DrawString (CENTER, 10, "Test screen");
	Reshape (param.x_resolution, param.y_resolution);
    Winsys.SwapBuffers ();
} 
Exemple #3
0
void
Paused::postDisplay(float timestep)
{
    reshape(resolution);
    set_gl_options(GUI);

    if(Benchmark::getMode()!=Benchmark::PAUSED) {
        gl::PushMatrix();
        {
            gl::MatrixMode(GL_PROJECTION);
            gl::LoadIdentity();
            gl::Ortho(0.0, resolution.x(), 0.0, resolution.y(), -1.0, 1.0);
            gl::MatrixMode(GL_MODELVIEW);
            gl::LoadIdentity();
            gl::Translate(0.0, 0.0, -1.0);
            gl::Color(ppogl::Color::white);

            gl::Disable(GL_TEXTURE_2D);
            gl::Color(0.0,0.0,0.0,0.5);
            gl::Rect(0,0,resolution.x(), resolution.y());
            gl::Enable(GL_TEXTURE_2D);
        }
        gl::PopMatrix();

        ppogl::UIManager::getInstance().draw(resolution,
                                             false); // no decoration
    }
}
Exemple #4
0
 /*! 
  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();
 }
void PopRenderMode()
{
	TRenderMode mode = modestack.top();
	modestack.pop();
	if(!modestack.empty() && modestack.top() != mode)
		set_gl_options(modestack.top());
}
Exemple #6
0
void RegistLoop (double timestep ){
	int ww = param.x_resolution;
	int hh = param.y_resolution;
	Music.Update ();    
	check_gl_error();
    ClearRenderContext ();
    set_gl_options (GUI);
    SetupGuiDisplay ();
	TColor col;
		
	update_ui_snow (timestep);
	draw_ui_snow();

	Tex.Draw (BOTTOM_LEFT, 0, hh - 256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);
	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), scale);

//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top, 
//			0, colMBackgr, col, 0.2);

	FT.AutoSizeN (3);
	FT.SetColor (colWhite);
	int top = AutoYPosN (24);
	FT.DrawString (area.left, top, "Select your player name:");
	FT.DrawString (area.left + framewidth + arrowwidth, top, "Select a character:");

	FT.AutoSizeN (4);
	if (curr_focus == 0) col = colDYell; else col = colWhite;
	DrawFrameX (area.left, area.top, framewidth, frameheight, 3, colMBackgr, col, 1.0);
	FT.SetColor (col);
	FT.DrawString (area.left + 20, area.top, Players.GetName (curr_player));
	Tex.DrawDirectFrame (Players.GetAvatarID (curr_player), 
		area.left + 60, AutoYPosN (40), texsize, texsize, 3, colWhite);

	if (curr_focus == 1) col = colDYell; else col = colWhite;
	DrawFrameX (area.left + framewidth + arrowwidth, area.top, 
		framewidth, frameheight, 3, colMBackgr, col, 1.0);
	FT.SetColor (col);
	FT.DrawString (area.left + framewidth + arrowwidth + 20, 
		area.top, CharList[curr_character].name);
	Tex.DrawDirectFrame (CharList[curr_character].preview, 
		area.right - texsize - 60 - arrowwidth, 
		AutoYPosN (40), texsize, texsize, 3, colWhite);


	FT.SetColor (colWhite);
	PrintArrow (0, (curr_player > 0));	

	PrintArrow (1, (curr_player < last_player));
	PrintArrow (2, (curr_character > 0));	
	PrintArrow (3, (curr_character < last_character));

	PrintTextButton (0, curr_focus);
	PrintTextButton (1, curr_focus);

	if (param.ice_cursor) DrawCursor ();
    Winsys.SwapBuffers();
} 
Exemple #7
0
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();
}
Exemple #8
0
void CreditsLoop (double time_step) {
	int ww = param.x_resolution;
	int hh = param.y_resolution;
	
	Music.Update ();    
	check_gl_error();
    ClearRenderContext ();
    set_gl_options (GUI);
    SetupGuiDisplay ();

//	DrawBackLogo (-1,  AutoYPos (200), 1.0);
	DrawCreditsText (time_step);
	if (param.ui_snow) {
		update_ui_snow (time_step);
		draw_ui_snow();
    }
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);
 	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), param.scale);
	

	Reshape (ww, hh);
    Winsys.SwapBuffers();
}
static void GameSelectLoop (double time_step) {
	int ww = param.x_resolution;
	int hh = param.y_resolution;

	check_gl_error();
	Music.Update ();    
    set_gl_options (GUI);
    ClearRenderContext ();
    SetupGuiDisplay ();
    
	if (param.ui_snow) {
		update_ui_snow (time_step);
		draw_ui_snow();
    }

	Tex.Draw (T_TITLE, CENTER, AutoYPosN (5), param.scale);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);

	PrintTextButton (0, scope);
	PrintTextButton (1, scope);
	PrintTextButton (2, scope);
	PrintTextButton (3, scope);
	PrintTextButton (4, scope);
	PrintTextButton (5, scope);
	PrintTextButton (6, scope);

	if (param.ice_cursor) DrawCursor ();
	Reshape (ww, hh);
	Winsys.SwapBuffers ();
}
Exemple #10
0
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();
} 
  void
GameOver::loop(float timeStep)
{
  int width, height;
  width = getparam_x_resolution();
  height = getparam_y_resolution();

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

    if ( is_joystick_continue_button_down() )
    {
      if ( gameMgr->gametype != GameMgr::PRACTICING ) {
        set_game_mode( EVENT_RACE_SELECT );
      }else{
        set_game_mode( RACE_SELECT );
      }
      winsys_post_redisplay();
      return;
    }
  }
  fpsCounter.update();

  update_audio();

  clear_rendering_context();

  fogPlane.setup();
  update_player_pos( players[0], 0 );
  update_view( players[0], 0 );

  setup_view_frustum( players[0], NEAR_CLIP_DIST, 
      getparam_forward_clip_distance() );

  draw_sky(players[0].view.pos);
  draw_fog_plane();

  set_course_clipping( true );
  set_course_eye_point( players[0].view.pos );
  setup_course_lighting();
  render_course();
  draw_trees();
  if ( getparam_draw_particles() ) {
    draw_particles( players[0] );
  }

  ModelHndl->draw_tux();
  draw_tux_shadow();
  set_gl_options( GUI );

  UIMgr.setupDisplay();
  UIMgr.draw();

  HUD1.draw(players[0]);
  reshape( width, height );

  winsys_swap_buffers();
}
void EventSelectLoop (double timestep) {
	int ww = param.x_resolution;
	int hh = param.y_resolution;
	TColor col;
		
	check_gl_error();
   	set_gl_options (GUI );
	Music.Update ();    
    ClearRenderContext ();
	SetupGuiDisplay ();

	if (param.ui_snow) {
		update_ui_snow (timestep);
		draw_ui_snow ();
	}

	Tex.Draw (T_TITLE_SMALL, CENTER, AutoYPosN (5), param.scale);
	Tex.Draw (BOTTOM_LEFT, 0, hh-256, 1);
	Tex.Draw (BOTTOM_RIGHT, ww-256, hh-256, 1);
	Tex.Draw (TOP_LEFT, 0, 0, 1);
	Tex.Draw (TOP_RIGHT, ww-256, 0, 1);
	
//	DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top, 
//			0, colMBackgr, colBlack, 0.2);

	FT.AutoSizeN (3);
	FT.SetColor (colWhite);
	FT.DrawString (area.left, AutoYPosN (30), Trans.Text (6));
	FT.DrawString (area.left,AutoYPosN (45), Trans.Text (7));
	if (Events.IsUnlocked (curr_event, curr_cup) == false) {
		FT.SetColor (colLGrey);
 		FT.DrawString (CENTER, AutoYPosN (58), Trans.Text (10));
	}

	FT.AutoSizeN (4);

	if (curr_focus == 0) col = colDYell; else col = colWhite;
	DrawFrameX (area.left, frametop1, framewidth, frameheight, 3, colMBackgr, col, 1.0);
	FT.SetColor (colDYell);
	FT.DrawString (area.left + 20, frametop1, EventList[curr_event].name);

	if (curr_focus == 1) col = colDYell; else col = colWhite;
	DrawFrameX (area.left, frametop2, framewidth, frameheight, 3, colMBackgr, col, 1.0);
	if (Events.IsUnlocked (curr_event, curr_cup)) FT.SetColor (colDYell); 
		else FT.SetColor (colLGrey);
	FT.DrawString (area.left + 20, frametop2, Events.GetCupTrivialName (curr_event, curr_cup));

	PrintArrow (0, (curr_event > 0));	
	PrintArrow (1, (curr_event < last_event));
	PrintArrow (2, (curr_cup > 0));	
	PrintArrow (3, (curr_cup < last_cup));

	if (Events.IsUnlocked (curr_event, curr_cup)) PrintTextButton (0, curr_focus);
	PrintTextButton (1, curr_focus);

	if (param.ice_cursor) DrawCursor ();
    SDL_GL_SwapBuffers ();
}
Exemple #13
0
void flat_mode()
{
    set_gl_options( TEXT );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrthof( -0.5, 639.5, -0.5, 479.5, -1.0, 1.0 );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
}
void
EventSelect::loop(float timeStep)
{
    set_gl_options( GUI );
	drawSnow(timeStep);
    
	ppogl::UIManager::getInstance().draw(resolution);

    reshape(resolution);
}
void
Configuration::loop(float timeStep)
{
    set_gl_options( GUI );
	
	drawSnow(timeStep);

	// draw ui
	ppogl::UIManager::getInstance().draw(resolution);
    reshape(resolution);
}
Exemple #16
0
void CCharShape::Draw () {
    TCharNode *node;
    float dummy_color[]  = {0.0, 0.0, 0.0, 1.0};

    glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, dummy_color);
    set_gl_options (TUX);
	glEnable (GL_NORMALIZE);
	
	if (!GetNode (0, &node)) return;
	DrawNodes (node);
	glDisable (GL_NORMALIZE);
	if (param.perf_level > 2 && g_game.argument == 0) DrawShadow ();
 	highlighted = false;
} 
Exemple #17
0
void CCharShape::DrawShadow () {
    TMatrix model_matrix;
    TCharNode *node;

    if (g_game.light_id == 1 || g_game.light_id == 3) return;

    set_gl_options (TUX_SHADOW); 
    glColor4f (shad_col.r, shad_col.g, shad_col.b, shad_col.a);
    MakeIdentityMatrix (model_matrix);

    if (GetNode (0, &node) == false) {
		Message ("couldn't find tux's root node", "");
		return;
    } 
    TraverseDagForShadow (node, model_matrix);
}
Exemple #18
0
void draw_bonus(player_data_t *plyr) {
    bonus_data_t* bonus = bonus_list;

    int i=0;
    while (bonus!=NULL)
    {
        i++;
        bonus_data_t* next_bonus = bonus->next;
        scalar_t anim_time = g_game.time-bonus->start_time;
        if (anim_time < BONUS_TIME_ANIMATION) {
            char *binding;
            font_t *font;

            //Use the same font as for FPS
            binding = "bonus";

            if ( !get_font_binding( binding, &font ) ) {
                print_warning( IMPORTANT_WARNING,
                               "Couldn't get font for binding %s", binding );
                return;
            }

            char* string = bonus->bonus_string;

            set_font_color(font, color_from_time_delta(anim_time));
            set_font_size(font, scale_from_time_delta(anim_time) * 12);
            scalar_t width, a, d;
            get_font_metrics_scalar( font, string, &width, &a, &d);

            bind_font_texture( font );
            set_gl_options( TEXFONT );

            glPushMatrix();
            {
                glTranslatef( 800 * (1 - position_from_time_delta(anim_time)) - width/2 - 140, 200.0 + i*18.0, 0 );

                draw_string( font, string );
            }
            glPopMatrix();
        } else {
            remove_bonus(bonus);
        }

        bonus = next_bonus;

    }
}
Exemple #19
0
void render_course()
{
    int nx, ny;
    
    get_course_divisions(&nx, &ny);
    set_gl_options( COURSE );
    
    setup_course_tex_gen();
    
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    set_material( white, black, 1.0 );
    
    update_course_quadtree( eye_pt, getparam_course_detail_level() );
    
    render_course_quadtree( );
    
    draw_track_marks();
}
Exemple #20
0
// -------------------------------------------------------
void DrawHud (CControl *ctrl) {
    TVector3 vel;
    double speed;

	if (!param.show_hud) return;
    vel = ctrl->cvel;
    speed = NormVector (&vel);
    SetupGuiDisplay ();

    draw_gauge (speed * 3.6, ctrl->jump_amt);
	set_gl_options (TEXFONT);
	glColor4f (1, 1, 1, 1);
    draw_time();
    draw_herring_count (g_game.herring);
    DrawSpeed (speed * 3.6);
	DrawFps ();
	DrawCoursePosition (ctrl);
	if (g_game.wind_id > 0) DrawWind2 (Wind.Angle (), Wind.Speed (), ctrl);
}
void RenderSequence (double timestep) {
	check_gl_error();
	set_gl_options (TUX);
    ClearRenderContext (colDDBackgr);

	GluCamera.Update (timestep);
	if (TestFrame.active) TestFrame.UpdateTest (timestep, &TestChar);
	else if (keyrun) {
		TestFrame.InitTest (NullVec, &TestChar);
		keyrun = false;
	}

	glPushMatrix ();
	TestChar.Draw ();
	glPopMatrix ();

	Reshape (param.x_resolution, param.y_resolution);
    Winsys.SwapBuffers();
}
Exemple #22
0
void draw_tux()
{
    if(get_player_data(0)->view.mode == TUXEYE) return;

    GLfloat dummy_colour[]  = { 0.0, 0.0, 0.0, 1.0 };

    /* XXX: For some reason, inserting this call here makes Tux render
     * with correct lighting under Mesa 3.1. I'm guessing it's a Mesa bug.
     */
    glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, dummy_colour );

    set_gl_options( TUX );

    /* Turn on lights
     */
    setup_course_lighting();

    draw_scene_graph( tuxRootNode );
} 
Exemple #23
0
void GameOverLoop (double time_step) {
    CControl *ctrl = Players.GetCtrl (g_game.player_id);
    int width, height;
    width = param.x_resolution;
    height = param.y_resolution;
    check_gl_error();

    Music.Update ();

    ClearRenderContext ();
    Env.SetupFog ();

    update_view (ctrl, 0);

    if (final_frame != NULL) final_frame->Update (time_step, ctrl);

    SetupViewFrustum (ctrl);
    Env.DrawSkybox (ctrl->viewpos);
    Env.DrawFog ();
    Env.SetupLight ();

    RenderCourse ();
    DrawTrackmarks ();
    DrawTrees ();

    UpdateWind (time_step, ctrl);
    UpdateSnow (time_step, ctrl);
    DrawSnow (ctrl);

    Char.Draw (g_game.char_id);

    set_gl_options (GUI);
    SetupGuiDisplay ();
    if (final_frame != NULL) {
        if (!final_frame->active) GameOverMessage (ctrl);
    } else GameOverMessage (ctrl);
    DrawHud (ctrl);
    Reshape (width, height);
    Winsys.SwapBuffers ();
}
Exemple #24
0
/*! 
 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();
}
void SplashLoop (double /*timestep*/){
	Music.Update ();    
	check_gl_error();
	ClearRenderContext ();
	set_gl_options (GUI);
	SetupGuiDisplay ();


//	FT.SetFont ("normal");
	Tex.Draw (TEXLOGO, CENTER, 60, param.scale);
	FT.SetColor (colDYell);
	FT.AutoSizeN (6);
	int top = AutoYPosN (60);
	int dist = FT.AutoDistanceN (3);
	FT.DrawText (CENTER, top, "Loading resources,");
	FT.DrawText (CENTER, top+dist, "please wait ...");


	if (param.ice_cursor) DrawCursor ();
    Winsys.SwapBuffers();

	Trans.LoadLanguages ();
	Trans.LoadTranslations (param.language);
	LoadCreditList ();
	Char.LoadCharacterList ();
	Course.LoadObjectTypes (); 
	Course.LoadTerrainTypes ();
	Env.LoadEnvironmentList ();
	Course.LoadCourseList ();
	Score.LoadHighScore (); // after LoadCourseList !!!
	Events.LoadEventList ();
	Players.LoadAvatars (); // before LoadPlayers !!!
	Players.LoadPlayers ();

	Winsys.Delay (10);
	Winsys.SetMode (REGIST);
} 
Exemple #26
0
void
HUD::draw(const Player& plyr, const ppogl::Vec2i& resolution)
{
	m_resolution = resolution;
	
	gl::PushMatrix();
	{
	gl::MatrixMode(GL_PROJECTION);
    gl::LoadIdentity();
    gl::Ortho(0.0, m_resolution.x(), 0.0,
			  m_resolution.y(), -1.0, 1.0);
    gl::MatrixMode(GL_MODELVIEW);
    gl::LoadIdentity();
    gl::Translate(0.0, 0.0, -1.0);
	
	set_gl_options( TEXFONT );
		
	for(int i=0; i<m_numElements; i++){	
		switch(m_element[i].type){
			case 0:
				text(i);
				break;
			case 1:
				if(GameConfig::displayFPS){
					fps(i);
    			}	
				break;
			case 2:
				herring(i,plyr.herring);
				break;
			case 3:
				image(i);
				break;
			case 4:
				time(i);
				break;	
			case 5:
				{
				ppogl::Vec3d vel = plyr.vel;
    			speed(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H);
				}
				break;
			case 6:
				{
				ppogl::Vec3d vel = plyr.vel;
				gauge(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H,plyr.control.jump_amt);
				}
				break;
			case 7:
				bar(i,plyr.control.jump_amt);
				break;
			case 8:
				{
				ppogl::Vec3d vel = plyr.vel;
				bar(i,vel.normalize()* M_PER_SEC_TO_KM_PER_H/135);
				}	
				break;
			case 9:
				if(GameConfig::displayCoursePercentage){
					coursePercentage(i, plyr);
				}
				break;
			case 10:
				if(GameConfig::displayCoursePercentage){		
					bar(i,plyr.getCoursePercentage()/100);
				}
				break;
			case 11:
				if(GameConfig::displayCoursePercentage){		
					image(i);
				}
				break;				
			case 12:
				if(GameConfig::displayFPS){
					image(i);
    			}	
				break;
		}
	}
	
	}
	gl::PopMatrix();
}
Exemple #27
0
void
HUD::gauge(const int i, const double _speed, const double energy)
{
	const GLfloat xplane[4] = { 1.0/m_element[i].size, 0.0, 0.0, 0.0 };
    const GLfloat yplane[4] = { 0.0, 1.0/m_element[i].size, 0.0, 0.0 };

	//the gauge bar needs it's own mode
	//we reset the mode at the end of the function
    set_gl_options( GAUGE_BARS );

    gl::TexGen(GL_S, GL_OBJECT_PLANE, xplane);
    gl::TexGen(GL_T, GL_OBJECT_PLANE, yplane);

    gl::PushMatrix();
    {
	gl::Translate(m_resolution.x() - m_element[i].width,0);

	gl::Color(energy_background_color);

	gl::BindTexture(GL_TEXTURE_2D, m_energymaskTex);

	const double y = ENERGY_GAUGE_BOTTOM + energy * m_element[i].height;

	gl::Begin( GL_QUADS );
	{
	    gl::Vertex(0.0, y);
	    gl::Vertex(m_element[i].size, y);
	    gl::Vertex(m_element[i].size, m_element[i].size);
	    gl::Vertex(0.0, m_element[i].size);
	}
	gl::End();

	gl::Color(energy_foreground_color);

	gl::Begin(GL_QUADS);
	{
	    gl::Vertex(0.0, 0.0);
	    gl::Vertex(m_element[i].size, 0.0);
	    gl::Vertex(m_element[i].size, y);
	    gl::Vertex(0.0, y);
	}
	gl::End();

	// Calculate the fraction of the speed bar to fill
	double speedbar_frac = 0.0;

	if ( _speed > SPEEDBAR_GREEN_MAX_SPEED ) {
	    speedbar_frac = SPEEDBAR_GREEN_FRACTION;
	    
	    if ( _speed > SPEEDBAR_YELLOW_MAX_SPEED ) {
		speedbar_frac += SPEEDBAR_YELLOW_FRACTION;
		
		if ( _speed > SPEEDBAR_RED_MAX_SPEED ) {
		    speedbar_frac += SPEEDBAR_RED_FRACTION;
		} else {
		    speedbar_frac +=
			( _speed - SPEEDBAR_YELLOW_MAX_SPEED ) /
			( SPEEDBAR_RED_MAX_SPEED - SPEEDBAR_YELLOW_MAX_SPEED ) *
			SPEEDBAR_RED_FRACTION;
		}

	    } else {
		speedbar_frac += 
		    ( _speed - SPEEDBAR_GREEN_MAX_SPEED ) /
		    ( SPEEDBAR_YELLOW_MAX_SPEED - SPEEDBAR_GREEN_MAX_SPEED ) *
		    SPEEDBAR_YELLOW_FRACTION;
	    }
	    
	} else {
	    speedbar_frac +=  _speed/SPEEDBAR_GREEN_MAX_SPEED * 
		SPEEDBAR_GREEN_FRACTION;
	}

	gl::Color(speedbar_background_color);

	gl::BindTexture(GL_TEXTURE_2D, m_speedmaskTex);

	draw_partial_tri_fan(1.0);

	gl::Color(ppogl::Color::white);

	draw_partial_tri_fan( MIN( 1.0, speedbar_frac ) );

	gl::Color(ppogl::Color::white);

	gl::BindTexture(GL_TEXTURE_2D, m_outlineTex);

	gl::Begin(GL_QUADS);
	{
	    gl::Vertex(0.0, 0.0);
	    gl::Vertex(m_element[i].size, 0.0);
	    gl::Vertex(m_element[i].size, m_element[i].size);
	    gl::Vertex(0.0, m_element[i].size);
	}
	gl::End();
	
    }
    gl::PopMatrix();
	
	//we reset this because all other elements need TEXFONT
	set_gl_options( TEXFONT );
}
Exemple #28
0
void draw_gauge (double speed, double energy) {
    GLfloat xplane[4] = {1.0 / GAUGE_IMG_SIZE, 0.0, 0.0, 0.0 };
    GLfloat yplane[4] = {0.0, 1.0 / GAUGE_IMG_SIZE, 0.0, 0.0 };
    double y;
    double speedbar_frac;

    set_gl_options (GAUGE_BARS);

	if (Tex.TexID (GAUGE_ENERGY) < 1) return;
	if (Tex.TexID (GAUGE_SPEED) < 1) return;
	if (Tex.TexID (GAUGE_OUTLINE) < 1) return;
	
	Tex.BindTex (GAUGE_ENERGY);
    glTexGenfv (GL_S, GL_OBJECT_PLANE, xplane);
    glTexGenfv (GL_T, GL_OBJECT_PLANE, yplane);

    glPushMatrix();
	glTranslatef (param.x_resolution - GAUGE_WIDTH, 0, 0);
	Tex.BindTex (GAUGE_ENERGY);
	y = ENERGY_GAUGE_BOTTOM + energy * ENERGY_GAUGE_HEIGHT;

	glColor4fv (energy_background_color);
	glBegin (GL_QUADS);
	    glVertex2f (0.0, y);
	    glVertex2f (GAUGE_IMG_SIZE, y);
	    glVertex2f (GAUGE_IMG_SIZE, GAUGE_IMG_SIZE);
	    glVertex2f (0.0, GAUGE_IMG_SIZE);
	glEnd ();

	glColor4fv (energy_foreground_color);
	glBegin (GL_QUADS);
	    glVertex2f (0.0, 0.0);
	    glVertex2f (GAUGE_IMG_SIZE, 0.0);
	    glVertex2f (GAUGE_IMG_SIZE, y);
	    glVertex2f (0.0, y);
	glEnd ();

	speedbar_frac = 0.0;

	if  (speed > SPEEDBAR_GREEN_MAX_SPEED) {
	    speedbar_frac = SPEEDBAR_GREEN_FRACTION;
	    
	    if  (speed > SPEEDBAR_YELLOW_MAX_SPEED) {
			speedbar_frac += SPEEDBAR_YELLOW_FRACTION;
			if  (speed > SPEEDBAR_RED_MAX_SPEED) {
				speedbar_frac += SPEEDBAR_RED_FRACTION;
			} else {
				speedbar_frac += (speed - SPEEDBAR_YELLOW_MAX_SPEED) /
				(SPEEDBAR_RED_MAX_SPEED - SPEEDBAR_YELLOW_MAX_SPEED) * SPEEDBAR_RED_FRACTION;
			}
	    } else {
			speedbar_frac += (speed - SPEEDBAR_GREEN_MAX_SPEED) /
				(SPEEDBAR_YELLOW_MAX_SPEED - SPEEDBAR_GREEN_MAX_SPEED) * SPEEDBAR_YELLOW_FRACTION;
	    }	    
	} else {
	    speedbar_frac +=  speed/SPEEDBAR_GREEN_MAX_SPEED * SPEEDBAR_GREEN_FRACTION;
	}

	glColor4fv (speedbar_background_color);
	Tex.BindTex (GAUGE_SPEED);
	draw_partial_tri_fan (1.0);
	glColor4fv (hud_white);
	draw_partial_tri_fan (min (1.0, speedbar_frac));

	glColor4fv (hud_white);
	Tex.BindTex (GAUGE_OUTLINE);
	glBegin (GL_QUADS);
	    glVertex2f (0.0, 0.0);
	    glVertex2f (GAUGE_IMG_SIZE, 0.0);
	    glVertex2f (GAUGE_IMG_SIZE, GAUGE_IMG_SIZE);
	    glVertex2f (0.0, GAUGE_IMG_SIZE);
	glEnd();
    glPopMatrix();
}
Exemple #29
0
void CEnvironment::DrawFog () {
    TPlane bottom_plane, top_plane;
    TVector3 left, right;
    TVector3 topleft, topright;
    TVector3 bottomleft = NullVec; 
    TVector3 bottomright = NullVec;
    float height;

    if (!fog.is_on) return;

    // the clipping planes are calculated by view frustum (view.cpp)
    leftclip = get_left_clip_plane ();
    rightclip = get_right_clip_plane ();
    farclip = get_far_clip_plane ();
    bottomclip = get_bottom_clip_plane ();

    // --------------- calculate the planes ---------------------------

    float slope = tan (ANGLES_TO_RADIANS (Course.GetCourseAngle()));
//	TPlane left_edge_plane = MakePlane (1.0, 0.0, 0.0, 0.0);
//	TPlane right_edge_plane = MakePlane (-1.0, 0.0, 0.0, Course.width);

    bottom_plane.nml = MakeVector (0.0, 1, -slope);
    height = Course.GetBaseHeight (0);
    bottom_plane.d = -height * bottom_plane.nml.y;

    top_plane.nml = bottom_plane.nml;
    height = Course.GetMaxHeight (0) + fog.height;
    top_plane.d = -height * top_plane.nml.y;

    if (!IntersectPlanes (bottom_plane, farclip, leftclip,  &left)) return;
    if (!IntersectPlanes (bottom_plane, farclip, rightclip, &right)) return;
    if (!IntersectPlanes (top_plane,    farclip, leftclip,  &topleft)) return;
    if (!IntersectPlanes (top_plane,    farclip, rightclip, &topright)) return;
    if (!IntersectPlanes (bottomclip,   farclip, leftclip,  &bottomleft)) return;
    if (!IntersectPlanes (bottomclip,   farclip, rightclip, &bottomright)) return;

    TVector3 leftvec  = SubtractVectors (topleft, left);
    TVector3 rightvec = SubtractVectors (topright, right);

    TVector3 vpoint1 = AddVectors (topleft, leftvec);
    TVector3 vpoint2 = AddVectors (topright, rightvec);
    TVector3 vpoint3 = AddVectors (topleft, ScaleVector (3.0, leftvec));
    TVector3 vpoint4 = AddVectors (topright, ScaleVector (3.0, rightvec));

    // --------------- draw the fog plane -----------------------------

    set_gl_options (FOG_PLANE);
    glEnable (GL_FOG);

    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);

	// only the alpha channel is used
	const GLfloat col[] = {
		// bottom density
		0, 0, 0, 1.0,
		0, 0, 0, 1.0,
		0, 0, 0, 1.0,
		0, 0, 0, 1.0,

		// top density
		0, 0, 0, 0.9,
		0, 0, 0, 0.9,

		// left/right density
		0, 0, 0, 0.3,
		0, 0, 0, 0.3,

		// top/bottom density
		0, 0, 0, 0.0,
		0, 0, 0, 0.0
	};

	const GLfloat vtx[] = {
		bottomleft.x, bottomleft.y, bottomleft.z,
		bottomright.x, bottomright.y, bottomright.z,
		left.x, left.y, left.z,
		right.x, right.y, right.z,
		topleft.x, topleft.y, topleft.z,
		topright.x, topright.y, topright.z,
		vpoint1.x, vpoint1.y, vpoint1.z,
		vpoint2.x, vpoint2.y, vpoint2.z,
		vpoint3.x, vpoint3.y, vpoint3.z,
		vpoint4.x, vpoint4.y, vpoint4.z
	};

	glColorPointer(4, GL_FLOAT, 0, col);
	glVertexPointer(3, GL_FLOAT, 0, vtx);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
}
Exemple #30
0
void CEnvironment::DrawSkybox (TVector3 pos) {
 	set_gl_options (SKY);
	double aa, bb;
	
#if defined (OS_LINUX)
	aa = 0.0;
	bb = 1.0;
#else
	aa = 0.005;
	bb = 0.995;
#endif

	glColor4f (1.0, 1.0, 1.0, 1.0);
	glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glPushMatrix();
	glTranslatef (pos.x, pos.y, pos.z);
	
	const GLfloat tex[] = {
		aa, aa,
		bb, aa,
		bb, bb,
		aa, bb
	};

	// front
	const GLfloat front[] = {
		-1, -1, -1,
		 1, -1, -1,
		 1,  1, -1,
		-1,  1, -1		
	};

	glBindTexture (GL_TEXTURE_2D, Skybox[0]);
	glVertexPointer(3, GL_FLOAT, 0, front);
	glTexCoordPointer(2, GL_FLOAT, 0, tex);
	glDrawArrays(GL_TRIANGLE_FAN,0,4);
	
	// left
	const GLfloat left[] = {
		-1, -1,  1,
		-1, -1, -1,
		-1,  1, -1,
		-1,  1,  1		
	};

	glBindTexture (GL_TEXTURE_2D, Skybox[1]);
	glVertexPointer(3, GL_FLOAT, 0, left);
	glTexCoordPointer(2, GL_FLOAT, 0, tex);
	glDrawArrays(GL_TRIANGLE_FAN,0,4);

	// right
	const GLfloat right[] = {
		 1, -1, -1,
		 1, -1,  1,
		 1,  1,  1,
		 1,  1, -1		
	};

	glBindTexture (GL_TEXTURE_2D, Skybox[2]);
	glVertexPointer(3, GL_FLOAT, 0, right);
	glTexCoordPointer(2, GL_FLOAT, 0, tex);
	glDrawArrays(GL_TRIANGLE_FAN,0,4);

	// normally, the following textures are unvisible
	// see game_config.cpp (param.full_skybox)
	if (param.full_skybox) {
		// top
		const GLfloat top[] = {
			-1,  1, -1,
			 1,  1, -1,
			 1,  1,  1,
			-1,  1,  1
		};

		glBindTexture (GL_TEXTURE_2D, Skybox[3]);
		glVertexPointer(3, GL_FLOAT, 0, top);
		glTexCoordPointer(2, GL_FLOAT, 0, tex);
		glDrawArrays(GL_TRIANGLE_FAN,0,4);
		
		// bottom
		const GLfloat bottom[] = {
			-1, -1,  1,
			 1, -1,  1,
			 1, -1, -1,
			-1, -1, -1
		};

		glBindTexture (GL_TEXTURE_2D, Skybox[4]);
		glVertexPointer(3, GL_FLOAT, 0, bottom);
		glTexCoordPointer(2, GL_FLOAT, 0, tex);
		glDrawArrays(GL_TRIANGLE_FAN,0,4);
		
		// back
		const GLfloat back[] = {
			 1, -1,  1,
			-1, -1,  1,
			-1,  1,  1,
			 1,  1,  1
		};

		glBindTexture (GL_TEXTURE_2D, Skybox[5]);
		glVertexPointer(3, GL_FLOAT, 0, back);
		glTexCoordPointer(2, GL_FLOAT, 0, tex);
		glDrawArrays(GL_TRIANGLE_FAN,0,4);
	}	
	glPopMatrix();

	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
}