我有画布调整大小和gl.viewport同步的问题.
假设我从画布300x300画布开始,并gl.viewport以相同尺寸(gl.vieport(0, 0, 300, 300))初始化.
之后,在浏览器的控制台中,我进行了测试:
我正在改变画布的大小,使用jquery,调用类似的东西$("#scene").width(200).height(200)
function resizeWindow(width, height){
var ww = width === undefined? w.gl.viewportWidth : width;
var h = height === undefined? w.gl.viewportHeight : height;
h = h <= 0? 1 : h;
w.gl.viewport(0, 0, ww, h);
mat4.identity(projectionMatrix);
mat4.perspective(45, ww / h, 1, 1000.0, projectionMatrix);
mat4.identity(modelViewMatrix);
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我的gl.viewport这个电话只占了我画布的一部分.
谁能告诉我出了什么问题?