2021-10-05 00:17:24 +13:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Common\StepTimer.h"
|
|
|
|
|
#include "Common\DeviceResources.h"
|
|
|
|
|
#include "Content\Sample3DSceneRenderer.h"
|
|
|
|
|
#include "Content\SampleFpsTextRenderer.h"
|
|
|
|
|
|
|
|
|
|
// Renders Direct2D and 3D content on the screen.
|
2021-10-05 00:27:45 +13:00
|
|
|
|
namespace CameraRenderer_cpp
|
2021-10-05 00:17:24 +13:00
|
|
|
|
{
|
2021-10-05 00:27:45 +13:00
|
|
|
|
class CameraRenderer_cppMain : public DX::IDeviceNotify
|
2021-10-05 00:17:24 +13:00
|
|
|
|
{
|
|
|
|
|
public:
|
2021-10-05 00:27:45 +13:00
|
|
|
|
CameraRenderer_cppMain(const std::shared_ptr<DX::DeviceResources>& deviceResources);
|
|
|
|
|
~CameraRenderer_cppMain();
|
2021-10-05 00:17:24 +13:00
|
|
|
|
void CreateWindowSizeDependentResources();
|
|
|
|
|
void StartTracking() { m_sceneRenderer->StartTracking(); }
|
|
|
|
|
void TrackingUpdate(float positionX) { m_pointerLocationX = positionX; }
|
|
|
|
|
void StopTracking() { m_sceneRenderer->StopTracking(); }
|
|
|
|
|
bool IsTracking() { return m_sceneRenderer->IsTracking(); }
|
|
|
|
|
void StartRenderLoop();
|
|
|
|
|
void StopRenderLoop();
|
|
|
|
|
Concurrency::critical_section& GetCriticalSection() { return m_criticalSection; }
|
|
|
|
|
|
|
|
|
|
// IDeviceNotify
|
|
|
|
|
virtual void OnDeviceLost();
|
|
|
|
|
virtual void OnDeviceRestored();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void ProcessInput();
|
|
|
|
|
void Update();
|
|
|
|
|
bool Render();
|
|
|
|
|
|
|
|
|
|
// Cached pointer to device resources.
|
|
|
|
|
std::shared_ptr<DX::DeviceResources> m_deviceResources;
|
|
|
|
|
|
|
|
|
|
// TODO: Replace with your own content renderers.
|
|
|
|
|
std::unique_ptr<Sample3DSceneRenderer> m_sceneRenderer;
|
|
|
|
|
std::unique_ptr<SampleFpsTextRenderer> m_fpsTextRenderer;
|
|
|
|
|
|
|
|
|
|
Windows::Foundation::IAsyncAction^ m_renderLoopWorker;
|
|
|
|
|
Concurrency::critical_section m_criticalSection;
|
|
|
|
|
|
|
|
|
|
// Rendering loop timer.
|
|
|
|
|
DX::StepTimer m_timer;
|
|
|
|
|
|
|
|
|
|
// Track current input pointer position.
|
|
|
|
|
float m_pointerLocationX;
|
|
|
|
|
};
|
|
|
|
|
}
|