| OLD | NEW |
| 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 // This sample is based upon the Ray Tracer sample by Jonas Sicking at: | 5 // This sample is based upon the Ray Tracer sample by Jonas Sicking at: |
| 6 // http://www.khronos.org/webgl/wiki/Demo_Repository | 6 // http://www.khronos.org/webgl/wiki/Demo_Repository |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A sample GL application. | 9 * A sample GL application. |
| 10 */ | 10 */ |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 void setup(canvas, int w, int h) { | 338 void setup(canvas, int w, int h) { |
| 339 if (canvas == null) { | 339 if (canvas == null) { |
| 340 canvas = new CanvasElement(width: w, height: h); | 340 canvas = new CanvasElement(width: w, height: h); |
| 341 } | 341 } |
| 342 gl = canvas.getContext("experimental-webgl"); | 342 gl = canvas.getContext("experimental-webgl"); |
| 343 initShaders(); | 343 initShaders(); |
| 344 gl.clearColor(0.0, 0.0, 0.0, 1.0); | 344 gl.clearColor(0.0, 0.0, 0.0, 1.0); |
| 345 gl.clearDepth(1.0); | 345 gl.clearDepth(1.0); |
| 346 initBuffers(); | 346 initBuffers(); |
| 347 resize(w, h); | 347 resize(w, h); |
| 348 requestAnimationFrame(update); |
| 348 log("Done setup"); | 349 log("Done setup"); |
| 349 } | 350 } |
| 350 | 351 |
| 351 void resize(int width, int height) { | 352 void resize(int width, int height) { |
| 352 gl.viewport(0, 0, width, height); | 353 gl.viewport(0, 0, width, height); |
| 353 ratio = width / height; | 354 ratio = width / height; |
| 354 t -= 0.03; | 355 t -= 0.03; |
| 355 drawScene(); | 356 drawScene(); |
| 356 } | 357 } |
| 357 | 358 |
| 358 void update() { | 359 void update(when) { |
| 359 drawScene(); | 360 drawScene(); |
| 361 requestAnimationFrame(update); |
| 360 } | 362 } |
| 361 | 363 |
| 362 onMotionDown(num when, num x, num y) { | 364 onMotionDown(num when, num x, num y) { |
| 363 } | 365 } |
| 364 | 366 |
| OLD | NEW |