Browse files

Add: gl.blendFunc

  • Loading branch information...
1 parent a495392 commit 496ac636798e3b8346190970b6caaa10c351fd44 @tmpvar committed Aug 24, 2011
Showing with 13 additions and 5 deletions.
  1. +3 −3 example/triangle.js
  2. +10 −2 src/js/spidermonkey.cc
View
6 example/triangle.js
@@ -96,10 +96,10 @@ e('vertex pointer', gl.vertexAttribPointer(attr, 4, gl.FLOAT, false
e('bind texture buffer', gl.bindBuffer(gl.ARRAY_BUFFER, squareTextureBuffer));
e('vertex point texture', gl.vertexAttribPointer(textureAttr, 2, gl.FLOAT, false, 0, 0));
e('enable depth test', gl.enable(gl.DEPTH_TEST));
+e('enable blend mode', gl.enable(gl.BLEND));
+e('blend func', gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA));
-
-
-var a = 50000;
+var a = 5000;
while(a--) {
e('bind texture', gl.bindTexture(gl.TEXTURE_2D, textureImage));
View
12 src/js/spidermonkey.cc
@@ -108,8 +108,16 @@ JSBool webgl_rendering_context_blendEquationSeparate(JSContext *cx, uintN argc,
}
JSBool webgl_rendering_context_blendFunc(JSContext *cx, uintN argc, jsval *argv) {
- JS_ReportError(cx, "method not implemented");
- return JS_FALSE;
+ GLenum sfactor;
+ GLuint dfactor;
+ if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, argv), "uu", &sfactor, &dfactor)) {
+ JS_ReportError(cx, "Error in blendFunc");
+ return JS_FALSE;
+ }
+
+ glBlendFunc(sfactor, dfactor);
+
+ return JS_TRUE;
}
JSBool webgl_rendering_context_blendFuncSeparate(JSContext *cx, uintN argc, jsval *argv) {

0 comments on commit 496ac63

Please sign in to comment.