Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CAPI_DistortionRenderer.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : CAPI_DistortionRenderer.h
4 Content : Abstract interface for platform-specific rendering of distortion
5 Created : February 2, 2014
6 Authors : Michael Antonov
7 
8 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 
10 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
14 
15 You may obtain a copy of the License at
16 
17 http://www.oculusvr.com/licenses/LICENSE-3.1
18 
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24 
25 ************************************************************************************/
26 
27 #ifndef OVR_CAPI_DistortionRenderer_h
28 #define OVR_CAPI_DistortionRenderer_h
29 
30 #include "CAPI_HMDRenderState.h"
31 #include "CAPI_FrameTimeManager.h"
32 
33 
34 namespace OVR { namespace CAPI {
35 
36 //-------------------------------------------------------------------------------------
37 // ***** CAPI::DistortionRenderer
38 
39 // DistortionRenderer implements rendering of distortion and other overlay elements
40 // in platform-independent way.
41 // Platform-specific renderer back ends for CAPI are derived from this class.
42 
43 class DistortionRenderer : public RefCountBase<DistortionRenderer>
44 {
45  // Quiet assignment compiler warning.
47 public:
48 
50  FrameTimeManager& timeManager,
51  const HMDRenderState& renderState)
52  : RenderAPI(api), HMD(hmd), TimeManager(timeManager), RState(renderState)
53  { }
55  { }
56 
57 
58  // Configures the Renderer based on externally passed API settings. Must be
59  // called before use.
60  // Under D3D, apiConfig includes D3D Device pointer, back buffer and other
61  // needed structures.
62  virtual bool Initialize(const ovrRenderAPIConfig* apiConfig,
63  unsigned distortionCaps) = 0;
64 
65  // Submits one eye texture for rendering. This is in the separate method to
66  // allow "submit as you render" scenarios on horizontal screens where one
67  // eye can be scanned out before the other.
68  virtual void SubmitEye(int eyeId, ovrTexture* eyeTexture) = 0;
69 
70  // Finish the frame, optionally swapping buffers.
71  // Many implementations may actually apply the distortion here.
72  virtual void EndFrame(bool swapBuffers, unsigned char* latencyTesterDrawColor,
73  unsigned char* latencyTester2DrawColor) = 0;
74 
75  // Stores the current graphics pipeline state so it can be restored later.
77 
78  // Restores the saved graphics pipeline state.
80 
81  // *** Creation Factory logic
82 
84 
85  // Creation function for this interface, registered for API.
86  typedef DistortionRenderer* (*CreateFunc)(ovrHmd hmd,
87  FrameTimeManager &timeManager,
88  const HMDRenderState& renderState);
89 
91 
92 protected:
93 
94  class GraphicsState : public RefCountBase<GraphicsState>
95  {
96  public:
97  GraphicsState() : IsValid(false) {}
98  virtual ~GraphicsState() {}
99  virtual void Save() = 0;
100  virtual void Restore() = 0;
101 
102  protected:
103  bool IsValid;
104  };
105 
107  const ovrHmd HMD;
111 };
112 
113 }} // namespace OVR::CAPI
114 
115 
116 #endif // OVR_CAPI_DistortionRenderer_h
117 
118 
void operator=(const DistortionRenderer &)
virtual void SubmitEye(int eyeId, ovrTexture *eyeTexture)=0
DistortionRenderer(ovrRenderAPIType api, ovrHmd hmd, FrameTimeManager &timeManager, const HMDRenderState &renderState)
virtual bool Initialize(const ovrRenderAPIConfig *apiConfig, unsigned distortionCaps)=0
virtual void EndFrame(bool swapBuffers, unsigned char *latencyTesterDrawColor, unsigned char *latencyTester2DrawColor)=0
ovrRenderAPIType
Definition: OVR_CAPI.h:341
DistortionRenderer *(* CreateFunc)(ovrHmd hmd, FrameTimeManager &timeManager, const HMDRenderState &renderState)
ovrRenderAPIType GetRenderAPI() const
static CreateFunc APICreateRegistry[ovrRenderAPI_Count]