Permalink
Browse files

triangle.js is no longer exploding

  • Loading branch information...
tmpvar committed Aug 20, 2011
1 parent 77915e2 commit 7ab9e66235af4699d155d997eddfdcdd83f5ba92
Showing with 12 additions and 13 deletions.
  1. +4 −5 example/js/main.cc
  2. +7 −7 example/triangle.js
  3. +1 −1 src/js/spidermonkey.cc
View
@@ -359,16 +359,15 @@ int main(int argc, char **argv)
setupGlobals(cx, global);
glutInit(&argc, argv);
+
+ ok = JS_EvaluateScript(cx, global, script, strlen(script),
+ filename, lineno, &rval);
+
glutInitDisplayMode (GLUT_SINGLE);
glutInitWindowSize (500, 500); // Set the width and height of the window
glutInitWindowPosition (100, 100);
glutCreateWindow ("You’re first OpenGL Window");
glutDisplayFunc(render);
-
-
- ok = JS_EvaluateScript(cx, global, script, strlen(script),
- filename, lineno, &rval);
-
glutMainLoop();
delete [] script;
View
@@ -1,7 +1,7 @@
-var WebGLRenderingContext = require('lib/webctx.js');
+var WebGLRenderingContext = require('lib/webgl.js');
var ctx = new WebGLRenderingContext();
-var program = gl->createProgram();
+var program = ctx.createProgram();
var shaders = {
vertex : "attribute vec3 pos;\nvoid main() {\n gl_Position = vec4(pos, 1.0);\n}",
frag : "void main() {\n gl_FragColor = vec4(1.0, 0, 1, 1.0);\n}"
@@ -26,7 +26,7 @@ if (!ctx.getProgramParameter(program, ctx.LINK_STATUS)) {
}
ctx.useProgram(program);
-var attr = glGetAttribLocation(program, "pos");
+var attr = ctx.getAttribLocation(program, "pos");
var vertexBuffer = ctx.createBuffer();
vertexBuffer.itemSize = 3;
@@ -50,12 +50,12 @@ ctx.bindBuffer(ctx.ARRAY_BUFFER, vertexBuffer);
ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(vertexBuffer));
-setInterval(function() {
+while(1) {
ctx.clearColor(0.5, 0.5, 0.5, 1);
- ctx.clear(ctx.COLOR_BUFFER_BIT, DEPTH_BUFFER_BIT);
- ctx.bindBuffer(ctx.ARRAY_BUFFER, buffer);
+ ctx.clear(ctx.COLOR_BUFFER_BIT, ctx.DEPTH_BUFFER_BIT);
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, vertexBuffer);
ctx.enableVertexAttribArray(attr);
ctx.vertexAttribPointer(attr, vertexBuffer.itemSize, ctx.FLOAT, false, 0, 0);
ctx.drawArrays(ctx.TRIANGLES, 0, 3);
ctx.flush();
-}, 10);
+}
View
@@ -101,7 +101,7 @@ JSBool webgl_rendering_context_checkFramebufferStatus(JSContext *cx, uintN argc,
}
JSBool webgl_rendering_context_clear(JSContext *cx, uintN argc, jsval *argv) {
-
+ glClear();
return JS_TRUE;
}

0 comments on commit 7ab9e66

Please sign in to comment.