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