HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unitTestHelper.h
Go to the documentation of this file.
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 #ifndef PXR_IMAGING_HD_UNIT_TEST_HELPER_H
25 #define PXR_IMAGING_HD_UNIT_TEST_HELPER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/engine.h"
34 
35 #include "pxr/base/gf/vec4d.h"
36 #include "pxr/base/gf/matrix4d.h"
37 
38 #include <vector>
39 
41 
42 
43 /// \class Hd_TestDriver
44 ///
45 /// A unit test driver that exercises the core engine.
46 ///
47 /// \note This test driver does NOT assume OpenGL is available; in the even
48 /// that is is not available, all OpenGL calls become no-ops, but all other work
49 /// is performed as usual.
50 ///
51 class Hd_TestDriver final
52 {
53 public:
54  HD_API
55  Hd_TestDriver();
56  HD_API
57  Hd_TestDriver(HdReprSelector const &reprToken);
58  HD_API
60 
61  /// Draw
62  HD_API
63  void Draw(bool withGuides=false);
64 
65  /// Draw with external renderPass
66  HD_API
67  void Draw(HdRenderPassSharedPtr const &renderPass, bool withGuides);
68 
69  /// Set camera to renderpass
70  HD_API
71  void SetCamera(GfMatrix4d const &viewMatrix,
72  GfMatrix4d const &projectionMatrix,
73  CameraUtilFraming const &framing);
74 
75  /// Set cull style
76  HD_API
77  void SetCullStyle(HdCullStyle cullStyle);
78 
79  /// Returns the renderpass
80  HD_API
82 
83  /// Returns the renderPassState
85  return _renderPassState;
86  }
87 
88  /// Returns the UnitTest delegate
89  HdUnitTestDelegate& GetDelegate() { return *_sceneDelegate; }
90 
91  /// Switch repr
92  HD_API
93  void SetRepr(HdReprSelector const &reprSelector);
94 
95 private:
96 
97  void _Init(HdReprSelector const &reprSelector);
98 
99  HdEngine _engine;
100  Hd_UnitTestNullRenderDelegate _renderDelegate;
101  HdRenderIndex *_renderIndex;
102  HdUnitTestDelegate *_sceneDelegate;
103  SdfPath _cameraId;
104  HdRenderPassSharedPtr _renderPass;
105  HdRenderPassStateSharedPtr _renderPassState;
106  HdRprimCollection _collection;
107 };
108 
110 
111 #endif // PXR_IMAGING_HD_UNIT_TEST_HELPER_H
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:42
HdCullStyle
Definition: enums.h:122
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:41
HD_API void SetCamera(GfMatrix4d const &viewMatrix, GfMatrix4d const &projectionMatrix, CameraUtilFraming const &framing)
Set camera to renderpass.
HD_API void SetRepr(HdReprSelector const &reprSelector)
Switch repr.
#define HD_API
Definition: api.h:40
HdRenderPassStateSharedPtr const & GetRenderPassState() const
Returns the renderPassState.
HD_API void SetCullStyle(HdCullStyle cullStyle)
Set cull style.
Definition: path.h:291
HD_API void Draw(bool withGuides=false)
Draw.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HdUnitTestDelegate & GetDelegate()
Returns the UnitTest delegate.
HD_API ~Hd_TestDriver()
HD_API HdRenderPassSharedPtr const & GetRenderPass()
Returns the renderpass.
HD_API Hd_TestDriver()