Skip to content

Commit ae8144f

Browse files
committed
move from getParameter to gl buffer height/width
1 parent 23bc248 commit ae8144f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/core/shader.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ var Shader = (function() {
9494

9595
Shader.prototype.drawRect = function(left, top, right, bottom) {
9696
var undefined;
97-
var viewport = gl.getParameter(gl.VIEWPORT);
98-
top = top !== undefined ? (top - viewport[1]) / viewport[3] : 0;
99-
left = left !== undefined ? (left - viewport[0]) / viewport[2] : 0;
100-
right = right !== undefined ? (right - viewport[0]) / viewport[2] : 1;
101-
bottom = bottom !== undefined ? (bottom - viewport[1]) / viewport[3] : 1;
97+
// this is (t/l/r/b - viewport minx/miny/maxx/maxy) / (viewport width/hieght/hieght/width)
98+
// is top/left/right/botom always 0/0/0/0?
99+
top = top !== undefined ? top / gl.drawingBufferHeight : 0;
100+
left = left !== undefined ? left / gl.drawingBufferWidth : 0;
101+
right = right !== undefined ? right / gl.drawingBufferWidth : 1;
102+
bottom = bottom !== undefined ? bottom / gl.drawingBufferWidth : 1;
102103
if (gl.vertexBuffer == null) {
103104
gl.vertexBuffer = gl.createBuffer();
104105
}

0 commit comments

Comments
 (0)