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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 gl.drawArrays(WebGLRenderingContext.TRIANGLE_STRIP, 0, 4); | 330 gl.drawArrays(WebGLRenderingContext.TRIANGLE_STRIP, 0, 4); |
331 glSwapBuffers(); | 331 glSwapBuffers(); |
332 | 332 |
333 t += 0.03; | 333 t += 0.03; |
334 if (t > Math.PI * 200) { | 334 if (t > Math.PI * 200) { |
335 t -= Math.PI * 200; | 335 t -= Math.PI * 200; |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 void setup(canvas, int w, int h) { | 339 void setup(canvas, int w, int h, int f) { |
340 if (canvas == null) { | 340 if (canvas == null) { |
341 canvas = new CanvasElement(width: w, height: h); | 341 canvas = new CanvasElement(width: w, height: h); |
342 } | 342 } |
343 gl = canvas.getContext("experimental-webgl"); | 343 gl = canvas.getContext("experimental-webgl"); |
344 initShaders(); | 344 initShaders(); |
345 gl.clearColor(0.0, 0.0, 0.0, 1.0); | 345 gl.clearColor(0.0, 0.0, 0.0, 1.0); |
346 gl.clearDepth(1.0); | 346 gl.clearDepth(1.0); |
347 initBuffers(); | 347 initBuffers(); |
348 resize(w, h); | 348 resize(w, h); |
349 window.requestAnimationFrame(update); | 349 window.requestAnimationFrame(update); |
350 log("Done setup"); | 350 log("Done setup"); |
351 } | 351 } |
352 | 352 |
353 void resize(int width, int height) { | 353 void resize(int width, int height) { |
354 gl.viewport(0, 0, width, height); | 354 gl.viewport(0, 0, width, height); |
355 ratio = width / height; | 355 ratio = width / height; |
356 t -= 0.03; | 356 t -= 0.03; |
357 drawScene(); | 357 drawScene(); |
358 } | 358 } |
359 | 359 |
360 void update(when) { | 360 void update(when) { |
361 drawScene(); | 361 drawScene(); |
362 window.requestAnimationFrame(update); | 362 window.requestAnimationFrame(update); |
363 } | 363 } |
364 | 364 |
365 onMotionDown(num when, num x, num y) { | |
366 } | |
367 | |
OLD | NEW |