text: #pragma once
  
  #include <OVR_CAPI.h>
  #include <openvr.h>
  #include <vector>
  
  class CompositorBase
  {
  public:
  	CompositorBase();
  	virtual ~CompositorBase();
  
  	virtual vr::EGraphicsAPIConvention GetAPI() = 0;
  
  	// Texture Swapchain
  	virtual ovrResult CreateTextureSwapChain(const ovrTextureSwapChainDesc* desc, ovrTextureSwapChain* out_TextureSwapChain) = 0;
  	virtual void RenderTextureSwapChain(vr::EVREye eye, ovrTextureSwapChain swapChain, ovrTextureSwapChain sceneChain, ovrRecti viewport, vr::VRTextureBounds_t bounds, vr::HmdVector4_t quad) = 0;
  
  	// Mirror Texture
  	virtual ovrResult CreateMirrorTexture(const ovrMirrorTextureDesc* desc, ovrMirrorTexture* out_MirrorTexture) = 0;
  	virtual void RenderMirrorTexture(ovrMirrorTexture mirrorTexture, ovrTextureSwapChain swapChain[ovrEye_Count]) = 0;
  
  	void SetMirrorTexture(ovrMirrorTexture mirrorTexture);
  	vr::EVRCompositorError SubmitFrame(ovrLayerHeader const * const * layerPtrList, unsigned int layerCount);
  
  protected:
  	const ovrLayerHeader* m_SceneLayer;
  	ovrMirrorTexture m_MirrorTexture;
  
  	vr::VROverlayHandle_t CreateOverlay();
  	vr::VRTextureBounds_t ViewportToTextureBounds(ovrRecti viewport, ovrTextureSwapChain swapChain, unsigned int flags);
  	ovrFovPort MatrixToFovPort(ovrMatrix4f matrix);
  
  	void SubmitFovLayer(ovrRecti viewport[ovrEye_Count], ovrFovPort fov[ovrEye_Count], ovrTextureSwapChain swapChain[ovrEye_Count], unsigned int flags);
  	vr::VRCompositorError SubmitSceneLayer(ovrRecti viewport[ovrEye_Count], ovrFovPort fov[ovrEye_Count], ovrTextureSwapChain swapChain[ovrEye_Count], unsigned int flags);
  
  private:
  	// Overlays
  	unsigned int m_OverlayCount;
  	std::vector<vr::VROverlayHandle_t> m_ActiveOverlays;
  };
  