[Plot] Use GL-reported buffer size

Use the buffer width/height reported by WebGL when
configuring the viewport to ensure that data aligns
correctly to canvas size when drawn. WTD-852.
This commit is contained in:
Victor Woeltjen 2015-02-09 16:10:20 -08:00
parent 790397ae0f
commit 7c5c96ff1d

View File

@ -96,7 +96,15 @@ define(
* Clear the chart.
*/
clear: function () {
gl.viewport(0, 0, canvas.width, canvas.height);
// Set the viewport size; note that we use the width/height
// that our WebGL context reports, which may be lower
// resolution than the canvas we requested.
gl.viewport(
0,
0,
gl.drawingBufferWidth,
gl.drawingBufferHeight
);
gl.clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT);
},
/**
@ -107,8 +115,11 @@ define(
* origin of the chart
*/
setDimensions: function (dimensions, origin) {
gl.uniform2fv(uDimensions, dimensions);
gl.uniform2fv(uOrigin, origin);
if (dimensions && dimensions.length > 0 &&
origin && origin.length > 0) {
gl.uniform2fv(uDimensions, dimensions);
gl.uniform2fv(uOrigin, origin);
}
},
/**
* Draw the supplied buffer as a line strip (a sequence