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 HDST_UNIT_TEST_DRAWING_GL
25 #define HDST_UNIT_TEST_DRAWING_GL
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/base/gf/frustum.h"
30 #include "pxr/base/gf/matrix4d.h"
31 #include "pxr/base/gf/vec3f.h"
32 
33 #include <string>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 
38 class HdSt_UnitTestWindow;
39 
44 class HdSt_UnitTestGLDrawing {
45 public:
46  HDST_API
47  HdSt_UnitTestGLDrawing();
48  HDST_API
49  virtual ~HdSt_UnitTestGLDrawing();
50 
51  HDST_API
52  int GetWidth() const;
53  HDST_API
54  int GetHeight() const;
55  HDST_API
56  void RunTest(int argc, char *argv[]);
57 
58  virtual void InitTest() = 0;
59  virtual void DrawTest() = 0; // interactive mode
60  virtual void OffscreenTest() = 0; // offscreen mode (automated test)
61 
62  HDST_API
63  virtual void MousePress(int button, int x, int y);
64  HDST_API
65  virtual void MouseRelease(int button, int x, int y);
66  HDST_API
67  virtual void MouseMove(int x, int y);
68  HDST_API
69  virtual void KeyRelease(int key);
70 
71  HDST_API
72  virtual void Idle();
73 
74  HDST_API
75  bool WriteToFile(std::string const & attachment,
76  std::string const & filename) const;
77 
78 protected:
79  HDST_API
80  virtual void ParseArgs(int argc, char *argv[]);
81 
82  void SetCameraRotate(float rx, float ry) {
83  _rotate[0] = rx; _rotate[1] = ry;
84  }
85  void SetCameraTranslate(GfVec3f t) {
86  _translate = t;
87  }
88  GfVec3f GetCameraTranslate() const {
89  return _translate;
90  }
91  HDST_API
92  GfMatrix4d GetViewMatrix() const;
93  HDST_API
94  GfMatrix4d GetProjectionMatrix() const;
95  HDST_API
96  GfFrustum GetFrustum() const;
97 
98 private:
99  HdSt_UnitTestWindow *_widget;
100  float _rotate[2];
101  GfVec3f _translate;
102 
103  int _mousePos[2];
104  bool _mouseButton[3];
105 };
106 
107 
108 PXR_NAMESPACE_CLOSE_SCOPE
109 
110 #endif // HDST_UNIT_TEST_DRAWING_GL
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Basic type: View frustum.
Definition: frustum.h:87