All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unitTestGLDrawing.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 #ifndef PXR_USD_IMAGING_USD_IMAGING_GL_UNIT_TEST_GLDRAWING_H
25 #define PXR_USD_IMAGING_USD_IMAGING_GL_UNIT_TEST_GLDRAWING_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/gf/vec4d.h"
29 #include "pxr/base/vt/dictionary.h"
30 
31 #include "pxr/base/tf/declarePtrs.h"
32 
33 #include "pxr/usdImaging/usdImagingGL/engine.h"
34 
35 #include <string>
36 #include <vector>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 class UsdImagingGL_UnitTestWindow;
42 
47 class UsdImagingGL_UnitTestGLDrawing {
48 public:
49  UsdImagingGL_UnitTestGLDrawing();
50  virtual ~UsdImagingGL_UnitTestGLDrawing();
51 
52  int GetWidth() const;
53  int GetHeight() const;
54 
55  bool IsEnabledTestLighting() const { return _testLighting; }
56  bool IsEnabledSceneLights() const { return _sceneLights; }
57  bool IsEnabledCameraLight() const { return _cameraLight; }
58  bool IsEnabledCullBackfaces() const { return _cullBackfaces; }
59  bool IsEnabledIdRender() const { return _testIdRender; }
60 
61  UsdImagingGLDrawMode GetDrawMode() const { return _drawMode; }
62 
63  std::string const & GetStageFilePath() const { return _stageFilePath; }
64  std::string const & GetOutputFilePath() const { return _outputFilePath; }
65 
66  std::string const & GetCameraPath() const { return _cameraPath; }
67  std::vector<GfVec4d> const & GetClipPlanes() const { return _clipPlanes; }
68  std::vector<double> const& GetTimes() const { return _times; }
69  GfVec4f const & GetClearColor() const { return _clearColor; }
70  GfVec3f const & GetTranslate() const { return _translate; }
71  VtDictionary const &GetRenderSettings() const { return _renderSettings; }
72  TfToken const & GetRendererAov() const { return _rendererAov; }
73 
74  void RunTest(int argc, char *argv[]);
75 
76  virtual void InitTest() = 0;
77  virtual void DrawTest(bool offscreen) = 0;
78  virtual void ShutdownTest() { }
79 
80  virtual void MousePress(int button, int x, int y, int modKeys);
81  virtual void MouseRelease(int button, int x, int y, int modKeys);
82  virtual void MouseMove(int x, int y, int modKeys);
83  virtual void KeyRelease(int key);
84 
85  bool WriteToFile(std::string const & attachment, std::string const & filename) const;
86 
87 protected:
88  float _GetComplexity() const { return _complexity; }
89  bool _ShouldFrameAll() const { return _shouldFrameAll; }
90  TfToken _GetRenderer() const { return _renderer; }
91 
92  HdRenderIndex *_GetRenderIndex(UsdImagingGLEngine *engine) {
93  return engine->_GetRenderIndex();
94  }
95 
96  void _Render(UsdImagingGLEngine *engine,
97  const UsdImagingGLRenderParams &params) {
98  SdfPathVector roots(1, SdfPath::AbsoluteRootPath());
99  engine->RenderBatch(roots, params);
100  }
101 
102 private:
103  struct _Args;
104  void _Parse(int argc, char *argv[], _Args* args);
105 
106 private:
107  UsdImagingGL_UnitTestWindow *_widget;
108  bool _testLighting;
109  bool _sceneLights;
110  bool _cameraLight;
111  std::string _cameraPath;
112  bool _testIdRender;
113 
114  std::string _stageFilePath;
115  std::string _outputFilePath;
116 
117  float _complexity;
118  TfToken _renderer;
119 
120  std::vector<double> _times;
121 
122  std::vector<GfVec4d> _clipPlanes;
123 
124  UsdImagingGLDrawMode _drawMode;
125  bool _shouldFrameAll;
126  bool _cullBackfaces;
127  GfVec4f _clearColor;
128  GfVec3f _translate;
129  VtDictionary _renderSettings;
130  TfToken _rendererAov;
131 };
132 
133 
134 PXR_NAMESPACE_CLOSE_SCOPE
135 
136 #endif // PXR_USD_IMAGING_USD_IMAGING_GL_UNIT_TEST_GLDRAWING_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:117
USDIMAGINGGL_API HdRenderIndex * _GetRenderIndex() const
Returns the render index of the engine, if any.
A map with string keys and VtValue values.
Definition: dictionary.h:61
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
Used as an arguments class for various methods in UsdImagingGLEngine.
Definition: renderParams.h:72
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
Definition: engine.h:81