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

Side by Side Diff: samples/android_sample/assets/dart/android_extension.dart

Issue 11434046: Android rayshader sample. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/android_sample/android_sample.gyp ('k') | samples/android_sample/assets/dart/main.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library android_extension;
6
7 import "dart-ext:android_extension";
8
9 // The simplest way to call native code: top-level functions.
10 int systemRand() native "SystemRand";
11 void systemSrand(int seed) native "SystemSrand";
12 void log(String what) native "Log";
13
14 // EGL functions.
15 void eglSwapBuffers() native "EGLSwapBuffers";
16
17 // GL functions.
18 void glAttachShader(int program, int shader) native "GLAttachShader";
19 void glBindBuffer(int target, int buffer) native "GLBindBuffer";
20 void glBufferData(int target, List data, int usage) native "GLBufferData";
21 void glClearColor(num r, num g, num b, num alpha) native "GLClearColor";
22 void glClearDepth(num depth) native "GLClearDepth";
23 void glClear(int mask) native "GLClear";
24 void glCompileShader(int shader) native "GLCompileShader";
25 int glCreateBuffer() native "GLCreateBuffer";
26 int glCreateProgram() native "GLCreateProgram";
27 int glCreateShader(int shaderType) native "GLCreateShader";
28 void glDrawArrays(int mode, int first, int count) native "GLDrawArrays";
29 void glEnableVertexAttribArray(int index) native "GLEnableVertexAttribArray";
30 int glGetAttribLocation(int program, String name) native "GLGetAttribLocation";
31 int glGetError() native "GLGetError";
32 int glGetProgramParameter(int program, int param)
33 native "GLGetProgramParameter";
34 int glGetShaderParameter(int shader, int param) native "GLGetShaderParameter";
35 int glGetUniformLocation(int program, String name)
36 native "GLGetUniformLocation";
37 void glLinkProgram(int program) native "GLLinkProgram";
38 void glShaderSource(int shader, String source) native "GLShaderSource";
39 void glUniform1f(int location, double v0) native "GLUniform1f";
40 void glUniform2f(int location, double v0, double v1) native "GLUniform2f";
41 void glUniform3f(int location, double v0, double v1, double v2)
42 native "GLUniform3f";
43 void glUniform4f(int location, double v0, double v1, double v2, double v3)
44 native "GLUniform4f";
45 void glUniform1i(int location, int v0) native "GLUniform1i";
46 void glUniform2i(int location, int v0, int v1) native "GLUniform2i";
47 void glUniform3i(int location, int v0, int v1, int v2) native "GLUniform3i";
48 void glUniform4i(int location, int v0, int v1, int v2, int v3)
49 native "GLUniform4i";
50 void glUniform1fv(int location, List values) native "GLUniform1fv";
51 void glUniform2fv(int location, List values) native "GLUniform2fv";
52 void glUniform3fv(int location, List values) native "GLUniform3fv";
53 void glUniform4fv(int location, List values) native "GLUniform4fv";
54 void glUniform1iv(int location, List values) native "GLUniform1iv";
55 void glUniform2iv(int location, List values) native "GLUniform2iv";
56 void glUniform3iv(int location, List values) native "GLUniform3iv";
57 void glUniform4iv(int location, List values) native "GLUniform4iv";
58 void glUseProgram(int program) native "GLUseProgram";
59 void glVertexAttribPointer(int index, int size, int type, bool normalized,
60 int stride, int pointer) native "GLVertexAttribPointer";
61 void glViewport(int x, int y, int width, int height) native "GLViewport";
62
63 int glArrayBuffer() native "GLArrayBuffer";
64 int glColorBufferBit() native "GLColorBufferBit";
65 int glCompileStatus() native "GLCompileStatus";
66 int glDepthBufferBit() native "GLDepthBufferBit";
67 int glFloat() native "GLFloat";
68 int glFragmentShader() native "GLFragmentShader";
69 int glLinkStatus() native "GLLinkStatus";
70 int glStaticDraw() native "GLStaticDraw";
71 int glTriangleStrip() native "GLTriangleStrip";
72 int glTriangles() native "GLTriangles";
73 int glTrue() native "GLTrue";
74 int glVertexShader() native "GLVertexShader";
75
76 String glGetShaderInfoLog(int shader) native "GLGetShaderInfoLog";
77 String glGetProgramInfoLog(int program) native "GLGetProgramInfoLog";
78
79 class WebGLRenderingContext {
80 WebGLRenderingContext();
81
82 static get ARRAY_BUFFER => glArrayBuffer();
83 static get COLOR_BUFFER_BIT => glColorBufferBit();
84 static get COMPILE_STATUS => glCompileStatus();
85 static get DEPTH_BUFFER_BIT => glDepthBufferBit();
86 static get FLOAT => glFloat();
87 static get FRAGMENT_SHADER => glFragmentShader();
88 static get LINK_STATUS => glLinkStatus();
89 static get VERTEX_SHADER => glVertexShader();
90 static get STATIC_DRAW => glStaticDraw();
91 static get TRUE => glTrue();
92 static get TRIANGLE_STRIP => glTriangleStrip();
93 static get TRIANGLES => glTriangles();
94
95 attachShader(program, shader) => glAttachShader(program, shader);
96 bindBuffer(target, buffer) => glBindBuffer(target, buffer);
97 bufferData(target, data, usage) => glBufferData(target, data, usage);
98 clearColor(r, g, b, alpha) => glClearColor(r, g, b, alpha);
99 clearDepth(depth) => glClearDepth(depth);
100 clear(mask) => glClear(mask);
101 compileShader(shader) => glCompileShader(shader);
102 createBuffer() => glCreateBuffer();
103 createProgram() => glCreateProgram();
104 createShader(shaderType) => glCreateShader(shaderType);
105 drawArrays(mode, first, count) => glDrawArrays(mode, first, count);
106 enableVertexAttribArray(index) => glEnableVertexAttribArray(index);
107 getAttribLocation(program, name) => glGetAttribLocation(program, name);
108 getError() => glGetError();
109 getProgramParameter(program, name) => glGetProgramParameter(program, name);
110 getShaderParameter(shader, name) => glGetShaderParameter(shader, name);
111 getUniformLocation(program, name) => glGetUniformLocation(program, name);
112 linkProgram(program) => glLinkProgram(program);
113 shaderSource(shader, source) => glShaderSource(shader, source);
114 uniform1f(location, v0) => glUniform1f(location, v0);
115 uniform2f(location, v0, v1) => glUniform2f(location, v0, v1);
116 uniform3f(location, v0, v1, v2) => glUniform3f(location, v0, v1, v2);
117 uniform4f(location, v0, v1, v2, v3) => glUniform4f(location, v0, v1, v2, v3);
118 uniform1i(location, v0) => glUniform1i(location, v0);
119 uniform2i(location, v0, v1) => glUniform2i(location, v0, v1);
120 uniform3i(location, v0, v1, v2) => glUniform3i(location, v0, v1, v2);
121 uniform4i(location, v0, v1, v2, v3) => glUniform4i(location, v0, v1, v2, v3);
122 uniform1fv(location, values) => glUniform1fv(location, values);
123 uniform2fv(location, values) => glUniform2fv(location, values);
124 uniform3fv(location, values) => glUniform3fv(location, values);
125 uniform4fv(location, values) => glUniform4fv(location, values);
126 uniform1iv(location, values) => glUniform1iv(location, values);
127 uniform2iv(location, values) => glUniform2iv(location, values);
128 uniform3iv(location, values) => glUniform3iv(location, values);
129 uniform4iv(location, values) => glUniform4iv(location, values);
130 useProgram(program) => glUseProgram(program);
131 vertexAttribPointer(index, size, type, normalized, stride, pointer) =>
132 glVertexAttribPointer(index, size, type, normalized, stride, pointer);
133 viewport(x, y, width, height) => glViewport(x, y, width, height);
134 getShaderInfoLog(shader) => glGetShaderInfoLog(shader);
135 getProgramInfoLog(program) => glGetProgramInfoLog(program);
136
137 // TODO(vsm): Kill.
138 noSuchMethod(invocation) {
139 throw new Exception('Unimplemented ${invocation.memberName}');
140 }
141 }
142
143 var gl = new WebGLRenderingContext();
OLDNEW
« no previous file with comments | « samples/android_sample/android_sample.gyp ('k') | samples/android_sample/assets/dart/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698