Showing the changes to scripts/developer/utilities/render/debugFramebuffer.js (1 of 73 files). Show all
Unified · Split
| @@ -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 | + | |
| 12 | +var DDB = Render.RenderDeferredTask.DebugDeferredBuffer; | |
| 13 | +oldConfig = DDB.toJSON(); | |
| 14 | +DDB.enabled = true; | |
| 15 | + | |
| 16 | + | |
| 17 | +// Set up the qml ui | |
| 18 | +var qml = Script.resolvePath('framebuffer.qml'); | |
| 19 | +var window = new OverlayWindow({ | |
| 20 | + title: 'Framebuffer Debug', | |
| 21 | + source: qml, | |
| 22 | + width: 400, height: 400, | |
| 23 | +}); | |
| 24 | +window.setPosition(25, 50); | |
| 25 | +window.closed.connect(function() { Script.stop(); }); | |
| 26 | + | |
| 27 | +// Debug buffer sizing | |
| 28 | +var resizing = false; | |
| 29 | + | |
| 30 | +Controller.mousePressEvent.connect(function (e) { | |
| 31 | + if (shouldStartResizing(e.x)) { | |
| 32 | + resizing = true; | |
| 33 | + } | |
| 34 | +}); | |
| 35 | +Controller.mouseReleaseEvent.connect(function() { resizing = false; }); | |
| 36 | +Controller.mouseMoveEvent.connect(function (e) { resizing && setDebugBufferSize(e.x); }); | |
| 37 | + | |
| 38 | + | |
| 39 | +function 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 | + | |
| 45 | +function 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 | + | |
| 51 | +Script.scriptEnding.connect(function () { DDB.fromJSON(oldConfig); }); | |