当前位置: 首页>>代码示例>>C++>>正文


C++ Present函数代码示例

本文整理汇总了C++中Present函数的典型用法代码示例。如果您正苦于以下问题:C++ Present函数的具体用法?C++ Present怎么用?C++ Present使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Present函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsAtRest

/*
================
idBarrel::BarrelThink
================
*/
void idBarrel::BarrelThink(void) {
	bool wasAtRest, onGround;
	float movedDistance, rotatedDistance, angle;
	idVec3 curOrigin, gravityNormal, dir;
	idMat3 curAxis, axis;
	wasAtRest = IsAtRest();
	// run physics
	RunPhysics();
	// only need to give the visual model an additional rotation if the physics were run
	if (!wasAtRest) {
		// current physics state
		onGround = GetPhysics()->HasGroundContacts();
		curOrigin = GetPhysics()->GetOrigin();
		curAxis = GetPhysics()->GetAxis();
		// if the barrel is on the ground
		if (onGround) {
			gravityNormal = GetPhysics()->GetGravityNormal();
			dir = curOrigin - lastOrigin;
			dir -= gravityNormal * dir * gravityNormal;
			movedDistance = dir.LengthSqr();
			// if the barrel moved and the barrel is not aligned with the gravity direction
			if (movedDistance > 0.0f && idMath::Fabs(gravityNormal * curAxis[barrelAxis]) < 0.7f) {
				// barrel movement since last think frame orthogonal to the barrel axis
				movedDistance = idMath::Sqrt(movedDistance);
				dir *= 1.0f / movedDistance;
				movedDistance = (1.0f - idMath::Fabs(dir * curAxis[barrelAxis])) * movedDistance;
				// get rotation about barrel axis since last think frame
				angle = lastAxis[(barrelAxis + 1) % 3] * curAxis[(barrelAxis + 1) % 3];
				angle = idMath::ACos(angle);
				// distance along cylinder hull
				rotatedDistance = angle * radius;
				// if the barrel moved further than it rotated about it's axis
				if (movedDistance > rotatedDistance) {
					// additional rotation of the visual model to make it look
					// like the barrel rolls instead of slides
					angle = 180.0f * (movedDistance - rotatedDistance) / (radius * idMath::PI);
					if (gravityNormal.Cross(curAxis[barrelAxis]) * dir < 0.0f) {
						additionalRotation += angle;
					}
					else {
						additionalRotation -= angle;
					}
					dir = vec3_origin;
					dir[barrelAxis] = 1.0f;
					additionalAxis = idRotation(vec3_origin, dir, additionalRotation).ToMat3();
				}
			}
		}
		// save state for next think
		lastOrigin = curOrigin;
		lastAxis = curAxis;
	}
	Present();
}
开发者ID:revelator,项目名称:Revelation-Engine,代码行数:59,代码来源:Moveable.cpp

示例2: ReadBindFromSnapshot

void hhProxDoorSection::ReadFromSnapshot( const idBitMsgDelta &msg ) {
	ReadBindFromSnapshot(msg);
	GetPhysics()->ReadFromSnapshot(msg);

	if (msg.HasChanged()) {
		Show();
		UpdateVisuals();
		Present();
		GetPhysics()->LinkClip();
	}
}
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:11,代码来源:game_proxdoor.cpp

示例3: Clear

		// Renders All objects
		void xSceneManager::RenderAll()
		{
			Clear();
			BeginScene();
			std::for_each(m_SceneNodes.begin(), m_SceneNodes.end(), 
				std::mem_fun(&Impulse::Scene::xSceneNode::Render));
			EndScene();
			Present();
			m_FrameCount++;
			m_TempFrameCount++;
		}
开发者ID:andrewgbliss,项目名称:XImpulse,代码行数:12,代码来源:xSceneManager.cpp

示例4: Initialize

void CFXAPISample::Run (const int frameCount)
{
    Initialize ();

    for (int i = 0; i < frameCount; ++i) {
        Render ();
        Present ();
    }

    Shutdown ();
}
开发者ID:CSRedRat,项目名称:AGS_SDK,代码行数:11,代码来源:CFXAPISample.cpp

示例5: RemoveShard

/*
================
idBrittleFracture::Think
================
*/
void idBrittleFracture::Think( void ) {
	int i, startTime, endTime, droppedTime;
	shard_t *shard;
	bool atRest = true, fading = false;
	// remove overdue shards
	for( i = 0; i < shards.Num(); i++ ) {
		droppedTime = shards[i]->droppedTime;
		if( droppedTime != -1 ) {
			if( gameLocal.time - droppedTime > SHARD_ALIVE_TIME ) {
				RemoveShard( i );
				i--;
			}
			fading = true;
		}
	}
	// remove the entity when nothing is visible
	if( !shards.Num() ) {
		PostEventMS( &EV_Remove, 0 );
		return;
	}
	if( thinkFlags & TH_PHYSICS ) {
		startTime = gameLocal.previousTime;
		endTime = gameLocal.time;
		// run physics on shards
		for( i = 0; i < shards.Num(); i++ ) {
			shard = shards[i];
			if( shard->droppedTime == -1 ) {
				continue;
			}
			shard->physicsObj.Evaluate( endTime - startTime, endTime );
			if( !shard->physicsObj.IsAtRest() ) {
				atRest = false;
			}
		}
		if( atRest ) {
			BecomeInactive( TH_PHYSICS );
		} else {
			BecomeActive( TH_PHYSICS );
		}
	}
	if( !atRest || bounds.IsCleared() ) {
		bounds.Clear();
		for( i = 0; i < shards.Num(); i++ ) {
			bounds.AddBounds( shards[i]->clipModel->GetAbsBounds() );
		}
	}
	if( fading ) {
		BecomeActive( TH_UPDATEVISUALS | TH_THINK );
	} else {
		BecomeInactive( TH_THINK );
	}
	RunPhysics();
	Present();
}
开发者ID:SL987654,项目名称:The-Darkmod-Experimental,代码行数:59,代码来源:BrittleFracture.cpp

示例6: DrawFov

/*
================
idSecurityCamera::Think
================
*/
void idSecurityCamera::Think( void ) {
	float pct;
	float travel;
	if( thinkFlags & TH_THINK ) {
		if( g_showEntityInfo.GetBool() ) {
			DrawFov();
		}
		if( health <= 0 ) {
			BecomeInactive( TH_THINK );
			return;
		}
	}
	// run physics
	RunPhysics();
	if( thinkFlags & TH_THINK ) {
		if( CanSeePlayer() ) {
			if( alertMode == SCANNING ) {
				float	sightTime;
				SetAlertMode( ALERT );
				stopSweeping = gameLocal.time;
				if( sweeping ) {
					CancelEvents( &EV_SecurityCam_Pause );
				} else {
					CancelEvents( &EV_SecurityCam_ReverseSweep );
				}
				sweeping = false;
				StopSound( SND_CHANNEL_ANY, false );
				StartSound( "snd_sight", SND_CHANNEL_BODY, 0, false, NULL );
				sightTime = spawnArgs.GetFloat( "sightTime", "5" );
				PostEventSec( &EV_SecurityCam_Alert, sightTime );
			}
		} else {
			if( alertMode == ALERT ) {
				float	sightResume;
				SetAlertMode( LOSINGINTEREST );
				CancelEvents( &EV_SecurityCam_Alert );
				sightResume = spawnArgs.GetFloat( "sightResume", "1.5" );
				PostEventSec( &EV_SecurityCam_ContinueSweep, sightResume );
			}
			if( sweeping ) {
				idAngles a = GetPhysics()->GetAxis().ToAngles();
				pct = ( gameLocal.time - sweepStart ) / ( sweepEnd - sweepStart );
				travel = pct * sweepAngle;
				if( negativeSweep ) {
					a.yaw = angle + travel;
				} else {
					a.yaw = angle - travel;
				}
				SetAngles( a );
			}
		}
	}
	Present();
}
开发者ID:nbohr1more,项目名称:Revelation,代码行数:59,代码来源:SecurityCamera.cpp

示例7: EnterPresentState

void					ESVideo::PresentFrame			(GLuint aID, uint32_t aWidth, uint32_t aHeight, const Area& aViewPort, bool aFlip)
{
	//Enter present state
	EnterPresentState();

	//Calculate output area
	Area presentArea;

	if(NoAspect)
	{
		uint32_t x = PresentArea.X, y = PresentArea.Y, w = PresentArea.Width, h = PresentArea.Height;
		Utility::CenterAndScale(x, y, w, h, aViewPort.Width, aViewPort.Height);

		presentArea = Area(x, y, w, h);
	}
	else
	{
		presentArea = PresentArea;
	}

	//Call kiddie present if possible
	if(SupportsShaders())
	{
		Present(aID, aWidth, aHeight, aViewPort, presentArea, aFlip);

		/* Reset vertex buffer */
		ApplyVertexBuffer(VertexBuffer);
	}
	else
	{
		float xl = (float)aViewPort.X / (float)aWidth;
		float xr = (float)aViewPort.Right() / (float)aWidth;
		float yl = (float)aViewPort.Y / (float)aHeight;
		float yr = (float)aViewPort.Bottom() / (float)aHeight;

		if(aFlip)
		{
			std::swap(yl, yr);
		}

		glBindTexture(GL_TEXTURE_2D, aID); glSplat();

		SetVertex(&VertexBuffer[0 * VertexSize], presentArea.X, 		presentArea.Y, 			1.0f, 1.0f, 1.0f, 1.0f, xl, yl);
		SetVertex(&VertexBuffer[1 * VertexSize], presentArea.Right(), 	presentArea.Y, 			1.0f, 1.0f, 1.0f, 1.0f, xr, yl);
		SetVertex(&VertexBuffer[2 * VertexSize], presentArea.Right(),	presentArea.Bottom(),	1.0f, 1.0f, 1.0f, 1.0f, xr, yr);
		SetVertex(&VertexBuffer[3 * VertexSize], presentArea.X,			presentArea.Bottom(),	1.0f, 1.0f, 1.0f, 1.0f, xl, yr);

		glDrawArrays(GL_QUADS, 0, 4); glSplat();
	}

	//Exit present state
	ExitPresentState();
}
开发者ID:kozarovv,项目名称:mednafen-ps3,代码行数:53,代码来源:ESVideo.cpp

示例8: Present

void CApp::RenderWorld()
{
	if( m_pCamera )
	{
		m_pCamera->BeginRender();
		m_pCamera->ClearToSceneColor();
		m_pCamera->RenderPass( -1 );
		m_pCamera->EndRender();
		
		Present( m_pCamera->pGetRenderTarget() );
	}
}
开发者ID:stephanreiter,项目名称:muli3d,代码行数:12,代码来源:app.cpp

示例9: RunPhysics

void hhControlHand::ClientPredictionThink( void ) {
	RunPhysics();
	
	// HUMANHEAD pdm
	if (thinkFlags & TH_TICKER) {
		Ticker();
	}

	UpdateAnimation();
	UpdateVisuals();
	Present();
}
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:12,代码来源:game_handcontrol.cpp

示例10: Run

/*
================
idEntityFx::Think

  Clears any visual fx started when {item,mob,player} was spawned
================
*/
void idEntityFx::Think( void ) {
	if ( g_skipFX.GetBool() ) {
		return;
	}

	if ( thinkFlags & TH_THINK ) {
		Run( gameLocal.time );
	}

	RunPhysics();
	Present();
}
开发者ID:Salamek,项目名称:Shadow-of-Dust,代码行数:19,代码来源:Fx.cpp

示例11: RunPhysics

/*
================
idMoveableItem::Think
================
*/
void idMoveableItem::Think( void ) {
	RunPhysics();

	if ( thinkFlags & TH_PHYSICS ) {
		// update trigger position
		trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), mat3_identity );
	}

// ---> sikk - Moveable Item Spinning
	if ( thinkFlags & TH_THINK ) {
		if ( spawnArgs.GetBool( "spin" ) || spawnArgs.GetBool( "fixedAxis" ) ) {
			idMat3 axis;
			axis.Identity();
			GetPhysics()->SetAngularVelocity( vec3_zero );
			GetPhysics()->SetAxis( axis );

			if ( spawnArgs.GetBool( "spin" ) ) {
				idAngles	ang;
				idVec3		org;

				// item rotation
				ang.pitch = ang.roll = 0.0f;
				ang.yaw = ( gameLocal.time & 4095 ) * 360.0f / -4096.0f;
				renderEntity.axis = ang.ToMat3();

				// item bobbing
				float scale = 0.005f;
				org = GetPhysics()->GetOrigin();
				org.z += 4.0f + cos( ( gameLocal.time * scale + entityNumber ) ) * 4.0f;
				renderEntity.origin = org;
			}
		}
	}
// <--- sikk - Moveable Item Spinning

	if ( thinkFlags & TH_UPDATEPARTICLES ) {
		if ( !gameLocal.smokeParticles->EmitSmoke( smoke, smokeTime, gameLocal.random.CRandomFloat(), GetPhysics()->GetOrigin(), GetPhysics()->GetAxis() ) ) {
// ---> sikk - continuous smoke particles (for gibs)
			if ( repeatSmoke && GetPhysics()->GetLinearVelocity().Length() > 100.0f ) {
				smokeTime = gameLocal.time;
			} else {
				smokeTime = 0;
				BecomeInactive( TH_UPDATEPARTICLES );
			}
// <--- sikk - continuous smoke particles (for gibs)

		}
	}

	Present();
}
开发者ID:RobertBeckebans,项目名称:Sikkpin-Breadcrumps-src,代码行数:56,代码来源:Item.cpp

示例12: RunPhysics

void idActor::Think( void ) {

	if ( thinkFlags & TH_THINK ) {

		// clear the ik before we do anything else so the skeleton doesn't get updated twice
		walkIK.ClearJointMods();

		RunPhysics();
		
	}

	UpdateAnimation();
	Present();		
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:14,代码来源:MD5Actor.cpp

示例13: SetResourceBarrier

//-------------------------------------------------------------------------------------------------
//      フレーム描画処理です.
//-------------------------------------------------------------------------------------------------
void App::OnFrameRender()
{
    // ビューポートを設定.
    m_CmdList->RSSetViewports( 1, &m_Viewport );
    SetResourceBarrier( m_CmdList.GetPtr(), m_ColorTarget.GetPtr(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET);

    // カラーバッファをクリア.
    float clearColor[] = { 0.39f, 0.58f, 0.92f, 1.0f };
    m_CmdList->ClearRenderTargetView( m_ColorTargetHandle, clearColor, 0, nullptr );
    SetResourceBarrier( m_CmdList.GetPtr(), m_ColorTarget.GetPtr(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT);

    // 画面に表示.
    Present( 0 );
}
开发者ID:tatsuya-ogawa,项目名称:D3D12_Simple,代码行数:17,代码来源:App.cpp

示例14: D3DPERF_BeginEvent

// Call the user's Render() callback (if it exists)
//-----------------------------------------------------------------------------
void CPUT_DX11::InnerExecutionLoop()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT User's Render() ");
#endif
    if(!mbShutdown)
    {
		if( mpSwapChain )
		{
			double deltaSeconds = mpTimer->GetElapsedTime();
			Update(deltaSeconds);
			Present(); // Note: Presenting immediately before Rendering minimizes CPU stalls (i.e., execute Update() before Present() stalls)

			double totalSeconds = mpTimer->GetTotalTime();
			SetPerFrameConstantBuffer(totalSeconds);
			CPUTMaterialDX11::ResetStateTracking();
			Render(deltaSeconds);
		}
        if(!CPUTOSServices::GetOSServices()->DoesWindowHaveFocus())
        {
            Sleep(100);
        }
    }
    else
    {
#ifndef _DEBUG
        exit(0);
#endif
        Present(); // Need to present, or will leak all references held by previous Render()!
        ShutdownAndDestroy();
    }

#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_EndEvent();
#endif
}
开发者ID:Clever-Boy,项目名称:OutdoorLightScattering,代码行数:38,代码来源:CPUT_DX11.cpp

示例15: CheckSizeChanged

bool DiD3D9WindowTarget::SwapBuffer()
{
    bool resized = CheckSizeChanged();
    HRESULT hr = Present();

    if (D3DERR_DEVICELOST == hr || resized)
        return false;
    else
    {
        if (FAILED(hr))
        {
            DI_ERROR("Swaping buffer failed!");
        }
        return true;
    }
}
开发者ID:zxy2845986,项目名称:Demi3D,代码行数:16,代码来源:D3D9WindowTarget.cpp


注:本文中的Present函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。