static WebTransformationMatrix orthoProjectionMatrix(float left, float right, float bottom, float top) { // Use the standard formula to map the clipping frustum to the cube from // [-1, -1, -1] to [1, 1, 1]. float deltaX = right - left; float deltaY = top - bottom; WebTransformationMatrix proj; if (!deltaX || !deltaY) return proj; proj.setM11(2.0f / deltaX); proj.setM41(-(right + left) / deltaX); proj.setM22(2.0f / deltaY); proj.setM42(-(top + bottom) / deltaY); // Z component of vertices is always set to zero as we don't use the depth buffer // while drawing. proj.setM33(0); return proj; }