本文整理汇总了C++中Timer::DeltaSecondsF方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::DeltaSecondsF方法的具体用法?C++ Timer::DeltaSecondsF怎么用?C++ Timer::DeltaSecondsF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::DeltaSecondsF方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void ShadowsApp::Render(const Timer& timer)
{
ID3D11DeviceContextPtr context = deviceManager.ImmediateContext();
AppSettings::UpdateCBuffer(context);
RenderMainPass();
if(colorTarget.MultiSamples > 1)
context->ResolveSubresource(resolveTarget.Texture, 0, colorTarget.Texture, 0, colorTarget.Format);
// Kick off post-processing
D3DPERF_BeginEvent(0xFFFFFFFF, L"Post Processing");
PostProcessor::Constants constants;
constants.BloomThreshold = AppSettings::BloomThreshold;
constants.BloomMagnitude = AppSettings::BloomMagnitude;
constants.BloomBlurSigma = AppSettings::BloomBlurSigma;
constants.Tau = AppSettings::AdaptationRate;
constants.KeyValue = AppSettings::KeyValue;
constants.TimeDelta = timer.DeltaSecondsF();
postProcessor.SetConstants(constants);
postProcessor.Render(context, resolveTarget.SRView, deviceManager.BackBuffer());
D3DPERF_EndEvent();
// postProcessor.DrawDepthBuffer(depthBuffer, deviceManager.BackBuffer());
ID3D11RenderTargetView* renderTargets[1] = { deviceManager.BackBuffer() };
context->OMSetRenderTargets(1, renderTargets, NULL);
D3D11_VIEWPORT vp;
vp.Width = static_cast<float>(deviceManager.BackBufferWidth());
vp.Height = static_cast<float>(deviceManager.BackBufferHeight());
vp.TopLeftX = 0;
vp.TopLeftY = 0;
vp.MinDepth = 0;
vp.MaxDepth = 1;
context->RSSetViewports(1, &vp);
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/*spriteRenderer.Begin(context, SpriteRenderer::Linear);
ID3D11ShaderResourceView* srv = meshRenderer.ShadowMap().SRView;
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srv->GetDesc(&srvDesc);
srvDesc.Texture2DArray.ArraySize = 1;
ID3D11ShaderResourceViewPtr newSrv;
deviceManager.Device()->CreateShaderResourceView(meshRenderer.ShadowMap().Texture, &srvDesc, &newSrv);
spriteRenderer.Render(newSrv, Float4x4());
spriteRenderer.End();*/
RenderHUD();
}
示例2: Render
void MSAAFilter::Render(const Timer& timer)
{
if(AppSettings::MSAAMode.Changed())
CreateRenderTargets();
ID3D11DeviceContextPtr context = deviceManager.ImmediateContext();
AppSettings::UpdateCBuffer(context);
RenderScene();
RenderBackgroundVelocity();
RenderAA();
{
// Kick off post-processing
PIXEvent pixEvent(L"Post Processing");
postProcessor.Render(context, resolveTarget.SRView, deviceManager.BackBuffer(), timer.DeltaSecondsF());
}
ID3D11RenderTargetView* renderTargets[1] = { deviceManager.BackBuffer() };
context->OMSetRenderTargets(1, renderTargets, NULL);
SetViewport(context, deviceManager.BackBufferWidth(), deviceManager.BackBufferHeight());
RenderHUD();
++frameCount;
}
示例3: Update
void MSAAFilter::Update(const Timer& timer)
{
AppSettings::UpdateUI();
MouseState mouseState = MouseState::GetMouseState(window);
KeyboardState kbState = KeyboardState::GetKeyboardState(window);
if(kbState.IsKeyDown(KeyboardState::Escape))
window.Destroy();
float CamMoveSpeed = 5.0f * timer.DeltaSecondsF();
const float CamRotSpeed = 0.180f * timer.DeltaSecondsF();
const float MeshRotSpeed = 0.180f * timer.DeltaSecondsF();
// Move the camera with keyboard input
if(kbState.IsKeyDown(KeyboardState::LeftShift))
CamMoveSpeed *= 0.25f;
Float3 camPos = camera.Position();
if(kbState.IsKeyDown(KeyboardState::W))
camPos += camera.Forward() * CamMoveSpeed;
else if (kbState.IsKeyDown(KeyboardState::S))
camPos += camera.Back() * CamMoveSpeed;
if(kbState.IsKeyDown(KeyboardState::A))
camPos += camera.Left() * CamMoveSpeed;
else if (kbState.IsKeyDown(KeyboardState::D))
camPos += camera.Right() * CamMoveSpeed;
if(kbState.IsKeyDown(KeyboardState::Q))
camPos += camera.Up() * CamMoveSpeed;
else if (kbState.IsKeyDown(KeyboardState::E))
camPos += camera.Down() * CamMoveSpeed;
camera.SetPosition(camPos);
// Rotate the camera with the mouse
if(mouseState.RButton.Pressed && mouseState.IsOverWindow)
{
float xRot = camera.XRotation();
float yRot = camera.YRotation();
xRot += mouseState.DY * CamRotSpeed;
yRot += mouseState.DX * CamRotSpeed;
camera.SetXRotation(xRot);
camera.SetYRotation(yRot);
}
// Reset the camera projection
camera.SetAspectRatio(camera.AspectRatio());
Float2 jitter = 0.0f;
if(AppSettings::EnableTemporalAA && AppSettings::EnableJitter() && AppSettings::UseStandardResolve == false)
{
if(AppSettings::JitterMode == JitterModes::Uniform2x)
{
jitter = frameCount % 2 == 0 ? -0.5f : 0.5f;
}
else if(AppSettings::JitterMode == JitterModes::Hammersley4x)
{
uint64 idx = frameCount % 4;
jitter = Hammersley2D(idx, 4) * 2.0f - Float2(1.0f);
}
else if(AppSettings::JitterMode == JitterModes::Hammersley8x)
{
uint64 idx = frameCount % 8;
jitter = Hammersley2D(idx, 8) * 2.0f - Float2(1.0f);
}
else if(AppSettings::JitterMode == JitterModes::Hammersley16x)
{
uint64 idx = frameCount % 16;
jitter = Hammersley2D(idx, 16) * 2.0f - Float2(1.0f);
}
jitter *= AppSettings::JitterScale;
const float offsetX = jitter.x * (1.0f / colorTarget.Width);
const float offsetY = jitter.y * (1.0f / colorTarget.Height);
Float4x4 offsetMatrix = Float4x4::TranslationMatrix(Float3(offsetX, -offsetY, 0.0f));
camera.SetProjection(camera.ProjectionMatrix() * offsetMatrix);
}
jitterOffset = (jitter - prevJitter) * 0.5f;
prevJitter = jitter;
// Toggle VSYNC
if(kbState.RisingEdge(KeyboardState::V))
deviceManager.SetVSYNCEnabled(!deviceManager.VSYNCEnabled());
deviceManager.SetNumVSYNCIntervals(AppSettings::DoubleSyncInterval ? 2 : 1);
if(AppSettings::CurrentScene.Changed())
{
meshRenderer.SetModel(&models[AppSettings::CurrentScene]);
AppSettings::ModelOrientation.SetValue(modelOrientations[AppSettings::CurrentScene]);
}
Quaternion orientation = AppSettings::ModelOrientation;
orientation = orientation * Quaternion::FromAxisAngle(Float3(0.0f, 1.0f, 0.0f), AppSettings::ModelRotationSpeed * timer.DeltaSecondsF());
AppSettings::ModelOrientation.SetValue(orientation);
modelTransform = orientation.ToFloat4x4() * Float4x4::ScaleMatrix(ModelScales[AppSettings::CurrentScene]);
modelTransform.SetTranslation(ModelPositions[AppSettings::CurrentScene]);
}
示例4: Update
void ShadowsApp::Update(const Timer& timer)
{
MouseState mouseState = MouseState::GetMouseState(window);
KeyboardState kbState = KeyboardState::GetKeyboardState(window);
if (kbState.IsKeyDown(KeyboardState::Escape))
window.Destroy();
float CamMoveSpeed = 5.0f * timer.DeltaSecondsF();
const float CamRotSpeed = 0.180f * timer.DeltaSecondsF();
const float MeshRotSpeed = 0.180f * timer.DeltaSecondsF();
// Move the camera with keyboard input
if (kbState.IsKeyDown(KeyboardState::LeftShift))
CamMoveSpeed *= 0.25f;
Float3 camPos = camera.Position();
if (kbState.IsKeyDown(KeyboardState::W))
camPos += camera.Forward() * CamMoveSpeed;
else if (kbState.IsKeyDown(KeyboardState::S))
camPos += camera.Back() * CamMoveSpeed;
if (kbState.IsKeyDown(KeyboardState::A))
camPos += camera.Left() * CamMoveSpeed;
else if (kbState.IsKeyDown(KeyboardState::D))
camPos += camera.Right() * CamMoveSpeed;
if (kbState.IsKeyDown(KeyboardState::Q))
camPos += camera.Up() * CamMoveSpeed;
else if (kbState.IsKeyDown(KeyboardState::E))
camPos += camera.Down() * CamMoveSpeed;
camera.SetPosition(camPos);
// Rotate the camera with the mouse
if(mouseState.RButton.Pressed && mouseState.IsOverWindow)
{
float xRot = camera.XRotation();
float yRot = camera.YRotation();
xRot += mouseState.DY * CamRotSpeed;
yRot += mouseState.DX * CamRotSpeed;
camera.SetXRotation(xRot);
camera.SetYRotation(yRot);
}
if(AppSettings::AnimateLight)
{
float rotY = XMScalarModAngle(timer.DeltaSecondsF() * 0.25f);
Quaternion rotation = Quaternion::FromAxisAngle(Float3(0.0f, 1.0f, 0.0f), rotY);
Float3 lightDir = AppSettings::LightDirection;
lightDir = Float3::Transform(lightDir, rotation);
AppSettings::LightDirection.SetValue(lightDir);
}
// Toggle VSYNC
if(kbState.RisingEdge(KeyboardState::V))
deviceManager.SetVSYNCEnabled(!deviceManager.VSYNCEnabled());
if(AppSettings::CurrentScene.Changed())
{
float scale = MeshScales[AppSettings::CurrentScene];
meshRenderer.SetSceneMesh(deviceManager.ImmediateContext(), &models[AppSettings::CurrentScene],
XMMatrixScaling(scale, scale, scale));
}
AppSettings::Update();
meshRenderer.Update();
}