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 /** | 5 /** |
6 * A sample GL application. | 6 * A sample GL application. |
7 */ | 7 */ |
8 library simplegl; | 8 library flashingbox; |
9 | 9 |
10 import 'gl.dart'; | 10 import 'gl.dart'; |
11 | 11 |
12 num r; | 12 num r; |
13 num g; | 13 num g; |
14 num b; | 14 num b; |
15 | 15 |
16 /** | 16 /** |
17 * Invoked on initial startup. | 17 * Invoked on initial startup. |
18 */ | 18 */ |
19 void setup(GlContext gl) { | 19 void setup() { |
20 r = 0; | 20 r = 0; |
21 g = 0; | 21 g = 0; |
22 b = 0; | 22 b = 0; |
23 } | 23 } |
24 | 24 |
| 25 void resize(int width, int height) { |
| 26 gl.viewport(0, 0, width, height); |
| 27 } |
| 28 |
25 /** | 29 /** |
26 * Invoked on each frame render. | 30 * Invoked on each frame render. |
27 */ | 31 */ |
28 void draw(GlContext gl) { | 32 void draw() { |
29 gl.clearColor(r, g, b, 1.0); | 33 gl.clearColor(r, g, b, 1.0); |
30 gl.clear(gl.COLOR_BUFFER_BIT | | 34 gl.clear(WebGLRenderingContext.COLOR_BUFFER_BIT | |
31 gl.DEPTH_BUFFER_BIT); | 35 WebGLRenderingContext.DEPTH_BUFFER_BIT); |
32 r = r + 0.1; | 36 r = r + 0.1; |
33 if (r > 1) { | 37 if (r > 1) { |
34 r = 0; | 38 r = 0; |
35 g = g + 0.1; | 39 g = g + 0.1; |
36 } | 40 } |
37 if (g > 1) { | 41 if (g > 1) { |
38 g = 0; | 42 g = 0; |
39 b = b + 0.1; | 43 b = b + 0.1; |
40 } | 44 } |
41 if (b > 1) { | 45 if (b > 1) { |
42 b = 0; | 46 b = 0; |
43 } | 47 } |
44 } | 48 } |
OLD | NEW |