我正在尝试使用SpatialSurfaceObserver类用于Windows。我在跟踪这个:directx
然而,我遇到了一个路障。示例声明我应该创建一个类似于这样的实例: m_surfaceObserver = ref新的SpatialSurfaceObserver();
但是,我使用的是纯C++,没有C#,没有C++/CX等等。到目前为止,这是没有问题的,我希望使用一个激活工厂来创建一个实例,但据我所知,这个类的一个不包含任何函数来创建一个实例。
基本上我想用这个:
using namespace ABI::Windows::Perception::Spatial;
ComPtr<Surfaces::ISpatialSurfaceObserverStatics> observerFactory;
ABI::Windows::Foundation::GetActivationFactory(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observerFactory);
observerFactory->someCreatorFunction(...);但我没有什么功能可以用。
然后我找到了ActivateInstance,并认为这应该是可行的:
ComPtr<Surfaces::ISpatialSurfaceObserver> observer;
ABI::Windows::Foundation::ActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);但是这也不能编译,它总是抱怨ISpatialSurfaceObserver不包含"InterfaceType“成员。
我还遇到了"Make“和"MakeAndActivate",但并不真正理解如何使用它们,以及它们是否适合我的情况。
知道我错过了什么吗?
发布于 2017-07-23 20:25:32
这里没有任何专业知识,只有一个想法可以尝试。
ABI::Windows::Foundation::ActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(),&观察者);
你能给我打个电话吗
::RoActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);一些可能有用的参考资料:
https://stackoverflow.com/questions/45268836
复制相似问题