Permalink
Browse files

rendering with js

  • Loading branch information...
1 parent 0fd53ab commit 2b995ecb1bff119096778a65c0d39ade9635a548 @tmpvar committed Aug 21, 2011
Showing with 8 additions and 7 deletions.
  1. +6 −5 example/triangle.js
  2. +2 −2 src/js/spidermonkey.cc
View
11 example/triangle.js
@@ -41,23 +41,24 @@ if (!ctx.getProgramParameter(program, ctx.LINK_STATUS)) {
fail();
}
-e('use program', ctx.useProgram(program));
-var attr = e('attribute location', ctx.getAttribLocation(program, "pos"));
-var vertexBuffer = e('create buffer', ctx.createBuffer());
+var attr = e('attribute location', ctx.getAttribLocation(program, "pos"));
+var vertexBuffer = e('create buffer', ctx.createBuffer());
e('bind buffer', ctx.bindBuffer(ctx.ARRAY_BUFFER, vertexBuffer));
e('buffer data', ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(vertices), ctx.STATIC_DRAW));
+
e('viewport', ctx.viewport(0, 0, 300, 300));
+e('use program', ctx.useProgram(program));
+e('enable vertex attrib array', ctx.enableVertexAttribArray(attr));
-var a = 1;
+var a = 10000;
while(a--) {
e('clear color', ctx.clearColor(0.5, 0.5, 0.5, 1));
e('clear', ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT));
e('bind buffer', ctx.bindBuffer(ctx.ARRAY_BUFFER, vertexBuffer));
- e('enable vertex attrib array', ctx.enableVertexAttribArray(attr));
e('vertex pointer', ctx.vertexAttribPointer(attr, 3, ctx.FLOAT, false, 0, 0));
e('draw arrays', ctx.drawArrays(ctx.TRIANGLES, 0, 3));
e('flush', ctx.flush());
View
4 src/js/spidermonkey.cc
@@ -899,15 +899,15 @@ JSBool webgl_rendering_context_vertexAttribPointer(JSContext *cx, uintN argc, js
GLuint attr;
GLint size;
unsigned int type;
- GLboolean normalized;
+ bool normalized;
GLsizei stride;
int offset;
if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, argv), "iiibii", &attr, &size, &type, &normalized, &stride, &offset)) {
return JS_FALSE;
}
- glVertexAttribPointer(attr, size, type, normalized, stride, (void *)&offset);
+ glVertexAttribPointer(attr, size, type, normalized, stride, (void *)offset);
return JS_TRUE;
}

0 comments on commit 2b995ec

Please sign in to comment.