Loading...
Searching...
No Matches
unitTestGLDrawing.h
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"
14#include "pxr/base/gf/vec3f.h"
15
16#include <string>
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20
21class HdSt_UnitTestWindow;
22
27class HdSt_UnitTestGLDrawing {
28public:
29 HDST_API
30 HdSt_UnitTestGLDrawing();
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
65protected:
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 }
72 void SetCameraTranslate(GfVec3f t) {
73 _translate = t;
74 }
75 GfVec3f GetCameraTranslate() const {
76 return _translate;
77 }
78 HDST_API
79 GfMatrix4d GetViewMatrix() const;
80 HDST_API
81 GfMatrix4d GetProjectionMatrix() const;
82 HDST_API
83 GfFrustum GetFrustum() const;
84
85 GfVec2i GetMousePos() const { return GfVec2i(_mousePos[0], _mousePos[1]); }
86
87private:
88 HdSt_UnitTestWindow *_widget;
89 float _rotate[2];
90 GfVec3f _translate;
91
92 int _mousePos[2];
93 bool _mouseButton[3];
94};
95
96
97PXR_NAMESPACE_CLOSE_SCOPE
98
99#endif // PXR_IMAGING_HD_ST_UNIT_TEST_GLDRAWING_H
Basic type: View frustum.
Definition: frustum.h:71
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Basic type for a vector of 2 int components.
Definition: vec2i.h:44
Basic type for a vector of 3 float components.
Definition: vec3f.h:46