을 증가시키지 않고, 문제를 재현하는 값을 생성, 나는 다음 단계로 좁혀 :StepTimer.GetTotalSeconds()는 항상 내가 단순화하기 위해 다이렉트 X 11을 사용하고
- "새 만들기 DirectX 및 XAML 응용 프로그램 (UWP) "Visual Studio (VS 2017 사용하고 있습니다).
다음 코드로 Sample3DSceneRenderer :: 업데이트 방법 교체 :
inline void DebugTrace(const wchar_t *format, ...) { // Generate the message string. va_list args; va_start(args, format); // initialize the argument list wchar_t buffer[1024]; va_end(args); OutputDebugStringW(buffer); // this is a Windows function }
내가 실행
void Sample3DSceneRenderer::Update(DX::StepTimer const& timer)
{
if (!m_tracking)
{
double total = timer.GetTotalSeconds();
// Convert degrees to radians, then convert seconds to rotation angle
float radiansPerSecond = XMConvertToRadians(m_degreesPerSecond);
double totalRotation = total * radiansPerSecond;
float radians = static_cast<float>(fmod(totalRotation, XM_2PI));
DX::DebugTrace(L"num = %4.2f\t%4.2f\n", radians, total);
Rotate(radians);
}
}
를 출력 창에 값을 추적하기 위해 다음과 같은 기능을 추가 출력 창에 다음 값이 표시됩니다.
num = 0.01 0.01
num = 0.02 0.02
num = 0.00 0.00 // decreased
num = 0.00 0.01 // decreased
num = 0.03 0.04
num = 0.05 0.06
num = 0.02 0.02 // decreased
num = 0.06 0.07
num = 0.03 0.04 // decreased
num = 0.07 0.09
num = 0.04 0.06 // decreased
num = 0.08 0.11
num = 0.06 0.07 // decreased
num = 0.10 0.12
num = 0.07 0.09 // decreased
num = 0.11 0.14
num = 0.08 0.11 // decreased
num = 0.12 0.16
num = 0.10 0.12 // decreased
num = 0.11 0.14
num = 0.14 0.17
num = 0.12 0.16 // decreased
num = 0.15 0.19
num = 0.16 0.21
num = 0.14 0.17 // decreased
num = 0.18 0.22
num = 0.15 0.19 // decreased
num = 0.16 0.21
num = 0.19 0.24
num = 0.20 0.26
num = 0.18 0.22 // decreased
etc.
질문 : 왜 TotalSeconds 값이 증가했다가 감소하고 다시 증가합니까? 예 : 0.01, 0.02, 0.00, 0.01. 그들은 항상 증가해서는 안됩니까?
본인은이 문제를 조사했는데 그것은 DirectXPage 생성자가 두 번 호출 된 것으로 밝혀졌다 : 한 번 프레임 워크 (ActivateInstance 방법)에 의해 응용 프로그램 자체 (통화 m_directXPage = 심판 새로운 DirectXPage에 의해 다른 시간 ()을 App.xaml.cpp에 추가합니다. 질문은 여전히 남아 있습니다. XAML 페이지가 두 번 인스턴스화되는 이유는 무엇입니까? 그게 버그 야? – ata6502
설명 : 페이지가 두 번 인스턴스화 되었기 때문에 Update 메서드가 두 번 호출되므로 두 개의 타이머가 동시에 작동합니다. 내게 버그 같아 보이지? – ata6502