Webgl gl.viewport change

Viewed 8319

I have a problem with canvas resizing and gl.viewport sync.
Let's say that I start with both the canvas 300x300 canvas, and the initialization of gl.viewport at the same sizes (gl.vieport(0, 0, 300, 300)).
After that, in browser's console I make my tests:

  1. I'm changing size of my canvas, using jquery, calling something like $("#scene").width(200).height(200)

  2. 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);
    }
    
    • function that's synchronizing viewport with required dimensions.

Unfortunatly, my gl.viewport after this call takes only a part of my canvas.
Could anyone tell me what is going wrong?

1 Answers
Related