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

Side by Side 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 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/ant.properties ('k') | samples/android/assets/dart/simplegl.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
13
14 // GL functions.
15 void glAttachShader(int program, int shader) native "GLAttachShader";
16 void glBindBuffer(int target, int buffer) native "GLBindBuffer";
17 void glBufferData(int target, List data, int usage) native "GLBufferData";
18 void glClearColor(num r, num g, num b, num alpha) native "GLClearColor";
19 void glClearDepth(num depth) native "GLClearDepth";
20 void glClear(int mask) native "GLClear";
21 void glCompileShader(int shader) native "GLCompileShader";
22 int glCreateBuffer() native "GLCreateBuffer";
23 int glCreateProgram() native "GLCreateProgram";
24 int glCreateShader(int shaderType) native "GLCreateShader";
25 void glDrawArrays(int mode, int first, int count) native "GLDrawArrays";
26 void glEnableVertexAttribArray(int index) native "GLEnableVertexAttribArray";
27 int glGetAttribLocation(int program, String name) native "GLGetAttribLocation";
28 int glGetError() native "GLGetError";
29 int glGetProgramParameter(int program, int param) native "GLGetProgramParameter" ;
30 int glGetShaderParameter(int shader, int param) native "GLGetShaderParameter";
31 int glGetUniformLocation(int program, String name) native "GLGetUniformLocation" ;
32 void glLinkProgram(int program) native "GLLinkProgram";
33 void glShaderSource(int shader, String source) native "GLShaderSource";
34 void glUniform3f(int location, num v0, num v1, num v2) native "GLUniform3f";
35 void glUseProgram(int program) native "GLUseProgram";
36 void glVertexAttribPointer(int index, int size, int type, bool normalized, int s tride, int pointer) native "GLVertexAttribPointer";
37 void glViewport(int x, int y, int width, int height) native "GLViewport";
38
39 int glArrayBuffer() native "GLArrayBuffer";
40 int glColorBufferBit() native "GLColorBufferBit";
41 int glCompileStatus() native "GLCompileStatus";
42 int glDepthBufferBit() native "GLDepthBufferBit";
43 int glFloat() native "GLFloat";
44 int glFragmentShader() native "GLFragmentShader";
45 int glLinkStatus() native "GLLinkStatus";
46 int glStaticDraw() native "GLStaticDraw";
47 int glTriangleStrip() native "GLTriangleStrip";
48 int glTrue() native "GLTrue";
49 int glVertexShader() native "GLVertexShader";
50
51 class WebGLRenderingContext {
52 WebGLRenderingContext();
53
54 static get ARRAY_BUFFER => glArrayBuffer();
55 static get COLOR_BUFFER_BIT => glColorBufferBit();
56 static get COMPILE_STATUS => glCompileStatus();
57 static get DEPTH_BUFFER_BIT => glDepthBufferBit();
58 static get FLOAT => glFloat();
59 static get FRAGMENT_SHADER => glFragmentShader();
60 static get LINK_STATUS => glLinkStatus();
61 static get VERTEX_SHADER => glVertexShader();
62 static get STATIC_DRAW => glStaticDraw();
63 static get TRUE => glTrue();
64 static get TRIANGLE_STRIP => glTriangleStrip();
65
66 attachShader(program, shader) => glAttachShader(program, shader);
67 bindBuffer(target, buffer) => glBindBuffer(target, buffer);
68 bufferData(target, data, usage) => glBufferData(target, data, usage);
69 clearColor(r, g, b, alpha) => glClearColor(r, g, b, alpha);
70 clearDepth(depth) => glClearDepth(depth);
71 clear(mask) => glClear(mask);
72 compileShader(shader) => glCompileShader(shader);
73 createBuffer() => glCreateBuffer();
74 createProgram() => glCreateProgram();
75 createShader(shaderType) => glCreateShader(shaderType);
76 drawArrays(mode, first, count) => glDrawArrays(mode, first, count);
77 enableVertexAttribArray(index) => glEnableVertexAttribArray(index);
78 getAttribLocation(program, name) => glGetAttribLocation(program, name);
79 getError() => glGetError();
80 getProgramParameter(program, name) => glGetProgramParameter(program, name);
81 getShaderParameter(shader, name) => glGetShaderParameter(shader, name);
82 getUniformLocation(program, name) => glGetUniformLocation(program, name);
83 linkProgram(program) => glLinkProgram(program);
84 shaderSource(shader, source) => glShaderSource(shader, source);
85 uniform3f(location, v0, v1, v2) => glUniform3f(location, v0, v1, v2);
86 useProgram(program) => glUseProgram(program);
87 vertexAttribPointer(index, size, type, normalized, stride, pointer) =>
88 glVertexAttribPointer(index, size, type, normalized, stride, pointer);
89 viewport(x, y, width, height) => glViewport(x, y, width, height);
90
91 // TODO(vsm): Kill.
92 noSuchMethod(method, args) { throw new Exception('Unimplemented $method'); }
93 }
94
95 var gl = new WebGLRenderingContext();
OLDNEW
« 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