Project
Loading...
Searching...
No Matches
GPUDisplayKeys.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "GPUDisplay.h"
16
17using namespace o2::gpu;
18
19const char* HelpText[] = {
20 "[ESC] Quit",
21 "[n] Next event",
22 "[r] Reset Display Settings",
23 "[l] / [k] / [J] Draw single sector (next / previous sector), draw related sectors (same plane in phi)",
24 "[;] / [:] Show splitting of TPC in sectors by extruding volume, [:] resets",
25 "[#] Invert colors",
26 "[y] / [Y] / [X] / [M] Start Animation, Add / remove Animation point, Reset Points, Cycle animation camera mode (resets)",
27 "[>] / [<] Toggle config interpolation during Animation / change Animation interval (via movement)",
28 "[g] Draw Grid",
29 "[i] Project onto XY-plane",
30 "[x] Exclude Clusters used in the tracking steps enabled for visualization ([1]-[8])",
31 "[.] Exclude rejected tracks",
32 "[c] Mark flagged clusters (splitPad = 0x1, splitTime = 0x2, edge = 0x4, singlePad = 0x8, rejectDistance = 0x10, rejectErr = 0x20",
33 "[z] Mark fake attached clusters",
34 "[B] Mark clusters attached as adjacent",
35 "[L] / [K] Draw single collisions (next / previous)",
36 "[C] Colorcode clusters of different collisions",
37 "[v] Hide rejected clusters from tracks",
38 "[j] Show tracks segments propagated to adjacent sector in different color / splt CE tracks",
39 "[u] Cycle through track filter",
40 "[E] / [G] Extrapolate tracks / loopers",
41 "[t] / [T] Take Screenshot / Record Animation to pictures",
42 "[Z] Change screenshot resolution (scaling factor)",
43 "[S] / [A] / [D] Enable or disable smoothing of points / smoothing of lines / depth buffer",
44 "[W] / [U] / [V] Toggle anti-aliasing (MSAA at raster level / change downsampling FSAA factor) / toggle VSync",
45 "[F] / [_] / [R] Switch mFullScreen / Maximized window / FPS rate limiter",
46 "[I] Enable / disable GL indirect draw",
47 "[o] / [p] / [O] / [P] Save / restore current camera position / Animation path",
48 "[h] Print Help",
49 "[H] Show info texts",
50 "[q] Start / Stop Qt GUI",
51 "[w] / [s] / [a] / [d] Zoom / Strafe Left and Right",
52 "[pgup] / [pgdn] Strafe up / down",
53 "[e] / [f] Rotate left / right",
54 "[+] / [-] Increase / decrease point size (Hold SHIFT for lines)",
55 "[b] Change FOV (field of view)",
56 "['] Switch between OpenGL core / compat code path",
57 "[MOUSE 1] Look around",
58 "[MOUSE 2] Strafe camera",
59 "[MOUSE 1+2] Zoom / Rotate",
60 "[SHIFT] Slow Zoom / Move / Rotate",
61 "[ALT] / [CTRL] / [ENTER] Focus camera on origin / orient y-axis upwards (combine with [SHIFT] to lock) / Cycle through modes",
62 "[RCTRL] / [RALT] Rotate model instead of camera / rotate TPC around beamline",
63 "[1] ... [8] / [N] Enable display of clusters, preseeds, seeds, starthits, tracklets, tracks, extrapolated tracks, merged tracks / Show assigned clusters in colors",
64 "[F1] / [F2] / [F3] / [F4] Enable / disable drawing of TPC / TRD / TOF / ITS",
65 "[SHIFT] + [F1] to [F4] Enable / disable track detector filter",
66 "[SHIFT] + [F12] Switch track detector filter between AND and OR mode"
67 // FREE: [m] [SPACE] [Q]
68 // Test setting: ^
69};
70
71void GPUDisplay::PrintHelp()
72{
73 mInfoHelpTimer.ResetStart();
74 for (uint32_t i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) {
75 GPUInfo("%s", HelpText[i]);
76 }
77}
78
80{
81 GPUSettingsDisplayHeavy oldCfgH = mCfgH;
82 GPUSettingsDisplayLight oldCfgL = mCfgL;
83 GPUSettingsDisplayRenderer oldCfgR = mCfgR;
84 if (key == 'n') {
85 mFrontend->mDisplayControl = 1;
86 SetInfo("Showing next event", 1);
87 } else if (key == 27 || key == mFrontend->KEY_ESCAPE) {
88 mFrontend->mDisplayControl = 2;
89 SetInfo("Exiting", 1);
90 } else if (key == 'r') {
91 mResetScene = 1;
92 SetInfo("View reset", 1);
93 } else if (key == mFrontend->KEY_ALT && mFrontend->mKeysShift[mFrontend->KEY_ALT]) {
94 mCfgR.camLookOrigin ^= 1;
95 mCfgR.cameraMode = mCfgR.camLookOrigin + 2 * mCfgR.camYUp;
96 SetInfo("Camera locked on origin: %s", mCfgR.camLookOrigin ? "enabled" : "disabled");
97 } else if (key == mFrontend->KEY_CTRL && mFrontend->mKeysShift[mFrontend->KEY_CTRL]) {
98 mCfgR.camYUp ^= 1;
99 mCfgR.cameraMode = mCfgR.camLookOrigin + 2 * mCfgR.camYUp;
100 SetInfo("Camera locked on y-axis facing upwards: %s", mCfgR.camYUp ? "enabled" : "disabled");
101 } else if (key == mFrontend->KEY_ENTER) {
102 mCfgR.cameraMode++;
103 if (mCfgR.cameraMode == 4) {
104 mCfgR.cameraMode = 0;
105 }
106 mCfgR.camLookOrigin = mCfgR.cameraMode & 1;
107 mCfgR.camYUp = mCfgR.cameraMode & 2;
108 const char* modeText[] = {"Descent (free movement)", "Focus locked on origin (y-axis forced upwards)", "Spectator (y-axis forced upwards)", "Focus locked on origin (with free rotation)"};
109 SetInfo("Camera mode %d: %s", mCfgR.cameraMode, modeText[mCfgR.cameraMode]);
110 } else if (key == mFrontend->KEY_ALT) {
111 mFrontend->mKeys[mFrontend->KEY_CTRL] = false; // Release CTRL with alt, to avoid orienting along y automatically!
112 } else if (key == 'l') {
113 if (mCfgL.drawSector >= (mCfgL.drawRelatedSectors ? (NSECTORS / 4 - 1) : (NSECTORS - 1))) {
114 mCfgL.drawSector = -1;
115 SetInfo("Showing all sectors", 1);
116 } else {
117 mCfgL.drawSector++;
118 SetInfo("Showing sector %d", mCfgL.drawSector);
119 }
120 } else if (key == 'k') {
121 if (mCfgL.drawSector <= -1) {
122 mCfgL.drawSector = mCfgL.drawRelatedSectors ? (NSECTORS / 4 - 1) : (NSECTORS - 1);
123 } else {
124 mCfgL.drawSector--;
125 }
126 if (mCfgL.drawSector == -1) {
127 SetInfo("Showing all sectors", 1);
128 } else {
129 SetInfo("Showing sector %d", mCfgL.drawSector);
130 }
131 } else if (key == 'J') {
132 mCfgL.drawRelatedSectors ^= 1;
133 SetInfo("Drawing of related sectors %s", mCfgL.drawRelatedSectors ? "enabled" : "disabled");
134 } else if (key == 'L') {
135 if (mCfgL.showCollision >= mNCollissions - 1) {
136 mCfgL.showCollision = -1;
137 SetInfo("Showing all collisions", 1);
138 } else {
139 mCfgL.showCollision++;
140 SetInfo("Showing collision %d / %d", mCfgL.showCollision, mNCollissions);
141 }
142 } else if (key == 'K') {
143 if (mCfgL.showCollision <= -1) {
144 mCfgL.showCollision = mNCollissions - 1;
145 } else {
146 mCfgL.showCollision--;
147 }
148 if (mCfgL.showCollision == -1) {
149 SetInfo("Showing all collisions", 1);
150 } else {
151 SetInfo("Showing collision %d / %d", mCfgL.showCollision, mNCollissions);
152 }
153 } else if (key == 'F') {
154 mCfgR.fullScreen ^= 1;
155 SetInfo("Toggling full screen (%d)", (int32_t)mCfgR.fullScreen);
156 } else if (key == '_') {
157 mCfgR.maximized ^= 1;
158 SetInfo("Toggling Maximized window (%d)", (int32_t)mCfgR.maximized);
159 } else if (key == 'R') {
160 mCfgR.maxFPSRate ^= 1;
161 SetInfo("FPS rate %s", mCfgR.maxFPSRate ? "not limited" : "limited");
162 } else if (key == 'H') {
163 mPrintInfoText += 1;
164 mPrintInfoText &= 3;
165 SetInfo("Info text display - console: %s, onscreen %s", (mPrintInfoText & 2) ? "enabled" : "disabled", (mPrintInfoText & 1) ? "enabled" : "disabled");
166 } else if (key == 'j') {
167 if (mCfgH.separateExtrapolatedTracks) {
168 mCfgH.splitCETracks ^= 1;
169 }
170 mCfgH.separateExtrapolatedTracks ^= 1;
171 SetInfo("Seperated display of tracks propagated to adjacent sectors %s / of CE tracks %s", mCfgH.separateExtrapolatedTracks ? "enabled" : "disabled", mCfgH.splitCETracks ? "enabled" : "disabled");
172 } else if (key == 'c') {
173 if (mCfgH.markClusters == 0) {
174 mCfgH.markClusters = 1;
175 } else if (mCfgH.markClusters >= 0x20) {
176 mCfgH.markClusters = 0;
177 } else {
178 mCfgH.markClusters <<= 1;
179 }
180 SetInfo("Cluster flag highlight mask set to %d (%s)", mCfgH.markClusters,
181 mCfgH.markClusters == 0 ? "off" : mCfgH.markClusters == 1 ? "split pad" : mCfgH.markClusters == 2 ? "split time" : mCfgH.markClusters == 4 ? "edge" : mCfgH.markClusters == 8 ? "singlePad" : mCfgH.markClusters == 0x10 ? "reject distance" : "reject error");
182 } else if (key == 'z') {
183 mCfgH.markFakeClusters ^= 1;
184 SetInfo("Marking fake clusters: %s", mCfgH.markFakeClusters ? "on" : "off");
185 } else if (key == 'b') {
186 if ((mCfgR.fov += 5) > 175) {
187 mCfgR.fov = 5;
188 }
189 SetInfo("Set FOV to %f", mCfgR.fov);
190 } else if (key == 39) { // character = "'"
191 if (backend()->backendType() == GPUDisplayBackend::TYPE_OPENGL) {
192#ifdef GPUCA_DISPLAY_OPENGL_CORE
193 SetInfo("OpenGL compat profile not available, using core profile", 1);
194#else
195 mCfgR.openGLCore ^= 1;
196 SetInfo("Using renderer path for OpenGL %s profile", mCfgR.openGLCore ? "core" : "compat");
197#endif
198 } else {
199 SetInfo("OpenGL options only available with OpenGL backend");
200 }
201 } else if (key == 'B') {
202 mCfgH.markAdjacentClusters++;
203 if (mCfgH.markAdjacentClusters == 5) {
204 mCfgH.markAdjacentClusters = 7;
205 }
206 if (mCfgH.markAdjacentClusters == 9) {
207 mCfgH.markAdjacentClusters = 15;
208 }
209 if (mCfgH.markAdjacentClusters == 17) {
210 mCfgH.markAdjacentClusters = 31;
211 }
212 if (mCfgH.markAdjacentClusters == 34) {
213 mCfgH.markAdjacentClusters = 0;
214 }
215 if (mCfgH.markAdjacentClusters == 33) {
216 SetInfo("Marking protected clusters (%d)", mCfgH.markAdjacentClusters);
217 } else if (mCfgH.markAdjacentClusters == 32) {
218 SetInfo("Marking removable clusters (%d)", mCfgH.markAdjacentClusters);
219 } else {
220 SetInfo("Marking adjacent clusters (%d): rejected %s, tube %s, looper leg %s, low Pt %s, high incl %s", mCfgH.markAdjacentClusters, (mCfgH.markAdjacentClusters & 1) ? "yes" : " no", (mCfgH.markAdjacentClusters & 2) ? "yes" : " no", (mCfgH.markAdjacentClusters & 4) ? "yes" : " no", (mCfgH.markAdjacentClusters & 8) ? "yes" : " no", (mCfgH.markAdjacentClusters & 16) ? "yes" : " no");
221 }
222 } else if (key == 'C') {
223 mCfgL.colorCollisions ^= 1;
224 SetInfo("Color coding of collisions %s", mCfgL.colorCollisions ? "enabled" : "disabled");
225 } else if (key == 'N') {
226 mCfgL.colorClusters ^= 1;
227 SetInfo("Color coding for seed / trrack attachmend %s", mCfgL.colorClusters ? "enabled" : "disabled");
228 } else if (key == 'E') {
229 mCfgL.propagateTracks += 1;
230 if (mCfgL.propagateTracks == 4) {
231 mCfgL.propagateTracks = 0;
232 }
233 const char* infoText[] = {"Hits connected", "Hits connected and propagated to vertex", "Reconstructed track propagated inwards and outwards", "Monte Carlo track"};
234 SetInfo("Display of propagated tracks: %s", infoText[mCfgL.propagateTracks]);
235 } else if (key == 'G') {
236 mCfgH.propagateLoopers ^= 1;
237 SetInfo("Propagation of loopers %s", mCfgH.propagateLoopers ? "enabled" : "disabled");
238 } else if (key == 'v') {
239 mCfgH.hideRejectedClusters ^= 1;
240 SetInfo("Rejected clusters are %s", mCfgH.hideRejectedClusters ? "hidden" : "shown");
241 } else if (key == 'i') {
242 mCfgH.projectXY ^= 1;
243 SetInfo("Projection onto xy plane %s", mCfgH.projectXY ? "enabled" : "disabled");
244 } else if (key == 'S') {
245 mCfgL.smoothPoints ^= true;
246 SetInfo("Smoothing of points %s", mCfgL.smoothPoints ? "enabled" : "disabled");
247 } else if (key == 'A') {
248 mCfgL.smoothLines ^= true;
249 SetInfo("Smoothing of lines %s", mCfgL.smoothLines ? "enabled" : "disabled");
250 } else if (key == 'D') {
251 mCfgL.depthBuffer ^= true;
252 SetInfo("Depth buffer (z-buffer, %u bits) %s", mBackend->DepthBits(), mCfgL.depthBuffer ? "enabled" : "disabled");
253 mBackend->setDepthBuffer();
254 } else if (key == 'W') {
255 mCfgR.drawQualityMSAA *= 2;
256 if (mCfgR.drawQualityMSAA < 2) {
257 mCfgR.drawQualityMSAA = 2;
258 }
259 if (mCfgR.drawQualityMSAA > 16 || mCfgR.drawQualityMSAA > mBackend->getMaxMSAA()) {
260 mCfgR.drawQualityMSAA = 0;
261 }
262 SetInfo("Multisampling anti-aliasing factor set to %d", mCfgR.drawQualityMSAA);
263 } else if (key == 'U') {
264 mCfgR.drawQualityDownsampleFSAA++;
265 if (mCfgR.drawQualityDownsampleFSAA == 1) {
266 mCfgR.drawQualityDownsampleFSAA = 2;
267 }
268 if (mCfgR.drawQualityDownsampleFSAA == 5) {
269 mCfgR.drawQualityDownsampleFSAA = 0;
270 }
271 SetInfo("Downsampling anti-aliasing factor set to %d", mCfgR.drawQualityDownsampleFSAA);
272 } else if (key == 'V') {
273 mCfgR.drawQualityVSync ^= true;
274 SetInfo("VSync: %s", mCfgR.drawQualityVSync ? "enabled" : "disabled");
275 } else if (key == 'I') {
276 mCfgR.useGLIndirectDraw ^= true;
277 SetInfo("OpenGL Indirect Draw %s", mCfgR.useGLIndirectDraw ? "enabled" : "disabled");
278 } else if (key == ';') {
279 mCfgH.xAdd += 60;
280 mCfgH.zAdd += 60;
281 SetInfo("TPC sector separation: %f %f", mCfgH.xAdd, mCfgH.zAdd);
282 } else if (key == ':') {
283 mCfgH.xAdd -= 60;
284 mCfgH.zAdd -= 60;
285 if (mCfgH.zAdd < 0 || mCfgH.xAdd < 0) {
286 mCfgH.zAdd = mCfgH.xAdd = 0;
287 }
288 SetInfo("TPC sector separation: %f %f", mCfgH.xAdd, mCfgH.zAdd);
289 } else if (key == '#') {
290 mCfgL.invertColors ^= 1;
291 } else if (key == 'g') {
292 mCfgL.drawGrid ^= 1;
293 SetInfo("Fast Cluster Search Grid %s", mCfgL.drawGrid ? "shown" : "hidden");
294 } else if (key == 'x') {
295 mCfgL.excludeClusters = (mCfgL.excludeClusters + 1) % 3;
296 SetInfo(mCfgL.excludeClusters ? "Clusters of selected category are excluded from display (%d)" : "Clusters are shown", mCfgL.excludeClusters);
297 } else if (key == '.') {
298 mCfgH.hideRejectedTracks ^= 1;
299 SetInfo("Rejected tracks are %s", mCfgH.hideRejectedTracks ? "hidden" : "shown");
300 } else if (key == '1') {
301 mCfgL.drawClusters ^= 1;
302 } else if (key == '2') {
303 mCfgL.drawInitLinks ^= 1;
304 } else if (key == '3') {
305 mCfgL.drawLinks ^= 1;
306 } else if (key == '4') {
307 mCfgL.drawSeeds ^= 1;
308 } else if (key == '5') {
309 mCfgL.drawTracklets ^= 1;
310 } else if (key == '6') {
311 mCfgL.drawTracks ^= 1;
312 } else if (key == '7') {
313 mCfgL.drawExtrapolatedTracks ^= 1;
314 } else if (key == '8') {
315 mCfgL.drawFinal ^= 1;
316 } else if (key == mFrontend->KEY_F1) {
317 if (mFrontend->mKeysShift[mFrontend->KEY_F1]) {
318 mCfgH.drawTPCTracks ^= 1;
319 SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks);
320 } else {
321 mCfgL.drawTPC ^= 1;
322 SetInfo("Showing TPC Clusters: %d", (int32_t)mCfgL.drawTPC);
323 }
324 } else if (key == mFrontend->KEY_F2) {
325 if (mFrontend->mKeysShift[mFrontend->KEY_F2]) {
326 mCfgH.drawTRDTracks ^= 1;
327 SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks);
328 } else {
329 mCfgL.drawTRD ^= 1;
330 SetInfo("Showing TRD Tracklets: %d", (int32_t)mCfgL.drawTRD);
331 }
332 } else if (key == mFrontend->KEY_F3) {
333 if (mFrontend->mKeysShift[mFrontend->KEY_F3]) {
334 mCfgH.drawTOFTracks ^= 1;
335 SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks);
336 } else {
337 mCfgL.drawTOF ^= 1;
338 SetInfo("Showing TOF Hits: %d", (int32_t)mCfgL.drawTOF);
339 }
340 } else if (key == mFrontend->KEY_F4) {
341 if (mFrontend->mKeysShift[mFrontend->KEY_F4]) {
342 mCfgH.drawITSTracks ^= 1;
343 SetInfo("Track Filter Mask: TPC:%d TRD:%d TOF:%d ITS:%d", (int32_t)mCfgH.drawTPCTracks, (int32_t)mCfgH.drawTRDTracks, (int32_t)mCfgH.drawTOFTracks, (int32_t)mCfgH.drawITSTracks);
344 } else {
345 mCfgL.drawITS ^= 1;
346 SetInfo("Showing ITS Clusters: %d", (int32_t)mCfgL.drawITS);
347 }
348 } else if (key == mFrontend->KEY_F12 && mFrontend->mKeysShift[mFrontend->KEY_F12]) {
349 mCfgH.drawTracksAndFilter ^= 1;
350 SetInfo("Track filter: %s", mCfgH.drawTracksAndFilter ? "AND" : "OR");
351 } else if (key == 't') {
352 static int32_t nScreenshot = 1;
353 char fname[32];
354 snprintf(fname, 32, "screenshot%d.bmp", nScreenshot++);
355 mRequestScreenshot = true;
356 mScreenshotFile = fname;
357 SetInfo("Taking screenshot (%s)", fname);
358 } else if (key == 'Z') {
359 mCfgR.screenshotScaleFactor += 1;
360 if (mCfgR.screenshotScaleFactor == 5) {
361 mCfgR.screenshotScaleFactor = 1;
362 }
363 SetInfo("Screenshot scaling factor set to %d", mCfgR.screenshotScaleFactor);
364 } else if (key == 'y' || key == 'T') {
365 if (mAnimateVectors[0].size() > 1) {
366 if ((mAnimateScreenshot = (key == 'T'))) {
367 mAnimationExport++;
368 }
369 startAnimation();
370 SetInfo("Starting Animation", 1);
371 } else {
372 SetInfo("Insufficient Animation points to start Animation", 1);
373 }
374 } else if (key == '>') {
375 mAnimationChangeConfig ^= 1;
376 SetInfo("Interpolating visualization settings during Animation %s", mAnimationChangeConfig ? "enabled" : "disabled");
377 } else if (key == 'Y') {
378 setAnimationPoint();
379 SetInfo("Added Animation point (%d points, %6.2f seconds)", (int32_t)mAnimateVectors[0].size(), mAnimateVectors[0].back());
380 } else if (key == 'X') {
381 resetAnimation();
382 SetInfo("Reset Animation points", 1);
383 } else if (key == '\'') {
384 removeAnimationPoint();
385 SetInfo("Removed Animation point", 1);
386 } else if (key == 'M') {
387 mCfgL.animationMode++;
388 if (mCfgL.animationMode == 7) {
389 mCfgL.animationMode = 0;
390 }
391 resetAnimation();
392 if (mCfgL.animationMode == 6) {
393 SetInfo("Animation mode %d - Centered on origin", mCfgL.animationMode);
394 } else {
395 SetInfo("Animation mode %d - Position: %s, Direction: %s", mCfgL.animationMode, (mCfgL.animationMode & 2) ? "Spherical (spherical rotation)" : (mCfgL.animationMode & 4) ? "Spherical (Euler angles)" : "Cartesian", (mCfgL.animationMode & 1) ? "Euler angles" : "Quaternion");
396 }
397 } else if (key == 'u') {
398 mCfgH.trackFilter = (mCfgH.trackFilter + 1) % (mConfig.filterMacros.size() + 1);
399 mUpdateTrackFilter = true;
400 SetInfo("Track filter: %s", mCfgH.trackFilter == 0 ? "None" : mConfig.filterMacros[mCfgH.trackFilter - 1].c_str());
401 } else if (key == 'o') {
402 FILE* ftmp = fopen("glpos.tmp", "w+b");
403 if (ftmp) {
404 int32_t retval = fwrite(&mViewMatrix, sizeof(mViewMatrix), 1, ftmp);
405 if (retval != 1) {
406 GPUError("Error writing position to file");
407 } else {
408 GPUInfo("Position stored to file");
409 }
410 fclose(ftmp);
411 } else {
412 GPUError("Error opening file");
413 }
414 SetInfo("Camera position stored to file", 1);
415 } else if (key == 'p') {
416 FILE* ftmp = fopen("glpos.tmp", "rb");
417 if (ftmp) {
418 int32_t retval = fread(&mViewMatrix, 1, sizeof(mViewMatrix), ftmp);
419 if (retval == sizeof(mViewMatrix)) {
420 GPUInfo("Position read from file");
421 } else {
422 GPUError("Error reading position from file");
423 }
424 fclose(ftmp);
425 } else {
426 GPUError("Error opening file");
427 }
428 SetInfo("Camera position loaded from file", 1);
429 } else if (key == 'O') {
430 FILE* ftmp = fopen("glanimation.tmp", "w+b");
431 if (ftmp) {
432 fwrite(&mCfgL, sizeof(mCfgL), 1, ftmp);
433 int32_t size = mAnimateVectors[0].size();
434 fwrite(&size, sizeof(size), 1, ftmp);
435 for (int32_t i = 0; i < 9; i++) {
436 fwrite(mAnimateVectors[i].data(), sizeof(mAnimateVectors[i][0]), size, ftmp);
437 }
438 fwrite(mAnimateConfig.data(), sizeof(mAnimateConfig[0]), size, ftmp);
439 fclose(ftmp);
440 } else {
441 GPUError("Error opening file");
442 }
443 SetInfo("Animation path stored to file %s", "glanimation.tmp");
444 } else if (key == 'P') {
445 FILE* ftmp = fopen("glanimation.tmp", "rb");
446 if (ftmp) {
447 int32_t retval = fread(&mCfgL, sizeof(mCfgL), 1, ftmp);
448 int32_t size;
449 retval += fread(&size, sizeof(size), 1, ftmp);
450 for (int32_t i = 0; i < 9; i++) {
451 mAnimateVectors[i].resize(size);
452 retval += fread(mAnimateVectors[i].data(), sizeof(mAnimateVectors[i][0]), size, ftmp);
453 }
454 mAnimateConfig.resize(size);
455 retval += fread(mAnimateConfig.data(), sizeof(mAnimateConfig[0]), size, ftmp);
456 (void)retval; // disable unused warning
457 fclose(ftmp);
458 updateConfig();
459 } else {
460 GPUError("Error opening file");
461 }
462 SetInfo("Animation path loaded from file %s", "glanimation.tmp");
463 } else if (key == 'h') {
464 if (mPrintInfoTextAlways) {
465 mPrintInfoTextAlways = false;
466 SetInfo("Showing help text disabled", 1);
467 } else if (mInfoHelpTimer.IsRunning()) {
468 mPrintInfoTextAlways = true;
469 mInfoHelpTimer.Reset();
470 SetInfo("Showing help text until disabled", 1);
471 } else {
472 PrintHelp();
473 SetInfo("Showing help text", 1);
474 }
475 } else if (key == 'q') {
476 if (mFrontend->isGUIRunning()) {
477 SetInfo("Stopping GUI", 1);
478 mFrontend->stopGUI();
479 } else {
480 SetInfo("Starting GUI", 1);
481 mFrontend->startGUI();
482 }
483 }
484 /*
485 else if (key == '^')
486 {
487 mTestSetting++;
488 SetInfo("Debug test variable set to %d", mTestSetting);
489 }
490 */
491
492 if (memcmp((void*)&oldCfgH, (void*)&mCfgH, sizeof(mCfgH)) != 0) {
493 mUpdateEventData = true;
494 }
495 if (memcmp((void*)&oldCfgL, (void*)&mCfgL, sizeof(mCfgL)) != 0 || memcmp((void*)&oldCfgR, (void*)&mCfgR, sizeof(mCfgR)) != 0) {
496 mUpdateDrawCommands = true;
497 }
498 if (oldCfgR.drawQualityMSAA != mCfgR.drawQualityMSAA || oldCfgR.drawQualityDownsampleFSAA != mCfgR.drawQualityDownsampleFSAA || oldCfgL.depthBuffer != mCfgL.depthBuffer || oldCfgR.screenshotScaleFactor != mCfgR.screenshotScaleFactor) {
499 mUpdateRenderPipeline = true;
500 }
501
502 if (oldCfgR.drawQualityVSync != mCfgR.drawQualityVSync) {
503 mFrontend->SetVSync(mCfgR.drawQualityVSync);
504 mBackend->SetVSync(mCfgR.drawQualityVSync);
505 }
506 if (oldCfgR.fullScreen != mCfgR.fullScreen) {
507 mFrontend->SwitchFullscreen(mCfgR.fullScreen);
508 }
509 if (oldCfgR.maximized != mCfgR.maximized) {
510 mFrontend->ToggleMaximized(mCfgR.maximized);
511 }
512 if (oldCfgR.maxFPSRate != mCfgR.maxFPSRate) {
513 mFrontend->mMaxFPSRate = mCfgR.maxFPSRate;
514 }
515 if (oldCfgR.useGLIndirectDraw != mCfgR.useGLIndirectDraw) {
516 mUpdateEventData = true;
517 }
518}
519
521{
522 // GPUError("key %d '%c'", key, (char) key);
523
524 bool shifted = key >= 'A' && key <= 'Z';
525 int32_t press = key;
526 if (press >= 'a' && press <= 'z') {
527 press += 'A' - 'a';
528 }
529 bool oldShift = mFrontend->mKeysShift[press];
530 mFrontend->mKeysShift[press] = shifted;
531 HandleKey(key);
532 mFrontend->mKeysShift[press] = oldShift;
533}
534
535void GPUDisplay::PrintGLHelpText(float colorValue)
536{
537 for (uint32_t i = 0; i < sizeof(HelpText) / sizeof(HelpText[0]); i++) {
538 OpenGLPrint(HelpText[i], 40.f, 35 + std::max(20, mDrawTextFontSize + 4) * (1 + i), colorValue, colorValue, colorValue, mInfoHelpTimer.GetCurrentElapsedTime() >= 5 ? (6 - mInfoHelpTimer.GetCurrentElapsedTime()) : 1, false);
539 }
540}
int32_t i
const char * HelpText[]
StringRef key
void Reset()
Definition timer.cxx:101
double GetCurrentElapsedTime(bool reset=false)
Definition timer.cxx:110
int32_t IsRunning()
Definition timer.h:33
void ResetStart()
Definition timer.cxx:63
static constexpr int32_t KEY_F2
static constexpr int32_t KEY_ALT
static constexpr int32_t KEY_F12
static constexpr int32_t KEY_F4
virtual void ToggleMaximized(bool set)=0
static constexpr int32_t KEY_ENTER
static constexpr int32_t KEY_CTRL
static constexpr int32_t KEY_F1
static constexpr int32_t KEY_F3
virtual void SetVSync(bool enable)=0
virtual void SwitchFullscreen(bool set)=0
static constexpr int32_t KEY_ESCAPE
void HandleKey(uint8_t key)
void HandleSendKey(int32_t key)
GPUDisplayBackend * backend() const
Definition GPUDisplay.h:66
GLsizeiptr size
Definition glcorearb.h:659
GLboolean * data
Definition glcorearb.h:298
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)