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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_UNIT_TEST_HELPER_H
8 #define PXR_IMAGING_HD_UNIT_TEST_HELPER_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/engine.h"
17 
18 #include "pxr/base/gf/vec4d.h"
19 #include "pxr/base/gf/matrix4d.h"
20 
21 #include <vector>
22 
24 
25 
26 /// \class Hd_TestDriver
27 ///
28 /// A unit test driver that exercises the core engine.
29 ///
30 /// \note This test driver does NOT assume OpenGL is available; in the even
31 /// that is is not available, all OpenGL calls become no-ops, but all other work
32 /// is performed as usual.
33 ///
34 class Hd_TestDriver final
35 {
36 public:
37  HD_API
38  Hd_TestDriver();
39  HD_API
40  Hd_TestDriver(HdReprSelector const &reprToken);
41  HD_API
43 
44  /// Draw
45  HD_API
46  void Draw(bool withGuides=false);
47 
48  /// Draw with external renderPass
49  HD_API
50  void Draw(HdRenderPassSharedPtr const &renderPass, bool withGuides);
51 
52  /// Set camera to renderpass
53  HD_API
54  void SetCamera(GfMatrix4d const &viewMatrix,
55  GfMatrix4d const &projectionMatrix,
56  CameraUtilFraming const &framing);
57 
58  /// Set cull style
59  HD_API
60  void SetCullStyle(HdCullStyle cullStyle);
61 
62  /// Returns the renderpass
63  HD_API
65 
66  /// Returns the renderPassState
68  return _renderPassState;
69  }
70 
71  /// Returns the UnitTest delegate
72  HdUnitTestDelegate& GetDelegate() { return *_sceneDelegate; }
73 
74  /// Switch repr
75  HD_API
76  void SetRepr(HdReprSelector const &reprSelector);
77 
78 private:
79 
80  void _Init(HdReprSelector const &reprSelector);
81 
82  HdEngine _engine;
83  Hd_UnitTestNullRenderDelegate _renderDelegate;
84  HdRenderIndex *_renderIndex;
85  HdUnitTestDelegate *_sceneDelegate;
86  SdfPath _cameraId;
87  HdRenderPassSharedPtr _renderPass;
88  HdRenderPassStateSharedPtr _renderPassState;
89  HdRprimCollection _collection;
90 };
91 
93 
94 #endif // PXR_IMAGING_HD_UNIT_TEST_HELPER_H
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:25
HdCullStyle
Definition: enums.h:105
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:24
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:23
HdRenderPassStateSharedPtr const & GetRenderPassState() const
Returns the renderPassState.
HD_API void SetCullStyle(HdCullStyle cullStyle)
Set cull style.
Definition: path.h:273
HD_API void Draw(bool withGuides=false)
Draw.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdUnitTestDelegate & GetDelegate()
Returns the UnitTest delegate.
HD_API ~Hd_TestDriver()
HD_API HdRenderPassSharedPtr const & GetRenderPass()
Returns the renderpass.
HD_API Hd_TestDriver()