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

Unified Diff: samples/android/assets/dart/gl.dart

Issue 11362103: Rotating spheres sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More cleanup Created 8 years, 1 month 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/android/ant.properties ('k') | samples/android/assets/dart/simplegl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/android/assets/dart/gl.dart
diff --git a/samples/android/assets/dart/gl.dart b/samples/android/assets/dart/gl.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4be707db82060201ccd38eb25a6b2284613ac4df
--- /dev/null
+++ b/samples/android/assets/dart/gl.dart
@@ -0,0 +1,95 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library("android_extension");
+
+#import("dart-ext:android_extension");
+
+// The simplest way to call native code: top-level functions.
+int systemRand() native "SystemRand";
+void systemSrand(int seed) native "SystemSrand";
+
+
+// GL functions.
+void glAttachShader(int program, int shader) native "GLAttachShader";
+void glBindBuffer(int target, int buffer) native "GLBindBuffer";
+void glBufferData(int target, List data, int usage) native "GLBufferData";
+void glClearColor(num r, num g, num b, num alpha) native "GLClearColor";
+void glClearDepth(num depth) native "GLClearDepth";
+void glClear(int mask) native "GLClear";
+void glCompileShader(int shader) native "GLCompileShader";
+int glCreateBuffer() native "GLCreateBuffer";
+int glCreateProgram() native "GLCreateProgram";
+int glCreateShader(int shaderType) native "GLCreateShader";
+void glDrawArrays(int mode, int first, int count) native "GLDrawArrays";
+void glEnableVertexAttribArray(int index) native "GLEnableVertexAttribArray";
+int glGetAttribLocation(int program, String name) native "GLGetAttribLocation";
+int glGetError() native "GLGetError";
+int glGetProgramParameter(int program, int param) native "GLGetProgramParameter";
+int glGetShaderParameter(int shader, int param) native "GLGetShaderParameter";
+int glGetUniformLocation(int program, String name) native "GLGetUniformLocation";
+void glLinkProgram(int program) native "GLLinkProgram";
+void glShaderSource(int shader, String source) native "GLShaderSource";
+void glUniform3f(int location, num v0, num v1, num v2) native "GLUniform3f";
+void glUseProgram(int program) native "GLUseProgram";
+void glVertexAttribPointer(int index, int size, int type, bool normalized, int stride, int pointer) native "GLVertexAttribPointer";
+void glViewport(int x, int y, int width, int height) native "GLViewport";
+
+int glArrayBuffer() native "GLArrayBuffer";
+int glColorBufferBit() native "GLColorBufferBit";
+int glCompileStatus() native "GLCompileStatus";
+int glDepthBufferBit() native "GLDepthBufferBit";
+int glFloat() native "GLFloat";
+int glFragmentShader() native "GLFragmentShader";
+int glLinkStatus() native "GLLinkStatus";
+int glStaticDraw() native "GLStaticDraw";
+int glTriangleStrip() native "GLTriangleStrip";
+int glTrue() native "GLTrue";
+int glVertexShader() native "GLVertexShader";
+
+class WebGLRenderingContext {
+ WebGLRenderingContext();
+
+ static get ARRAY_BUFFER => glArrayBuffer();
+ static get COLOR_BUFFER_BIT => glColorBufferBit();
+ static get COMPILE_STATUS => glCompileStatus();
+ static get DEPTH_BUFFER_BIT => glDepthBufferBit();
+ static get FLOAT => glFloat();
+ static get FRAGMENT_SHADER => glFragmentShader();
+ static get LINK_STATUS => glLinkStatus();
+ static get VERTEX_SHADER => glVertexShader();
+ static get STATIC_DRAW => glStaticDraw();
+ static get TRUE => glTrue();
+ static get TRIANGLE_STRIP => glTriangleStrip();
+
+ attachShader(program, shader) => glAttachShader(program, shader);
+ bindBuffer(target, buffer) => glBindBuffer(target, buffer);
+ bufferData(target, data, usage) => glBufferData(target, data, usage);
+ clearColor(r, g, b, alpha) => glClearColor(r, g, b, alpha);
+ clearDepth(depth) => glClearDepth(depth);
+ clear(mask) => glClear(mask);
+ compileShader(shader) => glCompileShader(shader);
+ createBuffer() => glCreateBuffer();
+ createProgram() => glCreateProgram();
+ createShader(shaderType) => glCreateShader(shaderType);
+ drawArrays(mode, first, count) => glDrawArrays(mode, first, count);
+ enableVertexAttribArray(index) => glEnableVertexAttribArray(index);
+ getAttribLocation(program, name) => glGetAttribLocation(program, name);
+ getError() => glGetError();
+ getProgramParameter(program, name) => glGetProgramParameter(program, name);
+ getShaderParameter(shader, name) => glGetShaderParameter(shader, name);
+ getUniformLocation(program, name) => glGetUniformLocation(program, name);
+ linkProgram(program) => glLinkProgram(program);
+ shaderSource(shader, source) => glShaderSource(shader, source);
+ uniform3f(location, v0, v1, v2) => glUniform3f(location, v0, v1, v2);
+ useProgram(program) => glUseProgram(program);
+ vertexAttribPointer(index, size, type, normalized, stride, pointer) =>
+ glVertexAttribPointer(index, size, type, normalized, stride, pointer);
+ viewport(x, y, width, height) => glViewport(x, y, width, height);
+
+ // TODO(vsm): Kill.
+ noSuchMethod(method, args) { throw new Exception('Unimplemented $method'); }
+}
+
+var gl = new WebGLRenderingContext();
« no previous file with comments | « samples/android/ant.properties ('k') | samples/android/assets/dart/simplegl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698