diff --git a/scripting/javascript/bindings/js_bindings_opengl.cpp b/scripting/javascript/bindings/js_bindings_opengl.cpp new file mode 100644 index 0000000000..7a518782d0 --- /dev/null +++ b/scripting/javascript/bindings/js_bindings_opengl.cpp @@ -0,0 +1,133 @@ +#include "js_bindings_opengl.h" + +void GLNode::draw() { + js_proxy_t* proxy = NULL; + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + proxy = js_get_or_create_proxy(cx, this); + + //JSB_CCNode *proxy = objc_getAssociatedObject(self, &JSB_association_proxy_key); + if( proxy ) { + JSObject *jsObj = proxy->obj; + if (jsObj) { + JSBool found; + JSB_ENSURE_AUTOCOMPARTMENT(cx, jsObj); + JS_HasProperty(cx, jsObj, "draw", &found); + if (found == JS_TRUE) { + jsval rval, fval; + jsval *argv = NULL; unsigned argc=0; + + JS_GetProperty(cx, jsObj, "draw", &fval); + JS_CallFunctionValue(cx, jsObj, fval, argc, argv, &rval); + } + } + } +} + + +JSClass *js_cocos2dx_GLNode_class; +JSObject *js_cocos2dx_GLNode_prototype; + +JSBool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + + if (argc == 0) { + GLNode* cobj = new GLNode(); +#ifdef COCOS2D_JAVASCRIPT + cocos2d::CCObject *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } +#endif + TypeTest t; + js_type_class_t *typeClass; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); + assert(typeClass); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t *p; + JS_NEW_PROXY(p, cobj, obj); +#ifdef COCOS2D_JAVASCRIPT + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLNode"); +#endif + return JS_TRUE; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} + +void js_cocos2dx_GLNode_finalize(JSFreeOp *fop, JSObject *obj) { +} + +JSBool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + GLNode* ret = new GLNode(); + jsval jsret; + do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; +} + +extern JSObject* jsb_CCNode_prototype; + +void js_register_cocos2dx_GLNode(JSContext *cx, JSObject *global) { + js_cocos2dx_GLNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + js_cocos2dx_GLNode_class->name = "GLNode"; + js_cocos2dx_GLNode_class->addProperty = JS_PropertyStub; + js_cocos2dx_GLNode_class->delProperty = JS_PropertyStub; + js_cocos2dx_GLNode_class->getProperty = JS_PropertyStub; + js_cocos2dx_GLNode_class->setProperty = JS_StrictPropertyStub; + js_cocos2dx_GLNode_class->enumerate = JS_EnumerateStub; + js_cocos2dx_GLNode_class->resolve = JS_ResolveStub; + js_cocos2dx_GLNode_class->convert = JS_ConvertStub; + js_cocos2dx_GLNode_class->finalize = js_cocos2dx_GLNode_finalize; + js_cocos2dx_GLNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {0, 0, 0, 0, 0} + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_GLNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + js_cocos2dx_GLNode_prototype = JS_InitClass( + cx, global, + jsb_CCNode_prototype, + js_cocos2dx_GLNode_class, + js_cocos2dx_GLNode_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace + JSBool found; + JS_SetPropertyAttributes(cx, global, "FiniteTimeAction", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, p); + if (!p) { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->type = typeId; + p->jsclass = js_cocos2dx_GLNode_class; + p->proto = js_cocos2dx_GLNode_prototype; + p->parentProto = jsb_CCNode_prototype; + HASH_ADD_INT(_js_global_type_ht, type, p); + } +} diff --git a/scripting/javascript/bindings/js_bindings_opengl.h b/scripting/javascript/bindings/js_bindings_opengl.h new file mode 100644 index 0000000000..2288051b9d --- /dev/null +++ b/scripting/javascript/bindings/js_bindings_opengl.h @@ -0,0 +1,10 @@ +#include "cocos2d.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +class GLNode : public cocos2d::CCNode { + public: + void draw(); +}; + +void js_register_cocos2dx_GLNode(JSContext *cx, JSObject *global); \ No newline at end of file diff --git a/scripting/javascript/bindings/jsb_opengl_functions.cpp b/scripting/javascript/bindings/jsb_opengl_functions.cpp new file mode 100644 index 0000000000..1d99cff3b3 --- /dev/null +++ b/scripting/javascript/bindings/jsb_opengl_functions.cpp @@ -0,0 +1,1919 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-05 +* Script version: v0.6 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_OPENGL + +#include "jsb_opengl_manual.h" + +#include "jsfriendapi.h" +//#include "jsb_config.h" +#include "js_bindings_core.h" +#include "js_manual_conversions.h" +#include "cocosjs_manual_conversions.h" +#include "jsb_opengl_functions.h" + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glActiveTexture((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLuint +// Ret value: void +JSBool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glAttachShader((GLuint)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLuint, char* +// Ret value: void +JSBool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; const char* arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_charptr(cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBindAttribLocation((GLuint)arg0 , (GLuint)arg1 , (char*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLuint +// Ret value: void +JSBool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBindBuffer((GLenum)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLuint +// Ret value: void +JSBool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBindFramebuffer((GLenum)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLuint +// Ret value: void +JSBool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBindRenderbuffer((GLenum)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLuint +// Ret value: void +JSBool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBindTexture((GLenum)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLclampf, GLclampf, GLclampf, GLclampf +// Ret value: void +JSBool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBlendColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBlendEquation((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum +// Ret value: void +JSBool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBlendEquationSeparate((GLenum)arg0 , (GLenum)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum +// Ret value: void +JSBool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBlendFunc((GLenum)arg0 , (GLenum)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLenum, GLenum +// Ret value: void +JSBool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBlendFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, ArrayBufferView, GLenum +// Ret value: void +JSBool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; void* arg1; uint32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg1); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBufferData((GLenum)arg0 , count, (GLvoid*)arg1 , (GLenum)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLintptr, ArrayBufferView +// Ret value: void +JSBool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg2); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glBufferSubData((GLenum)arg0 , (GLintptr)arg1 , count, (GLvoid*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: GLenum +JSBool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLenum ret_val; + + ret_val = glCheckFramebufferStatus((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLbitfield +// Ret value: void +JSBool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glClear((GLbitfield)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLclampf, GLclampf, GLclampf, GLclampf +// Ret value: void +JSBool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glClearColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLclampf +// Ret value: void +JSBool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glClearDepthf((GLclampf)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint +// Ret value: void +JSBool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glClearStencil((GLint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLboolean, GLboolean, GLboolean, GLboolean +// Ret value: void +JSBool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint16_t arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; + + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glColorMask((GLboolean)arg0 , (GLboolean)arg1 , (GLboolean)arg2 , (GLboolean)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glCompileShader((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, ArrayBufferView +// Ret value: void +JSBool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 8, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; void* arg7; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg6 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg7); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glCompressedTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLvoid*)arg7 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, ArrayBufferView +// Ret value: void +JSBool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 9, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; int32_t arg7; void* arg8; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg6 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glCompressedTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLsizei)arg7 , (GLvoid*)arg8 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint +// Ret value: void +JSBool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 8, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg6 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg7 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glCopyTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLint)arg3 , (GLint)arg4 , (GLsizei)arg5 , (GLsizei)arg6 , (GLint)arg7 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei +// Ret value: void +JSBool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 8, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg6 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg7 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glCopyTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLsizei)arg7 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: +// Ret value: GLuint +JSBool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + GLuint ret_val; + + ret_val = glCreateProgram( ); + JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: GLuint +JSBool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLuint ret_val; + + ret_val = glCreateShader((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glCullFace((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDeleteProgram((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDeleteShader((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDepthFunc((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLboolean +// Ret value: void +JSBool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint16_t arg0; + + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDepthMask((GLboolean)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLclampf, GLclampf +// Ret value: void +JSBool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDepthRangef((GLclampf)arg0 , (GLclampf)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLuint +// Ret value: void +JSBool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDetachShader((GLuint)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDisable((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDisableVertexAttribArray((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLsizei +// Ret value: void +JSBool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDrawArrays((GLenum)arg0 , (GLint)arg1 , (GLsizei)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLsizei, GLenum, ArrayBufferView +// Ret value: void +JSBool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; uint32_t arg2; void* arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg3); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glEnable((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glEnableVertexAttribArray((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: +// Ret value: void +JSBool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + glFinish( ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: +// Ret value: void +JSBool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + glFlush( ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLenum, GLuint +// Ret value: void +JSBool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glFramebufferRenderbuffer((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLenum, GLuint, GLint +// Ret value: void +JSBool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; int32_t arg4; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glFramebufferTexture2D((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 , (GLint)arg4 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glFrontFace((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: void +JSBool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glGenerateMipmap((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, char* +// Ret value: int +JSBool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; const char* arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + int ret_val; + + ret_val = glGetAttribLocation((GLuint)arg0 , (char*)arg1 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: +// Ret value: GLenum +JSBool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + GLenum ret_val; + + ret_val = glGetError( ); + JS_SET_RVAL(cx, vp, UINT_TO_JSVAL((uint32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLuint, char* +// Ret value: int +JSBool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; const char* arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); + printf("%s ", arg1); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + int ret_val; + + ret_val = glGetUniformLocation((GLuint)arg0 , (char*)arg1 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum +// Ret value: void +JSBool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glHint((GLenum)arg0 , (GLenum)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: GLboolean +JSBool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsBuffer((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLenum +// Ret value: GLboolean +JSBool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsEnabled((GLenum)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: GLboolean +JSBool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsFramebuffer((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: GLboolean +JSBool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsProgram((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: GLboolean +JSBool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsRenderbuffer((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: GLboolean +JSBool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsShader((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: GLboolean +JSBool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsTexture((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL((int32_t)ret_val)); + return JS_TRUE; +} + +// Arguments: GLfloat +// Ret value: void +JSBool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glLineWidth((GLfloat)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glLinkProgram((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint +// Ret value: void +JSBool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glPixelStorei((GLenum)arg0 , (GLint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLfloat, GLfloat +// Ret value: void +JSBool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView +// Ret value: void +JSBool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 7, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; uint32_t arg4; uint32_t arg5; void* arg6; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg5 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg6); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)arg6 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: +// Ret value: void +JSBool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + glReleaseShaderCompiler( ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLsizei, GLsizei +// Ret value: void +JSBool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLclampf, GLboolean +// Ret value: void +JSBool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; uint16_t arg1; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint, GLsizei, GLsizei +// Ret value: void +JSBool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLuint +// Ret value: void +JSBool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; uint32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLint, GLuint +// Ret value: void +JSBool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; int32_t arg2; uint32_t arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glStencilMask((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLuint +// Ret value: void +JSBool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLenum +// Ret value: void +JSBool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; uint32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLenum, GLenum +// Ret value: void +JSBool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, ArrayBufferView +// Ret value: void +JSBool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 9, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg6 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLfloat +// Ret value: void +JSBool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; int32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLenum, GLint +// Ret value: void +JSBool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; uint32_t arg1; int32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView +// Ret value: void +JSBool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 9, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg6 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLfloat +// Ret value: void +JSBool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform1f((GLint)arg0 , (GLfloat)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform1fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint +// Ret value: void +JSBool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform1i((GLint)arg0 , (GLint)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform1iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLfloat, GLfloat +// Ret value: void +JSBool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform2fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint, GLint +// Ret value: void +JSBool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform2iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLfloat, GLfloat, GLfloat +// Ret value: void +JSBool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform3fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint, GLint, GLint +// Ret value: void +JSBool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform3iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLfloat, GLfloat, GLfloat, GLfloat +// Ret value: void +JSBool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform4fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint, GLint, GLint, GLint +// Ret value: void +JSBool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniform4iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; uint16_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniformMatrix2fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; uint16_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniformMatrix3fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +JSBool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; uint16_t arg1; void* arg2; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUniformMatrix4fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glUseProgram((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint +// Ret value: void +JSBool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glValidateProgram((GLuint)arg0 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLfloat +// Ret value: void +JSBool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +JSBool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; void* arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib1fv((GLuint)arg0 , (GLfloat*)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLfloat, GLfloat +// Ret value: void +JSBool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +JSBool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; void* arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib2fv((GLuint)arg0 , (GLfloat*)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLfloat, GLfloat, GLfloat +// Ret value: void +JSBool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +JSBool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; void* arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib3fv((GLuint)arg0 , (GLfloat*)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLfloat, GLfloat, GLfloat, GLfloat +// Ret value: void +JSBool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +JSBool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; void* arg1; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttrib4fv((GLuint)arg0 , (GLfloat*)arg1 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid* +// Ret value: void +JSBool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 6, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; int32_t arg1; uint32_t arg2; uint16_t arg3; int32_t arg4; int32_t arg5; + + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg3 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)arg5 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +// Arguments: GLint, GLint, GLsizei, GLsizei +// Ret value: void +JSBool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + + +#endif // JSB_INCLUDE_OPENGL diff --git a/scripting/javascript/bindings/jsb_opengl_functions.h b/scripting/javascript/bindings/jsb_opengl_functions.h new file mode 100644 index 0000000000..ab82b91518 --- /dev/null +++ b/scripting/javascript/bindings/jsb_opengl_functions.h @@ -0,0 +1,144 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-05 +* Script version: v0.6 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_OPENGL + +#include "jsb_opengl_manual.h" + +extern "C" { + +JSBool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetTexParameterfv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp); +JSBool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp); + +} + + + +#endif // JSB_INCLUDE_OPENGL diff --git a/scripting/javascript/bindings/jsb_opengl_manual.cpp b/scripting/javascript/bindings/jsb_opengl_manual.cpp new file mode 100644 index 0000000000..d5727e92c8 --- /dev/null +++ b/scripting/javascript/bindings/jsb_opengl_manual.cpp @@ -0,0 +1,517 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2013 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_OPENGL + +#include "jsapi.h" +#include "jsfriendapi.h" + +#include "jsb_opengl_manual.h" +#include "js_manual_conversions.h" +#include "cocosjs_manual_conversions.h" +#include "js_bindings_core.h" +#include "jsb_opengl_functions.h" + + +// Helper functions that link "glGenXXXs" (OpenGL ES 2.0 spec), with "gl.createXXX" (WebGL spec) +JSBool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + GLuint texture; + glGenTextures(1, &texture); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL(texture)); + return JS_TRUE; +} + +JSBool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + GLuint buffer; + glGenBuffers(1, &buffer); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL(buffer)); + return JS_TRUE; +} + +JSBool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + GLuint renderbuffers; + glGenRenderbuffers(1, &renderbuffers); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL(renderbuffers)); + return JS_TRUE; +} + +JSBool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + GLuint framebuffers; + glGenFramebuffers(1, &framebuffers); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL(framebuffers)); + return JS_TRUE; +} + +JSBool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDeleteTextures(1, &arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +JSBool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDeleteBuffers(1, &arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +JSBool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDeleteRenderbuffers(1, &arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +JSBool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glDeleteFramebuffers(1, &arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +JSBool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; const char *arg1; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + ok &= jsval_to_charptr(cx, *argvp++, &arg1); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + glShaderSource(arg0, 1, &arg1, NULL); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; +} + +JSBool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLint ret; + glGetShaderiv(arg0, arg1, &ret); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL(ret)); + return JS_TRUE; +} + +JSBool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLint ret; + glGetProgramiv(arg0, arg1, &ret); + JS_SET_RVAL(cx, vp, INT_TO_JSVAL(ret)); + return JS_TRUE; +} + +JSBool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length); + GLchar src[length]; + glGetProgramInfoLog(arg0, length, NULL, src); + + JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src)); + return JS_TRUE; +} + +// DOMString? getShaderInfoLog(WebGLShader? shader); +JSBool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLsizei length; + glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length); + GLchar src[length]; + glGetShaderInfoLog(arg0, length, NULL, src); + + JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src)); + return JS_TRUE; +} + +// DOMString? getShaderSource(WebGLShader? shader); +JSBool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLsizei length; + glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length); + GLchar src[length]; + glGetShaderSource(arg0, length, NULL, src); + + JS_SET_RVAL(cx, vp, charptr_to_jsval(cx, src)); + return JS_TRUE; +} + +// interface WebGLActiveInfo { +// readonly attribute GLint size; +// readonly attribute GLenum type; +// readonly attribute DOMString name; +// WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index); +JSBool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); + GLchar buffer[length]; + GLint size = -1; + GLenum type = -1; + + glGetActiveAttrib(arg0, arg1, length, NULL, &size, &type, buffer); + + jsval retval = JSVAL_VOID; + + JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error creating JS Object"); + + if (!JS_DefineProperty(cx, object, "size", INT_TO_JSVAL(size), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "type", INT_TO_JSVAL(type), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "name", charptr_to_jsval(cx, buffer), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JS_FALSE; + + retval = OBJECT_TO_JSVAL(object); + + JS_SET_RVAL(cx, vp, retval); + return JS_TRUE; +} + + +// interface WebGLActiveInfo { +// readonly attribute GLint size; +// readonly attribute GLenum type; +// readonly attribute DOMString name; +// }; +// WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index); +JSBool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint( cx, *argvp++, &arg1 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); + GLchar buffer[length]; + GLint size = -1; + GLenum type = -1; + + glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, buffer); + + jsval retval = JSVAL_VOID; + + + JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error creating JS Object"); + + if (!JS_DefineProperty(cx, object, "size", INT_TO_JSVAL(size), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "type", INT_TO_JSVAL(type), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "name", charptr_to_jsval(cx, buffer), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JS_FALSE; + + retval = OBJECT_TO_JSVAL(object); + + JS_SET_RVAL(cx, vp, retval); + return JS_TRUE; +} + +// sequence? getAttachedShaders(WebGLProgram? program); +JSBool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, JS_FALSE, "Invalid number of arguments" ); + jsval *argvp = JS_ARGV(cx,vp); + JSBool ok = JS_TRUE; + uint32_t arg0; + + ok &= jsval_to_uint( cx, *argvp++, &arg0 ); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length); + GLuint buffer[length]; + + glGetAttachedShaders(arg0, length, NULL, buffer); + + JSObject *jsobj = JS_NewArrayObject(cx, length, NULL); + JSB_PRECONDITION2(jsobj, cx, JS_FALSE, "Error creating JS Object"); + + for( int i=0; i? getSupportedExtensions(); +JSBool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, JS_FALSE, "Invalid number of arguments" ); + + const GLubyte *extensions = glGetString(GL_EXTENSIONS); + + JSObject *jsobj = JS_NewArrayObject(cx, 0, NULL); + JSB_PRECONDITION2(jsobj, cx, JS_FALSE, "Error creating JS Object"); + + // copy, to be able to add '\0' + size_t len = strlen((char*)extensions); + GLubyte copy[len+1]; + strncpy((char*)copy, (const char*)extensions, len ); + + int start_extension=0; + int element=0; + for( int i=0; i +#include "jsapi.h" + +#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED +#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) + +// compatible with iOS +#define glClearDepthf glClearDepth +#define glDepthRangef glDepthRange +#define glReleaseShaderCompiler() + +#endif // __MAC_OS_X_VERSION_MAX_ALLOWED + +// forward declaration of new functions +JSBool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp); + + +#endif // JSB_INCLUDE_OPENGL + +#endif // __jsb_opengl_manual diff --git a/scripting/javascript/bindings/jsb_opengl_registration.cpp b/scripting/javascript/bindings/jsb_opengl_registration.cpp new file mode 100644 index 0000000000..5e74f67b5d --- /dev/null +++ b/scripting/javascript/bindings/jsb_opengl_registration.cpp @@ -0,0 +1,192 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "js_bindings_config.h" +#include "js_bindings_core.h" +//#include "jsb_opengl_manual.h" +#include "jsfriendapi.h" +#include "jsb_opengl_manual.h" +#include "jsb_opengl_manual.cpp" +#include "js_bindings_opengl.h" + +//#include "jsb_opengl_functions_registration.h" + +// system +#include "jsb_opengl_functions.h" +#include "jsb_opengl_functions.cpp" + + +void JSB_register_opengl(JSContext *_cx, JSObject *object) +{ + // + // gl + // + JSObject *opengl = JS_NewObject(_cx, NULL, NULL, NULL); + jsval openglVal = OBJECT_TO_JSVAL(opengl); + JS_SetProperty(_cx, object, "gl", &openglVal); + + jsval nsval; + JSObject *ccns; + JS_GetProperty(_cx, object, "cc", &nsval); + if (nsval == JSVAL_VOID) { + ccns = JS_NewObject(_cx, NULL, NULL, NULL); + nsval = OBJECT_TO_JSVAL(ccns); + JS_SetProperty(_cx, object, "cc", &nsval); + } else { + JS_ValueToObject(_cx, nsval, &ccns); + } + + js_register_cocos2dx_GLNode(_cx, ccns); + + // New WebGL functions, not present on OpenGL ES 2.0 + JS_DefineFunction(_cx, opengl, "getSupportedExtensions", JSB_glGetSupportedExtensions, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "activeTexture", JSB_glActiveTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_attachShader", JSB_glAttachShader, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindAttribLocation", JSB_glBindAttribLocation, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindBuffer", JSB_glBindBuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindFramebuffer", JSB_glBindFramebuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindRenderbuffer", JSB_glBindRenderbuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindTexture", JSB_glBindTexture, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendColor", JSB_glBlendColor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendEquation", JSB_glBlendEquation, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendEquationSeparate", JSB_glBlendEquationSeparate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendFunc", JSB_glBlendFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendFuncSeparate", JSB_glBlendFuncSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "bufferData", JSB_glBufferData, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "bufferSubData", JSB_glBufferSubData, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "checkFramebufferStatus", JSB_glCheckFramebufferStatus, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clear", JSB_glClear, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clearColor", JSB_glClearColor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clearDepthf", JSB_glClearDepthf, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clearStencil", JSB_glClearStencil, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "colorMask", JSB_glColorMask, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_compileShader", JSB_glCompileShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "compressedTexImage2D", JSB_glCompressedTexImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "compressedTexSubImage2D", JSB_glCompressedTexSubImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "copyTexImage2D", JSB_glCopyTexImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "copyTexSubImage2D", JSB_glCopyTexSubImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createProgram", JSB_glCreateProgram, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createShader", JSB_glCreateShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "cullFace", JSB_glCullFace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteBuffer", JSB_glDeleteBuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteFramebuffer", JSB_glDeleteFramebuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteProgram", JSB_glDeleteProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteRenderbuffer", JSB_glDeleteRenderbuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteShader", JSB_glDeleteShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteTexture", JSB_glDeleteTextures, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "depthFunc", JSB_glDepthFunc, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "depthMask", JSB_glDepthMask, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "depthRangef", JSB_glDepthRangef, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "detachShader", JSB_glDetachShader, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "disable", JSB_glDisable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "disableVertexAttribArray", JSB_glDisableVertexAttribArray, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "drawArrays", JSB_glDrawArrays, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "drawElements", JSB_glDrawElements, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "enable", JSB_glEnable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "enableVertexAttribArray", JSB_glEnableVertexAttribArray, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "finish", JSB_glFinish, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "flush", JSB_glFlush, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "framebufferRenderbuffer", JSB_glFramebufferRenderbuffer, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "framebufferTexture2D", JSB_glFramebufferTexture2D, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "frontFace", JSB_glFrontFace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createBuffer", JSB_glGenBuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createFramebuffer", JSB_glGenFramebuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createRenderbuffer", JSB_glGenRenderbuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createTexture", JSB_glGenTextures, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "generateMipmap", JSB_glGenerateMipmap, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getActiveAttrib", JSB_glGetActiveAttrib, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getActiveUniform", JSB_glGetActiveUniform, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getAttachedShaders", JSB_glGetAttachedShaders, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getAttribLocation", JSB_glGetAttribLocation, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "getError", JSB_glGetError, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getProgramInfoLog", JSB_glGetProgramInfoLog, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getProgramParameter", JSB_glGetProgramiv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getShaderInfoLog", JSB_glGetShaderInfoLog, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getShaderSource", JSB_glGetShaderSource, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getShaderParameter", JSB_glGetShaderiv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "getTexParameter", JSB_glGetTexParameterfv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getUniformLocation", JSB_glGetUniformLocation, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getUniform", JSB_glGetUniformfv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "hint", JSB_glHint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isBuffer", JSB_glIsBuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isEnabled", JSB_glIsEnabled, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isFramebuffer", JSB_glIsFramebuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isProgram", JSB_glIsProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isRenderbuffer", JSB_glIsRenderbuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isShader", JSB_glIsShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isTexture", JSB_glIsTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "lineWidth", JSB_glLineWidth, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_linkProgram", JSB_glLinkProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "pixelStorei", JSB_glPixelStorei, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "polygonOffset", JSB_glPolygonOffset, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "readPixels", JSB_glReadPixels, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "releaseShaderCompiler", JSB_glReleaseShaderCompiler, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "renderbufferStorage", JSB_glRenderbufferStorage, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "sampleCoverage", JSB_glSampleCoverage, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "scissor", JSB_glScissor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_shaderSource", JSB_glShaderSource, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilFunc", JSB_glStencilFunc, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilFuncSeparate", JSB_glStencilFuncSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilMask", JSB_glStencilMask, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilMaskSeparate", JSB_glStencilMaskSeparate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilOp", JSB_glStencilOp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilOpSeparate", JSB_glStencilOpSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_texImage2D", JSB_glTexImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "texParameterf", JSB_glTexParameterf, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "texParameteri", JSB_glTexParameteri, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_texSubImage2D", JSB_glTexSubImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1f", JSB_glUniform1f, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1fv", JSB_glUniform1fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1i", JSB_glUniform1i, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1iv", JSB_glUniform1iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2f", JSB_glUniform2f, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2fv", JSB_glUniform2fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2i", JSB_glUniform2i, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2iv", JSB_glUniform2iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3f", JSB_glUniform3f, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3fv", JSB_glUniform3fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3i", JSB_glUniform3i, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3iv", JSB_glUniform3iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4f", JSB_glUniform4f, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4fv", JSB_glUniform4fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4i", JSB_glUniform4i, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4iv", JSB_glUniform4iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniformMatrix2fv", JSB_glUniformMatrix2fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniformMatrix3fv", JSB_glUniformMatrix3fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniformMatrix4fv", JSB_glUniformMatrix4fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_useProgram", JSB_glUseProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_validateProgram", JSB_glValidateProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib1f", JSB_glVertexAttrib1f, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib1fv", JSB_glVertexAttrib1fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib2f", JSB_glVertexAttrib2f, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib2fv", JSB_glVertexAttrib2fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib3f", JSB_glVertexAttrib3f, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib3fv", JSB_glVertexAttrib3fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib4f", JSB_glVertexAttrib4f, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib4fv", JSB_glVertexAttrib4fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttribPointer", JSB_glVertexAttribPointer, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "viewport", JSB_glViewport, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + +} + diff --git a/scripting/javascript/bindings/jsb_opengl_registration.h b/scripting/javascript/bindings/jsb_opengl_registration.h new file mode 100644 index 0000000000..1351c240a9 --- /dev/null +++ b/scripting/javascript/bindings/jsb_opengl_registration.h @@ -0,0 +1,32 @@ +/* + * JS Bindings: https://github.com/zynga/jsbindings + * + * Copyright (c) 2012 Zynga Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef __JSB_OPENGL_REGISTRATION +#define __JSB_OPENGL_REGISTRATION +#include "jsb_opengl_functions.h" + +void JSB_register_opengl( JSContext *globalC, JSObject *globalO); + +#endif // __JSB_OPENGL_REGISTRATION