我有一个画布大小调整问题和gl.viewport
同步问题。
假设我以相同尺寸(gl.vieport(0, 0, 300, 300)
)开始画布300x300 canvas和初始化gl.viewport
。
之后,在浏览器的控制台,我做我的测试:Webgl gl.viewport更改
I'm changing size of my canvas,使用jQuery,呼吁像
$("#scene").width(200).height(200)
After this, i'm calling my resizeWindow function:
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); }
- 功能多数民众赞成同步视口所需尺寸。
不幸的是,我的gl.viewport
这个电话只需要我的画布的一部分了。
有谁能告诉我哪里出了问题?
对于gl.viewportWidth或gl.viewportHeight,这些参数在初始化gl对象(js feature)之后分配的这些参数很抱歉,所以gl.viewportWidth = canvas.clientWidth和gl.viewportHeight = canvas.clientHeight。 另外,如果这些东西拼错了,它们会被纠正,但是当我尝试手动调用resizeWindow时出现问题,在传输参数的情况下它们应该占优势(见代码)。
对于gl.drawingBufferWidth和gl.drawingBufferHeight非常感谢,它真的帮助我 – jorj 2012-08-08 19:38:53