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

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
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) native "GLUnifor m3f";
vsm 2012/11/30 17:00:30 nit: a few too long lines here.
gram 2012/11/30 18:01:31 Done.
42 void glUniform4f(int location, double v0, double v1, double v2, double v3) nativ e "GLUniform4f";
43 void glUniform1i(int location, int v0) native "GLUniform1i";
44 void glUniform2i(int location, int v0, int v1) native "GLUniform2i";
45 void glUniform3i(int location, int v0, int v1, int v2) native "GLUniform3i";
46 void glUniform4i(int location, int v0, int v1, int v2, int v3) native "GLUniform 4i";
vsm 2012/11/30 17:00:30 ditto
gram 2012/11/30 18:01:31 Done.
47 void glUniform1fv(int location, List values) native "GLUniform1fv";
48 void glUniform2fv(int location, List values) native "GLUniform2fv";
49 void glUniform3fv(int location, List values) native "GLUniform3fv";
50 void glUniform4fv(int location, List values) native "GLUniform4fv";
51 void glUniform1iv(int location, List values) native "GLUniform1iv";
52 void glUniform2iv(int location, List values) native "GLUniform2iv";
53 void glUniform3iv(int location, List values) native "GLUniform3iv";
54 void glUniform4iv(int location, List values) native "GLUniform4iv";
55 void glUseProgram(int program) native "GLUseProgram";
56 void glVertexAttribPointer(int index, int size, int type, bool normalized,
57 int stride, int pointer) native "GLVertexAttribPointer";
58 void glViewport(int x, int y, int width, int height) native "GLViewport";
59
60 int glArrayBuffer() native "GLArrayBuffer";
61 int glColorBufferBit() native "GLColorBufferBit";
62 int glCompileStatus() native "GLCompileStatus";
63 int glDepthBufferBit() native "GLDepthBufferBit";
64 int glFloat() native "GLFloat";
65 int glFragmentShader() native "GLFragmentShader";
66 int glLinkStatus() native "GLLinkStatus";
67 int glStaticDraw() native "GLStaticDraw";
68 int glTriangleStrip() native "GLTriangleStrip";
69 int glTriangles() native "GLTriangles";
70 int glTrue() native "GLTrue";
71 int glVertexShader() native "GLVertexShader";
72
73 String glGetShaderInfoLog(int shader) native "GLGetShaderInfoLog";
74 String glGetProgramInfoLog(int program) native "GLGetProgramInfoLog";
75
76 class WebGLRenderingContext {
77 WebGLRenderingContext();
78
79 static get ARRAY_BUFFER => glArrayBuffer();
80 static get COLOR_BUFFER_BIT => glColorBufferBit();
81 static get COMPILE_STATUS => glCompileStatus();
82 static get DEPTH_BUFFER_BIT => glDepthBufferBit();
83 static get FLOAT => glFloat();
84 static get FRAGMENT_SHADER => glFragmentShader();
85 static get LINK_STATUS => glLinkStatus();
86 static get VERTEX_SHADER => glVertexShader();
87 static get STATIC_DRAW => glStaticDraw();
88 static get TRUE => glTrue();
89 static get TRIANGLE_STRIP => glTriangleStrip();
90 static get TRIANGLES => glTriangles();
91
92 attachShader(program, shader) => glAttachShader(program, shader);
93 bindBuffer(target, buffer) => glBindBuffer(target, buffer);
94 bufferData(target, data, usage) => glBufferData(target, data, usage);
95 clearColor(r, g, b, alpha) => glClearColor(r, g, b, alpha);
96 clearDepth(depth) => glClearDepth(depth);
97 clear(mask) => glClear(mask);
98 compileShader(shader) => glCompileShader(shader);
99 createBuffer() => glCreateBuffer();
100 createProgram() => glCreateProgram();
101 createShader(shaderType) => glCreateShader(shaderType);
102 drawArrays(mode, first, count) => glDrawArrays(mode, first, count);
103 enableVertexAttribArray(index) => glEnableVertexAttribArray(index);
104 getAttribLocation(program, name) => glGetAttribLocation(program, name);
105 getError() => glGetError();
106 getProgramParameter(program, name) => glGetProgramParameter(program, name);
107 getShaderParameter(shader, name) => glGetShaderParameter(shader, name);
108 getUniformLocation(program, name) => glGetUniformLocation(program, name);
109 linkProgram(program) => glLinkProgram(program);
110 shaderSource(shader, source) => glShaderSource(shader, source);
111 uniform1f(location, v0) => glUniform1f(location, v0);
112 uniform2f(location, v0, v1) => glUniform2f(location, v0, v1);
113 uniform3f(location, v0, v1, v2) => glUniform3f(location, v0, v1, v2);
114 uniform4f(location, v0, v1, v2, v3) => glUniform4f(location, v0, v1, v2, v3);
115 uniform1i(location, v0) => glUniform1i(location, v0);
116 uniform2i(location, v0, v1) => glUniform2i(location, v0, v1);
117 uniform3i(location, v0, v1, v2) => glUniform3i(location, v0, v1, v2);
118 uniform4i(location, v0, v1, v2, v3) => glUniform4i(location, v0, v1, v2, v3);
119 uniform1fv(location, values) => glUniform1fv(location, values);
120 uniform2fv(location, values) => glUniform2fv(location, values);
121 uniform3fv(location, values) => glUniform3fv(location, values);
122 uniform4fv(location, values) => glUniform4fv(location, values);
123 uniform1iv(location, values) => glUniform1iv(location, values);
124 uniform2iv(location, values) => glUniform2iv(location, values);
125 uniform3iv(location, values) => glUniform3iv(location, values);
126 uniform4iv(location, values) => glUniform4iv(location, values);
127 useProgram(program) => glUseProgram(program);
128 vertexAttribPointer(index, size, type, normalized, stride, pointer) =>
129 glVertexAttribPointer(index, size, type, normalized, stride, pointer);
130 viewport(x, y, width, height) => glViewport(x, y, width, height);
131 getShaderInfoLog(shader) => glGetShaderInfoLog(shader);
132 getProgramInfoLog(program) => glGetProgramInfoLog(program);
133
134 // TODO(vsm): Kill.
135 noSuchMethod(invocation) {
136 throw new Exception('Unimplemented ${invocation.memberName}');
137 }
138 }
139
140 var gl = new WebGLRenderingContext();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698