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

Unified Diff: samples/openglui/src/flashingbox.dart

Issue 13345002: Cleaned up OpenGLUI samples and added Blasteroids. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/openglui/src/blasteroids.dart ('k') | samples/openglui/src/gl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/openglui/src/flashingbox.dart
===================================================================
--- samples/openglui/src/flashingbox.dart (revision 20700)
+++ samples/openglui/src/flashingbox.dart (working copy)
@@ -9,28 +9,30 @@
import 'gl.dart';
+WebGLRenderingContext gl = null;
+
num r;
num g;
num b;
-/**
- * Invoked on initial startup.
- */
-void setup(int width, int height) {
+void setup(canvas, int w, int h, int f) {
+ if (canvas == null) {
+ canvas = new CanvasElement(width: w, height: h);
+ }
+ gl = canvas.getContext("experimental-webgl");
r = 0;
g = 0;
b = 0;
- resize(width, height);
+ resize(w, h);
+ window.requestAnimationFrame(update);
+ log("Done setup");
}
void resize(int width, int height) {
gl.viewport(0, 0, width, height);
}
-/**
- * Invoked on each frame render.
- */
-void draw() {
+void update(when) {
gl.clearColor(r, g, b, 1.0);
gl.clear(WebGLRenderingContext.COLOR_BUFFER_BIT |
WebGLRenderingContext.DEPTH_BUFFER_BIT);
@@ -46,4 +48,7 @@
if (b > 1) {
b = 0;
}
+ glSwapBuffers();
+ window.requestAnimationFrame(update);
}
+
« no previous file with comments | « samples/openglui/src/blasteroids.dart ('k') | samples/openglui/src/gl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698