HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unitTestGLDrawing.h
Go to the documentation of this file.
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_IMAGING_HD_ST_UNIT_TEST_GLDRAWING_H
25 #define PXR_IMAGING_HD_ST_UNIT_TEST_GLDRAWING_H
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 
36 
37 
38 class HdSt_UnitTestWindow;
39 
40 /// \class HdSt_UnitTestGLDrawing
41 ///
42 /// A helper class for unit tests which need to perform GL drawing.
43 ///
45 public:
46  HDST_API
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  HDST_API
58  void RunOffscreenTest();
59 
60  virtual void InitTest() = 0;
61  HDST_API virtual void UninitTest();
62  virtual void DrawTest() = 0; // interactive mode
63  virtual void OffscreenTest() = 0; // offscreen mode (automated test)
64 
65  HDST_API
66  virtual void MousePress(int button, int x, int y, int modKeys);
67  HDST_API
68  virtual void MouseRelease(int button, int x, int y, int modKeys);
69  HDST_API
70  virtual void MouseMove(int x, int y, int modKeys);
71  HDST_API
72  virtual void KeyRelease(int key);
73 
74  HDST_API
75  virtual void Idle();
76 
77  HDST_API
78  virtual void Present(uint32_t framebuffer) {
79  // do nothing
80  }
81 
82 protected:
83  HDST_API
84  virtual void ParseArgs(int argc, char *argv[]);
85 
86  void SetCameraRotate(float rx, float ry) {
87  _rotate[0] = rx; _rotate[1] = ry;
88  }
90  _translate = t;
91  }
93  return _translate;
94  }
95  HDST_API
96  GfMatrix4d GetViewMatrix() const;
97  HDST_API
99  HDST_API
100  GfFrustum GetFrustum() const;
101 
102  GfVec2i GetMousePos() const { return GfVec2i(_mousePos[0], _mousePos[1]); }
103 
104 private:
105  HdSt_UnitTestWindow *_widget;
106  float _rotate[2];
107  GfVec3f _translate;
108 
109  int _mousePos[2];
110  bool _mouseButton[3];
111 };
112 
113 
115 
116 #endif // PXR_IMAGING_HD_ST_UNIT_TEST_GLDRAWING_H
HDST_API GfMatrix4d GetProjectionMatrix() const
virtual HDST_API void ParseArgs(int argc, char *argv[])
GfVec2i GetMousePos() const
virtual HDST_API void MouseRelease(int button, int x, int y, int modKeys)
virtual void InitTest()=0
virtual HDST_API ~HdSt_UnitTestGLDrawing()
virtual HDST_API void Present(uint32_t framebuffer)
Definition: vec2i.h:60
virtual void OffscreenTest()=0
HDST_API GfFrustum GetFrustum() const
HDST_API void RunOffscreenTest()
void SetCameraRotate(float rx, float ry)
Definition: vec3f.h:62
virtual HDST_API void Idle()
GLint y
Definition: glcorearb.h:103
HDST_API int GetHeight() const
GLuint framebuffer
Definition: glcorearb.h:1287
virtual HDST_API void MousePress(int button, int x, int y, int modKeys)
void SetCameraTranslate(GfVec3f t)
GLint GLenum GLint x
Definition: glcorearb.h:409
GLdouble t
Definition: glad.h:2397
HDST_API void RunTest(int argc, char *argv[])
HDST_API GfMatrix4d GetViewMatrix() const
HDST_API HdSt_UnitTestGLDrawing()
HDST_API int GetWidth() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
virtual HDST_API void UninitTest()
virtual HDST_API void MouseMove(int x, int y, int modKeys)
#define HDST_API
Definition: api.h:40
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
GfVec3f GetCameraTranslate() const
virtual HDST_API void KeyRelease(int key)
virtual void DrawTest()=0