-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHelloT5Cube.h
More file actions
119 lines (94 loc) · 3.34 KB
/
HelloT5Cube.h
File metadata and controls
119 lines (94 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#pragma once
#include <glapplication/Application.h>
#include <glwrapper/Shader.h>
#include <glwrapper/Buffer.h>
#include <glwrapper/VertexArray.h>
#include <glwrapper/Framebuffer.h>
#include <t5wrapper/Context.h>
#include <t5wrapper/Glasses.h>
#include <glapplication/Transform.h>
#include <util/ChangeDetector.h>
namespace GLW = GLWrapper;
namespace T5W = T5Wrapper;
namespace GLApp = GLApplication;
/****************************************************************************
Main application class
*****************************************************************************/
class HelloT5Cube : public GLApp::Application
{
/****************************************************************************
Holds framebuffer data for the two stereo images
*****************************************************************************/
struct DisplaySurface
{
int height;
int width;
int layers = 1;
Owned<GLW::Texture> texture;
Owned<GLW::Texture> depth;
Owned<GLW::Framebuffer> framebuffer;
bool Initialize(int height, int width, bool hasDepth = true);
bool InitializeMultiview(int height, int width, int layers);
void BeginDraw();
void EndDraw();
void BlitToScreen(int dstHeight, int dstWidth);
void BlitToFrameBuffer(GLW::Framebuffer& framebuffer, int dstHeight, int dstWidth);
void BlitFromFrameBuffer(GLW::Framebuffer& framebuffer);
Owned<GLW::Texture> GetTextureLayer(int layer);
};
bool glDebug;
// Are these the right defaults? Values were pulled from other
// source references
int defaultWidth = 1216;
int defaultHeight = 768;
float defaultFOV = 48.0;
bool isMultiviewCapable = false;
bool useMultiview = false;
bool copyMultviewTextures = false;
Owned<GLW::Texture> leftLayerTexture;
Owned<GLW::Texture> rightLayerTexture;
Owned<GLW::Framebuffer> leftLayerFramebuffer;
Owned<GLW::Framebuffer> rightLayerFramebuffer;
// program and vertex buffers for rendering
Owned<GLW::ShaderProgram> cubeShader;
Owned<GLW::Buffer> cubeVertexBuffer;
Owned<GLW::VertexArray> cubeVertexArrays;
// Frame buffers for left and right eye
DisplaySurface leftEyeDisplay;
DisplaySurface rightEyeDisplay;
DisplaySurface stereoEyeDisplay;
// T5 handles
Owned<T5W::Context> context;
Owned<T5W::Glasses> glasses;
// All the poses neeed to make up the view matrix
GLApp::Transform gameboardPose;
GLApp::Transform headPose; // Relative to game board pose
GLApp::Transform leftEyePose; // Relative to head pose
GLApp::Transform rightEyePose; // Relative to head pose
// List of glasses ID we got from the T5 API
std::vector<std::string> glassesIDList;
// Version number form the T5 service
std::string serviceVersion;
// Misc
ChangeDetector<bool> isPoseValid;
ChangeDetector<bool> isFrameSent;
bool isOutputingOnePoseFrame = false;
int frameCounter = 0;
// overrides from GLApp::Application
bool InitializeApplication() override;
bool InitializeContext() override;
void OnKey(int key, int scancode, int action, int mods) override;
void Update() override;
bool InitializeT5();
bool ConnectGlasses(std::string glassesID);
void UpdateGlassesPose();
void Render();
void SendFramesToGlasses();
public:
HelloT5Cube(int width, int height, std::string title, bool multiview, bool copyTextures, bool dgl)
: GLApplication::Application(width, height, title),
useMultiview(multiview),
copyMultviewTextures(copyTextures),
glDebug(dgl)
{}
};