History

move from examples/ to scripts/developer/

Andrew Meadows committed 10 years ago

Commit 0cc12fd1 parent 582b20273 files · +-2 −-2Browse files

Showing the changes to scripts/developer/utilities/render/debugFramebuffer.js (1 of 73 files). Show all

Unified · Split

scripts/developer/utilities/render/debugFramebuffer.js+51−0
@@ -0,0 +1,51 @@
1//
2// ddebugFramBuffer.js
3// examples/utilities/tools/render
4//
5// Sam Gateau created on 2/18/2016.
6// Copyright 2016 High Fidelity, Inc.
7//
8// Distributed under the Apache License, Version 2.0.
9// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10//
11
12var DDB = Render.RenderDeferredTask.DebugDeferredBuffer;
13oldConfig = DDB.toJSON();
14DDB.enabled = true;
15
16
17// Set up the qml ui
18var qml = Script.resolvePath('framebuffer.qml');
19var window = new OverlayWindow({
20 title: 'Framebuffer Debug',
21 source: qml,
22 width: 400, height: 400,
23});
24window.setPosition(25, 50);
25window.closed.connect(function() { Script.stop(); });
26
27// Debug buffer sizing
28var resizing = false;
29
30Controller.mousePressEvent.connect(function (e) {
31 if (shouldStartResizing(e.x)) {
32 resizing = true;
33 }
34});
35Controller.mouseReleaseEvent.connect(function() { resizing = false; });
36Controller.mouseMoveEvent.connect(function (e) { resizing && setDebugBufferSize(e.x); });
37
38
39function shouldStartResizing(eventX) {
40 var x = Math.abs(eventX - Window.innerWidth * (1.0 + DDB.size.x) / 2.0);
41 var mode = DDB.mode;
42 return mode !== -1 && x < 20;
43}
44
45function setDebugBufferSize(x) {
46 x = (2.0 * (x / Window.innerWidth) - 1.0); // scale
47 x = Math.min(Math.max(-1, x), 1); // clamp
48 DDB.size = { x: x, y: -1, z: 1, w: 1 };
49}
50
51Script.scriptEnding.connect(function () { DDB.fromJSON(oldConfig); });