Index: samples/simplegl/web/gl_driver.dart |
diff --git a/samples/simplegl/web/gl_driver.dart b/samples/simplegl/web/gl_driver.dart |
index 9c7f922f12da22ea3caba8de96f39e7b7d73c6aa..d04dd1dcabf037448e660c21b8f97f5d69eb11c3 100644 |
--- a/samples/simplegl/web/gl_driver.dart |
+++ b/samples/simplegl/web/gl_driver.dart |
@@ -2,29 +2,37 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
+library gl_driver; |
+ |
import 'dart:html'; |
-import 'gl_html.dart'; |
-import 'simplegl.dart'; |
+import 'gl.dart'; |
/** |
* A driver to run GL applications in the browser. |
*/ |
-void main() { |
+void glMain(setup, resize, draw) { |
// Setup a Canvas for GL to run inside. |
- final canvas = new CanvasElement(width: 480, height: 800); |
+ final canvas = new CanvasElement(width: window.innerWidth, height: window.innerHeight); |
document.body.nodes.add(canvas); |
- final context = |
- new HtmlGlContext(canvas.getContext('experimental-webgl')); |
+ |
+ gl = canvas.getContext('experimental-webgl'); |
// The first 'setup' entry point is called once. |
- setup(context); |
+ setup(); |
+ resize(canvas.width, canvas.height); |
// The second 'render' entry point is called each time the canvas should |
// be re-drawn. |
var render; |
render = (n) { |
- draw(context); |
+ draw(); |
window.requestAnimationFrame(render); |
}; |
- render(context); |
+ render(0); |
+ |
+ window.on.resize.add((e) { |
+ canvas.width = window.innerWidth; |
+ canvas.height = window.innerHeight; |
+ resize(canvas.width, canvas.height); |
+ }); |
} |