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

Side by Side Diff: samples/simplegl/web/gl_driver.dart

Issue 11883013: Refactored OpenGL embedder that works on Android, Mac or Linux. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library gl_driver; 5 library gl_driver;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'gl.dart'; 8 import 'gl.dart';
9 9
10 /** 10 /**
11 * A driver to run GL applications in the browser. 11 * A driver to run GL applications in the browser.
12 */ 12 */
13 void glMain(setup, resize, draw) { 13 void glMain(setup, resize, draw) {
14 // Setup a Canvas for GL to run inside. 14 // Setup a Canvas for GL to run inside.
15 final canvas = new CanvasElement(width: window.innerWidth, height: window.inne rHeight); 15 final canvas = new CanvasElement(width: window.innerWidth, height: window.inne rHeight);
16 document.body.nodes.add(canvas); 16 document.body.nodes.add(canvas);
17 17
18 gl = canvas.getContext('experimental-webgl'); 18 gl = canvas.getContext('experimental-webgl');
19 19
20 // The first 'setup' entry point is called once. 20 // The first 'setup' entry point is called once.
21 setup(); 21 setup(canvas.width, canvas.height);
22 resize(canvas.width, canvas.height);
23 22
24 // The second 'render' entry point is called each time the canvas should 23 // The second 'render' entry point is called each time the canvas should
25 // be re-drawn. 24 // be re-drawn.
26 var render; 25 var render;
27 render = (n) { 26 render = (n) {
28 draw(); 27 draw();
29 window.requestAnimationFrame(render); 28 window.requestAnimationFrame(render);
30 }; 29 };
31 render(0); 30 render(0);
32 31
33 window.on.resize.add((e) { 32 window.on.resize.add((e) {
34 canvas.width = window.innerWidth; 33 canvas.width = window.innerWidth;
35 canvas.height = window.innerHeight; 34 canvas.height = window.innerHeight;
36 resize(canvas.width, canvas.height); 35 resize(canvas.width, canvas.height);
37 }); 36 });
38 } 37 }
OLDNEW
« no previous file with comments | « samples/mobile_emulator_sample/mobile_emulator_sample.gyp ('k') | samples/simplegl/web/raytrace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698