Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(988)

Unified Diff: samples/o3djs/webgl.js

Issue 1798006: Thanks to gman, fixed o3d.webgl.createClient and o3d-webgl Client to handle... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/o3d/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/o3d-webgl/client.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « samples/o3d-webgl/client.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698