Free Electron
HydraDriver.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 
24 // originally from pxr/imaging/lib/hd/unitTestHelper.h
25 // adapted for Free Electron
26 
27 #ifndef __usd_HydraDriver_h__
28 #define __usd_HydraDriver_h__
29 
30 #include "pxr/imaging/hd/engine.h"
31 //#include "pxr/imaging/hd/lightingShader.h"
32 #include "pxr/imaging/hd/renderPass.h"
33 #include "pxr/imaging/hd/renderPassState.h"
34 #include "pxr/imaging/hio/glslfx.h"
35 
36 #include "pxr/base/gf/vec4d.h"
37 #include "pxr/base/gf/matrix4d.h"
38 
39 #include <vector>
40 #include <boost/scoped_ptr.hpp>
41 
42 /// \class HydraDriver
43 ///
44 /// A unit test driver that exercises the core engine.
45 ///
46 /// \note This test driver does NOT assume OpenGL is available; in the event
47 /// that is is not available, all OpenGL calls become no-ops,
48 /// but all other work is performed as usual.
50 {
51  public:
52  HydraDriver(void);
53  HydraDriver(TfToken const &reprName);
54  ~HydraDriver(void);
55 
56  void Draw(HdEngine& a_rEngine,bool withGuides=false);
57  void Draw(HdEngine& a_rEngine,
58  HdRenderPassSharedPtr const &renderPass);
59 
60  /// Set camera to renderpass
61  void SetCamera(GfMatrix4d const &modelViewMatrix,
62  GfMatrix4d const &projectionMatrix,
63  GfVec4d const &viewport);
64 
65  HdRenderPassSharedPtr const& GetRenderPass(bool withGuides=false);
66 
67  HdRenderPassStateSharedPtr const& GetRenderPassState(void) const
68  { return m_renderPassState; }
69 
70  HydraDelegate& GetDelegate(void)
71  { return *m_pSceneDelegate; }
72 
73  void SetRepr(TfToken const &reprName);
74 
75  private:
76 
77  class NullRenderPass: public HdRenderPass
78  {
79  public:
80  NullRenderPass(HdRenderIndex *index,
81  HdRprimCollection const &collection):
82  HdRenderPass(index, collection) {}
83  virtual ~NullRenderPass(void) {}
84 
85 #if HD_API_VERSION>=31
86  void _Execute(HdRenderPassStateSharedPtr const &renderPassState,
87  TfTokenVector const &renderTags) override {}
88 #endif
89  };
90 
91  void _Init(TfToken const &reprName);
92 
93  HdStRenderDelegate m_renderDelegate;
94  HdRenderIndex* m_pRenderIndex;
95  HydraDelegate* m_pSceneDelegate;
96  TfToken m_reprName;
97  HdRenderPassSharedPtr m_geomPass;
98  HdRenderPassSharedPtr m_geomAndGuidePass;
99  HdRenderPassStateSharedPtr m_renderPassState;
100 
101  std::unique_ptr<class Hgi> m_hgi;
102  HdDriver m_hgiDriver;
103 };
104 
105 #endif // __usd_HydraDriver_h__
A simple delegate class for unit test driver.
Definition: HydraDelegate.h:51
A unit test driver that exercises the core engine.
Definition: HydraDriver.h:49
void SetCamera(GfMatrix4d const &modelViewMatrix, GfMatrix4d const &projectionMatrix, GfVec4d const &viewport)
Set camera to renderpass.
Definition: HydraDriver.cc:178