diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-28 01:28:22 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-28 01:28:22 +0000 |
commit | f21b7281948a5d3c9899c72c81a6c0a6a37d59df (patch) | |
tree | 9ad8981afcab0692b3658269bc1cf3b98ceadc24 /o3d/samples/o3djs/webgl.js | |
parent | db5291012d45956754c57e263c58b79845185302 (diff) | |
download | chromium_src-f21b7281948a5d3c9899c72c81a6c0a6a37d59df.zip chromium_src-f21b7281948a5d3c9899c72c81a6c0a6a37d59df.tar.gz chromium_src-f21b7281948a5d3c9899c72c81a6c0a6a37d59df.tar.bz2 |
Thanks to gman, fixed o3d.webgl.createClient and o3d-webgl Client to handle
resizing of div containing O3D element. Added simpleviewer sample.
BUG=none
TEST=ran simpleviewer sample
Review URL: http://codereview.chromium.org/1798006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3djs/webgl.js')
-rw-r--r-- | o3d/samples/o3djs/webgl.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/o3d/samples/o3djs/webgl.js b/o3d/samples/o3djs/webgl.js index 3f4c1f5..9687af6 100644 --- a/o3d/samples/o3djs/webgl.js +++ b/o3d/samples/o3djs/webgl.js @@ -143,10 +143,20 @@ o3djs.webgl.createClient = function(element, opt_features, opt_debug) { // 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); |