| Index: samples/o3djs/webgl.js
|
| ===================================================================
|
| --- samples/o3djs/webgl.js (revision 45712)
|
| +++ samples/o3djs/webgl.js (working copy)
|
| @@ -143,10 +143,20 @@
|
| // we set the shader language to glsl.
|
| o3djs.effect.setLanguage('glsl');
|
|
|
| + // Make the canvas automatically resize to fill the containing
|
| + // element (div), and initialize its size correctly.
|
| var canvas;
|
| canvas = document.createElement('canvas');
|
| - canvas.setAttribute('width', element.getAttribute('width'));
|
| - canvas.setAttribute('height', element.getAttribute('height'));
|
| + canvas.style.width = "100%";
|
| + canvas.style.height = "100%";
|
| + var resizeHandler = function() {
|
| + var width = Math.max(1, canvas.clientWidth);
|
| + var height = Math.max(1, canvas.clientHeight);
|
| + canvas.width = width;
|
| + canvas.height = height;
|
| + };
|
| + window.addEventListener('resize', resizeHandler, false);
|
| + setTimeout(resizeHandler, 0);
|
|
|
| var client = new o3d.Client;
|
| client.initWithCanvas(canvas);
|
|
|