mirror of https://github.com/axmolengine/axmol.git
Adding new Javascript bindings for OpenGL to cocos2d-x. Modifying bindings generated in cocos2d-iphone
This commit is contained in:
parent
57fd3cdb9c
commit
1d89b137ed
|
@ -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<cocos2d::CCNode>(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<cocos2d::CCObject *>(cobj);
|
||||||
|
if (_ccobj) {
|
||||||
|
_ccobj->autorelease();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
TypeTest<GLNode> 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<GLNode>(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<GLNode> 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
|
@ -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<WebGLShader>? 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<length; i++) {
|
||||||
|
jsval e = INT_TO_JSVAL(buffer[i]);
|
||||||
|
JS_SetElement(cx, jsobj, i, &e );
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj));
|
||||||
|
return JS_TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// sequence<DOMString>? 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<len+1; i++) {
|
||||||
|
if( copy[i]==' ' || copy[i]==',' || i==len ) {
|
||||||
|
copy[i] = 0;
|
||||||
|
|
||||||
|
jsval str = charptr_to_jsval(cx, (const char*)©[start_extension]);
|
||||||
|
JS_SetElement(cx, jsobj, element++, &str );
|
||||||
|
|
||||||
|
start_extension = i+1;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj));
|
||||||
|
return JS_TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// any getTexParameter(GLenum target, GLenum pname);
|
||||||
|
JSBool JSB_glGetTexParameterfv(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
{
|
||||||
|
JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "JSB_glGetTexParameterfv: 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, "JSB_glGetTexParameterfv: Error processing arguments");
|
||||||
|
|
||||||
|
GLfloat param;
|
||||||
|
glGetTexParameterfv(arg0, arg1, ¶m);
|
||||||
|
|
||||||
|
JS_SET_RVAL(cx, vp, DOUBLE_TO_JSVAL(param));
|
||||||
|
return JS_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// any getUniform(WebGLProgram? program, WebGLUniformLocation? location);
|
||||||
|
JSBool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
|
||||||
|
{
|
||||||
|
JSB_PRECONDITION2( argc == 2, cx, JS_FALSE, "JSB_glGetUniformfv: 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, "JSB_glGetUniformfv: Error processing arguments");
|
||||||
|
|
||||||
|
GLsizei length;
|
||||||
|
glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length);
|
||||||
|
GLchar namebuffer[length];
|
||||||
|
GLint size = -1;
|
||||||
|
GLenum type = -1;
|
||||||
|
|
||||||
|
glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, namebuffer);
|
||||||
|
|
||||||
|
int usize = 0;
|
||||||
|
int utype = 0;
|
||||||
|
switch(type) {
|
||||||
|
|
||||||
|
// float
|
||||||
|
case GL_FLOAT:
|
||||||
|
usize = 1;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case GL_FLOAT_MAT2:
|
||||||
|
usize = 2 * 2;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case GL_FLOAT_MAT3:
|
||||||
|
usize = 3 * 3;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case GL_FLOAT_MAT4:
|
||||||
|
usize = 4 * 4;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case GL_FLOAT_VEC2:
|
||||||
|
usize = 2;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case GL_FLOAT_VEC3:
|
||||||
|
usize = 3;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case GL_FLOAT_VEC4:
|
||||||
|
usize = 4;
|
||||||
|
utype = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// int
|
||||||
|
case GL_INT:
|
||||||
|
usize = 1;
|
||||||
|
utype = GL_INT;
|
||||||
|
break;
|
||||||
|
case GL_INT_VEC2:
|
||||||
|
usize = 1;
|
||||||
|
utype = GL_INT;
|
||||||
|
break;
|
||||||
|
case GL_INT_VEC3:
|
||||||
|
usize = 1;
|
||||||
|
utype = GL_INT;
|
||||||
|
break;
|
||||||
|
case GL_INT_VEC4:
|
||||||
|
usize = 1;
|
||||||
|
utype = GL_INT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
JSB_PRECONDITION2(false, cx, JS_FALSE, "JSB_glGetUniformfv: Uniform Type not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSObject *typedArray = NULL;
|
||||||
|
if( utype == GL_FLOAT) {
|
||||||
|
GLfloat param[usize];
|
||||||
|
glGetUniformfv(arg0, arg1, param);
|
||||||
|
|
||||||
|
typedArray = JS_NewFloat32Array(cx, usize);
|
||||||
|
float *buffer = (float*)JS_GetArrayBufferViewData(typedArray);
|
||||||
|
memcpy( buffer, param, sizeof(float) * usize);
|
||||||
|
} else if( utype == GL_INT ) {
|
||||||
|
GLint param[usize];
|
||||||
|
glGetUniformiv(arg0, arg1, param);
|
||||||
|
|
||||||
|
typedArray = JS_NewInt32Array(cx, usize);
|
||||||
|
GLint *buffer = (GLint*)JS_GetArrayBufferViewData(typedArray);
|
||||||
|
memcpy( buffer, param, sizeof(GLint) * usize);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(typedArray));
|
||||||
|
return JS_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // JSB_INCLUDE_OPENGL
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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_manual
|
||||||
|
#define __jsb_opengl_manual
|
||||||
|
#define JSB_INCLUDE_OPENGL
|
||||||
|
#include "js_bindings_config.h"
|
||||||
|
#ifdef JSB_INCLUDE_OPENGL
|
||||||
|
|
||||||
|
#include <Availability.h>
|
||||||
|
#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
|
|
@ -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 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue