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 USDIMAGINGGL_UNIT_TEST_GL_DRAWING_H
25 #define USDIMAGINGGL_UNIT_TEST_GL_DRAWING_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 
73  void RunTest(int argc, char *argv[]);
74 
75  virtual void InitTest() = 0;
76  virtual void DrawTest(bool offscreen) = 0;
77  virtual void ShutdownTest() { }
78 
79  virtual void MousePress(int button, int x, int y, int modKeys);
80  virtual void MouseRelease(int button, int x, int y, int modKeys);
81  virtual void MouseMove(int x, int y, int modKeys);
82  virtual void KeyRelease(int key);
83 
84  bool WriteToFile(std::string const & attachment, std::string const & filename) const;
85 
86 protected:
87  float _GetComplexity() const { return _complexity; }
88  bool _ShouldFrameAll() const { return _shouldFrameAll; }
89  TfToken _GetRenderer() const { return _renderer; }
90 
91  HdRenderIndex *_GetRenderIndex(UsdImagingGLEngine *engine) {
92  return engine->_GetRenderIndex();
93  }
94 
95  void _Render(UsdImagingGLEngine *engine,
96  const UsdImagingGLRenderParams &params) {
97  SdfPathVector roots(1, SdfPath::AbsoluteRootPath());
98  engine->RenderBatch(roots, params);
99  }
100 
101 private:
102  struct _Args;
103  void _Parse(int argc, char *argv[], _Args* args);
104 
105 private:
106  UsdImagingGL_UnitTestWindow *_widget;
107  bool _testLighting;
108  bool _sceneLights;
109  bool _cameraLight;
110  std::string _cameraPath;
111  bool _testIdRender;
112 
113  std::string _stageFilePath;
114  std::string _outputFilePath;
115 
116  float _complexity;
117  TfToken _renderer;
118 
119  std::vector<double> _times;
120 
121  std::vector<GfVec4d> _clipPlanes;
122 
123  UsdImagingGLDrawMode _drawMode;
124  bool _shouldFrameAll;
125  bool _cullBackfaces;
126  GfVec4f _clearColor;
127  GfVec3f _translate;
128  VtDictionary _renderSettings;
129 };
130 
131 
132 PXR_NAMESPACE_CLOSE_SCOPE
133 
134 #endif // USDIMAGINGGL_UNIT_TEST_GL_DRAWING_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
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