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

Unified Diff: samples/simplegl/web/gl_driver.dart

Issue 11362256: Added raytracer to gl samples. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 8 years, 1 month 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/simplegl/web/gl.dart ('k') | samples/simplegl/web/gl_html.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ });
}
« no previous file with comments | « samples/simplegl/web/gl.dart ('k') | samples/simplegl/web/gl_html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698