Beispiel #1
0
//--------------------------------------------------------------
bool setupJS()
{
	// Some functions
	ofxJSDefineFunctionGlobal("ofNoise",						&ofNoise,						3);
	
    ofxJSDefineFunctionGlobal("loadShader",						&loadShader,					1);
	ofxJSDefineFunctionGlobal("beginShader",					&beginShader,					0);
	ofxJSDefineFunctionGlobal("endShader",						&endShader,						0);
	ofxJSDefineFunctionGlobal("setUniform1fShader",				&setUniform1fShader,			2);
	ofxJSDefineFunctionGlobal("setUniform2fShader",				&setUniform2fShader,			3);

	ofxJSDefineFunctionGlobal("playSound",                      &playSound,                     3);
    ofxJSDefineFunctionGlobal("setVolumeSound",                 &setVolumeSound,                2);
    ofxJSDefineFunctionGlobal("setVolumeSoundAll",              &setVolumeSoundAll,             1);
    ofxJSDefineFunctionGlobal("setVolumeSoundMainNormalized",   &setVolumeSoundMainNormalized,  1);
    
    
	// Load globals
	ofxJSScript* pScript = ofxJSLoadFromData("murmur.js", "murmur"); // "exampleId" is used for error reporting
	if (pScript){
		bool evalOk = ofxJSEval(pScript);
		if (evalOk){
			//printf("Loaded \"versatubes.js\"\n");
		}
	}
	
	return true; // TODO err checking
}
Beispiel #2
0
//class JSObject;
//--------------------------------------------------------------
ofxJSScript * initJS()
{ 
	// Some functions
	//
    
    ofxJSDefineFunctionGlobal("lookAtSvg",                      &lookAtSvg,                         2);

    
    ofxJSDefineFunctionGlobal("lookAt",                         &lookAt,                            5);
    ofxJSDefineFunctionGlobal("getPosX",                        &getPosX,                           2);
    ofxJSDefineFunctionGlobal("getPosY",                        &getPosY,                           2);
    ofxJSDefineFunctionGlobal("getPosZ",                        &getPosZ,                           2);
    ofxJSDefineFunctionGlobal("setRotation",                    &setRotation,                       4);
    ofxJSDefineFunctionGlobal("setOrientation",					&setOrientation,					5); 
    ofxJSDefineFunctionGlobal("forceLight",                     &forceLight,                        3); 
    ofxJSDefineFunctionGlobal("setGobo",                        &setGobo,                           3); 
    ofxJSDefineFunctionGlobal("setName",                        &setName,                           0); 
    
    ofxJSDefineFunctionGlobal("getMouseX",                      &getMouseX,                         0);
    ofxJSDefineFunctionGlobal("getMouseY",                      &getMouseY,                         0);

    ofxJSDefineFunctionGlobal("getPos",                         &getPos,                            1);
    
    ofxJSDefineFunctionGlobal("getCurrentTotalFrames",          &getCurrentTotalFrames,             0);
    ofxJSDefineFunctionGlobal("getCurrentAnimFrame",            &getCurrentAnimFrame,               0);
    
    
    ofxJSDefineFunctionGlobal("getWidth",                       &getWidth,                          0);
    ofxJSDefineFunctionGlobal("getHeight",                      &getHeight,                         0);
    ofxJSDefineFunctionGlobal("getDepth",                       &getDepth,                          0);
    
    ofxJSDefineFunctionGlobal("setFinePos",                     &setFinePos,                        3);

    ofxJSDefineFunctionGlobal("setFinePanTilt",                 &setFinePanTilt,                    3);
    
     ofxJSDefineFunctionGlobal("setDMXUSBPorts",                &setDMXUSBPorts,                    3);
    
	// Load globals
	ofxJSScript * pScript = ofxJSLoadFromData("app.js", "app"); 
	if (pScript){
		bool evalOk = ofxJSEval(pScript);
		if (evalOk){
			printf("Loaded \"app.js\"\n");
		} else {
            ofGetAppPtr()->exit();
        }
	}
       
    
	
	return pScript; // TODO err checking
}