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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_ST_UNIT_TEST_GLDRAWING_H
8 #define PXR_IMAGING_HD_ST_UNIT_TEST_GLDRAWING_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 #include "pxr/base/gf/frustum.h"
13 #include "pxr/base/gf/matrix4d.h"
14 #include "pxr/base/gf/vec3f.h"
15 
16 #include <string>
17 
19 
20 
21 class HdSt_UnitTestWindow;
22 
23 /// \class HdSt_UnitTestGLDrawing
24 ///
25 /// A helper class for unit tests which need to perform GL drawing.
26 ///
28 public:
29  HDST_API
31  HDST_API
32  virtual ~HdSt_UnitTestGLDrawing();
33 
34  HDST_API
35  int GetWidth() const;
36  HDST_API
37  int GetHeight() const;
38  HDST_API
39  void RunTest(int argc, char *argv[]);
40  HDST_API
41  void RunOffscreenTest();
42 
43  virtual void InitTest() = 0;
44  HDST_API virtual void UninitTest();
45  virtual void DrawTest() = 0; // interactive mode
46  virtual void OffscreenTest() = 0; // offscreen mode (automated test)
47 
48  HDST_API
49  virtual void MousePress(int button, int x, int y, int modKeys);
50  HDST_API
51  virtual void MouseRelease(int button, int x, int y, int modKeys);
52  HDST_API
53  virtual void MouseMove(int x, int y, int modKeys);
54  HDST_API
55  virtual void KeyRelease(int key);
56 
57  HDST_API
58  virtual void Idle();
59 
60  HDST_API
61  virtual void Present(uint32_t framebuffer) {
62  // do nothing
63  }
64 
65 protected:
66  HDST_API
67  virtual void ParseArgs(int argc, char *argv[]);
68 
69  void SetCameraRotate(float rx, float ry) {
70  _rotate[0] = rx; _rotate[1] = ry;
71  }
73  _translate = t;
74  }
76  return _translate;
77  }
78  HDST_API
79  GfMatrix4d GetViewMatrix() const;
80  HDST_API
82  HDST_API
83  GfFrustum GetFrustum() const;
84 
85  GfVec2i GetMousePos() const { return GfVec2i(_mousePos[0], _mousePos[1]); }
86 
87 private:
88  HdSt_UnitTestWindow *_widget;
89  float _rotate[2];
90  GfVec3f _translate;
91 
92  int _mousePos[2];
93  bool _mouseButton[3];
94 };
95 
96 
98 
99 #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:43
virtual void OffscreenTest()=0
HDST_API GfFrustum GetFrustum() const
HDST_API void RunOffscreenTest()
void SetCameraRotate(float rx, float ry)
Definition: vec3f.h:45
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:1425
virtual HDST_API void UninitTest()
virtual HDST_API void MouseMove(int x, int y, int modKeys)
#define HDST_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
GfVec3f GetCameraTranslate() const
virtual HDST_API void KeyRelease(int key)
virtual void DrawTest()=0