Exemplo n.º 1
0
void CPaused::Loop(float time_step) {
	CControl *ctrl = g_game.player->ctrl;
	int width = Winsys.resolution.width;
	int height = Winsys.resolution.height;

	ClearRenderContext();
	Env.SetupFog();
	update_view(ctrl, 0);
	SetupViewFrustum(ctrl);

	if (sky) Env.DrawSkybox(ctrl->viewpos);
	if (fog) Env.DrawFog();
	Env.SetupLight();
	if (terr) RenderCourse();
	DrawTrackmarks();
	if (trees) DrawTrees();

	DrawSnow(ctrl);

	if (param.perf_level > 2) draw_particles(ctrl);
	g_game.character->shape->Draw();

	DrawHud(ctrl);
	Reshape(width, height);
	Winsys.SwapBuffers();
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Called once per frame, the call is the entry point for 3d
//       rendering. This function sets up render states, clears the
//       viewport, and renders the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
    // Clear the viewport
    m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L );

    // Begin the scene
    if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
    {
        // Render the Skybox
        {
            // Center view matrix for skybox and disable zbuffer
            D3DXMATRIX matView, matViewSave;
            m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSave );
            matView = matViewSave;
            matView._41 = 0.0f; matView._42 = -0.3f; matView._43 = 0.0f;
            m_pd3dDevice->SetTransform( D3DTS_VIEW,      &matView );
            m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
            // Some cards do not disable writing to Z when 
            // D3DRS_ZENABLE is FALSE. So do it explicitly
            m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );

            // Render the skybox
            m_pSkyBox->Render( m_pd3dDevice );

            // Restore the render states
            m_pd3dDevice->SetTransform( D3DTS_VIEW,      &matViewSave );
            m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
            m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE);
        }

        // Draw the terrain
        m_pTerrain->Render( m_pd3dDevice );

        // Draw the trees
        DrawTrees();

        // Output statistics
        m_pFont->DrawText( 2,  0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
        m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );

        // End the scene.
        m_pd3dDevice->EndScene();
    }

    return S_OK;
}
Exemplo n.º 3
0
void racing_loop (double time_step){
    CControl *ctrl = Players.GetCtrl (g_game.player_id);
	double ycoord = Course.FindYCoord (ctrl->cpos.x, ctrl->cpos.z);
	bool airborne = (bool) (ctrl->cpos.y > (ycoord + JUMP_MAX_START_HEIGHT));

    check_gl_error();
    ClearRenderContext ();
	Env.SetupFog ();
	Music.Update ();    

	CalcTrickControls (ctrl, time_step, airborne);

	if (!g_game.finish) CalcSteeringControls (ctrl, time_step);
		else CalcFinishControls (ctrl, time_step, airborne);
	PlayTerrainSound (ctrl, airborne);

//  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	ctrl->UpdatePlayerPos (time_step); 
//  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

	if (g_game.finish) IncCameraDistance (time_step);
	update_view (ctrl, time_step);
	UpdateTrackmarks (ctrl);

    SetupViewFrustum (ctrl);
	if (sky) Env.DrawSkybox (ctrl->viewpos);
	if (fog) Env.DrawFog ();
	void SetupLight ();
	if (terr) RenderCourse ();
	DrawTrackmarks ();
	if (trees) DrawTrees ();
	if (param.perf_level > 2) {
		update_particles (time_step);
		draw_particles (ctrl);
    }
	Char.Draw (g_game.char_id);
	UpdateWind (time_step, ctrl);
	UpdateSnow (time_step, ctrl);
	DrawSnow (ctrl);
	DrawHud (ctrl);
	
	Reshape (param.x_resolution, param.y_resolution);
    Winsys.SwapBuffers ();
	if (g_game.finish == false) g_game.time += time_step;
} 
Exemplo n.º 4
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 ();
}
Exemplo n.º 5
0
void CReset::Loop(double time_step) {
	CControl *ctrl = Players.GetCtrl (g_game.player_id);
    double elapsed_time = Winsys.ClockTime () - reset_start_time;
    static bool tux_visible = true;
    static int tux_visible_count = 0;

    check_gl_error();
	ClearRenderContext ();
    Env.SetupFog ();
    ctrl->UpdatePlayerPos (EPS);
    update_view (ctrl, EPS);
    SetupViewFrustum (ctrl);
    Env.DrawSkybox (ctrl->viewpos);
    Env.DrawFog ();
	Env.SetupLight ();	// and fog
    RenderCourse();
    DrawTrackmarks ();
    DrawTrees ();

    if ((elapsed_time > BLINK_IN_PLACE_TIME) && (!position_reset)) {
		TObjectType* object_types = &Course.ObjTypes[0];
		TItem* item_locs  = &Course.NocollArr[0];
		size_t num_item_types = Course.ObjTypes.size();
		size_t first_reset = 0;
		size_t last_reset = 0;
		for (size_t i = 0; i < num_item_types; i++) {
		    if (object_types[i].reset_point == true) {
				last_reset = first_reset + object_types[i].num_items - 1;
				break;
		    } else {
				first_reset += object_types[i].num_items;
		    }
		} // for

		if (last_reset == 0) {
		    ctrl->cpos.x = Course.GetDimensions().x/2.0;
		    ctrl->cpos.z = min(ctrl->cpos.z + 10, -1.0);
		} else {
			int best_loc = -1;
		    for (size_t i = first_reset; i <= last_reset; i++) {
				if (item_locs[i].pt.z > ctrl->cpos.z) {
				    if (best_loc == -1 || item_locs[i].pt.z < item_locs[best_loc].pt.z) {
						best_loc = (int)i;
				    } // if
				} // if
		    } // for

		    if (best_loc == -1) {
				ctrl->cpos.x = Course.GetDimensions().x/2.0;
				ctrl->cpos.z = min (ctrl->cpos.z + 10, -1.0);
		    } else if (item_locs[best_loc].pt.z <= ctrl->cpos.z) {
				ctrl->cpos.x = Course.GetDimensions().x/2.0;
				ctrl->cpos.z = min (ctrl->cpos.z + 10, -1.0);
		    } else {
				ctrl->cpos.x = item_locs[best_loc].pt.x;
				ctrl->cpos.z = item_locs[best_loc].pt.z;
		    } // if
		}

		ctrl->view_init = false;
		ctrl->Init ();
		position_reset = true;
    } // if elapsed time

    if (tux_visible) Char.Draw (g_game.char_id);

    if (++tux_visible_count > 3) {
		tux_visible = (bool) !tux_visible;
		tux_visible_count = 0;
    }

    DrawHud (ctrl);
	Reshape (Winsys.resolution.width, Winsys.resolution.height);
    Winsys.SwapBuffers ();
    g_game.time += time_step;

    if (elapsed_time > TOTAL_RESET_TIME) {
		State::manager.RequestEnterState (Racing);
    }
}