本文介绍了[UWP] [C ++] C ++ DirectX11的新模板& XAML项目有2个渲染线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


似乎新创建的C ++中有2个 DirectXPage实例
DirectX11 & XAML项目。 (最新VS2017)

Seems there are 2 DirectXPage instances in new created C++DirectX11 & XAML project. (latest VS2017)

void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
{
#if _DEBUG
 if (IsDebuggerPresent())
 {
  DebugSettings->EnableFrameRateCounter = true;
 }
#endif
 if (m_directXPage == nullptr)
 {
  m_directXPage = ref new DirectXPage();   <-- ********** FIRST ONE *******
 }
 if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
 {
  m_directXPage->LoadInternalState(ApplicationData::Current->LocalSettings->Values);
 }
 auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
 // Do not repeat app initialization when the Window already has content,
 // just ensure that the window is active
 if (rootFrame == nullptr)
 {
  // Create a Frame to act as the navigation context and associate it with
  // a SuspensionManager key
  rootFrame = ref new Frame();
  rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
  if (rootFrame->Content == nullptr)
  {
   // When the navigation stack isn't restored navigate to the first page,
   // configuring the new page by passing required information as a navigation
   // parameter
   rootFrame->Navigate(TypeName(DirectXPage::typeid), e->Arguments);  <-- ******** SECOND ONE ? *******
  }
  // Place the frame in the current Window
  Window::Current->Content = rootFrame;
  // Ensure the current window is active
  Window::Current->Activate();
 }
 else
 {
  if (rootFrame->Content == nullptr)
  {
   // When the navigation stack isn't restored navigate to the first page,
   // configuring the new page by passing required information as a navigation
   // parameter
   rootFrame->Navigate(TypeName(DirectXPage::typeid), e->Arguments);
  }
  // Ensure the current window is active
  Window::Current->Activate();
 }
}

  rootFrame->导航(TypeName(DirectXPage) :: typeid),e->参数); //
这应该使用 m_directXPage?

 rootFrame->Navigate(TypeName(DirectXPage::typeid), e->Arguments); //Should this use m_directXPage?

推荐答案

这里的m_directXPage变量是错误的,因为它仅用于管理生命周期逻辑。它可能应该在可能的多页模板中静态而不是每页处理。感谢您指出了这一点。我会提交一个错误。在未来
,您可以通过Visual Studio反馈菜单(帮助。发送反馈)自行完成。

The m_directXPage variable here is wrong as it gets used only to manage the lifecycle logic. It probably should be handling that statically rather than per-page in a potentially multi-page template. Thanks for pointing this out. I'll file a bug. In the future you can do so yourself though the Visual Studio feedback menu (Help.Send Feedback).


这篇关于[UWP] [C ++] C ++ DirectX11的新模板&amp; XAML项目有2个渲染线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 23:44