Beispiel #1
0
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
    if(key == '1') {
        ofGetWindowPtr()->setClipboardString("Hello World!");
    } else if(key == '2') {
        clipboardContents = ofGetWindowPtr()->getClipboardString();
    }
}
Beispiel #2
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
    
    if(key == 'i') {
        selectSyphonInput(dirIdx+1);
    }
    if(key == 'c') {
        if(lastChangedParam != nullptr) {
            ofGetWindowPtr()->setClipboardString(ofxParameterFader::getOscAddressForParameter(*lastChangedParam));
        }
    }
    
    /*if(key == 'n') {
        mapping->nextCorner();
     }
     if(key == 'm') {
        mapping->prevCorner();
     }
     if(mapping->selectedCorner) {
     if(key == OF_KEY_UP) {
        mapping->selectedCorner->pos.z += 1;
        mapping->updateMeshes();
     }
     if(key == OF_KEY_DOWN) {
        mapping->selectedCorner->pos.z -= 1;
        mapping->updateMeshes();
     }
     }*/
}
string ofxTextInputField::getClipboard()
{
	const char *clip = glfwGetClipboardString((GLFWwindow*) ofGetWindowPtr()->getCocoaWindow());
	if(clip!=NULL) {
		return string(clip);
	} else {
		return "";
	}

}
//----------------------------------------------------------
ofGLRenderer::ofGLRenderer(bool useShapeColor)
:matrixStack(*ofGetWindowPtr()){
	bBackgroundAuto = true;

	linePoints.resize(2);
	rectPoints.resize(4);
	triPoints.resize(3);
	fillFlag = OF_FILLED;
	bSmoothHinted = false;
	rectMode = OF_RECTMODE_CORNER;
}
Beispiel #5
0
	void terminateApp(const std::string & module, const std::string & reason, float secondsOnScreen){
		
		ofLogFatalError("ofxApp") << "terminateApp()!";
		ofxSimpleHttp::destroySslContext();
		ofLogFatalError("ofxApp") << "";
		ofLogFatalError("ofxApp") << "-----------------------------------------------------------------------------------------------------------";
		ofLogFatalError("ofxApp") << "";
		ofLogFatalError("ofxApp") << "ofxApp is terminating because the module \"" << module << "\" found an unrecoverable error.";
		ofLogFatalError("ofxApp") << "\"" << reason << "\"";
		ofLogFatalError("ofxApp") << "This message will be on screen for " << (int)secondsOnScreen << " seconds, then the app will quit.";
		ofLogFatalError("ofxApp") << "";
		ofLogFatalError("ofxApp") << "-----------------------------------------------------------------------------------------------------------";
		ofLogFatalError("ofxApp") << "";
		ofxThreadSafeLog::one()->close();
		if(ofxApp::get().isWindowSetup()){
			ofxSuperLog::getLogger()->setScreenLoggingEnabled(true); //show log if json error
			ofxSuperLog::getLogger()->getDisplayLogger().setPanelWidth(1.0);
			int numFrames = secondsOnScreen * 1000 / 16; //stay up a bit so that you can read logs on screen
			
			OFXAPP_REPORT("ofxAppTerminate_" + module, reason, 2);
			
			//hijack OF and refresh screen & events by hand at ~60fps
			if(ofGetWindowPtr()){
				for(int i = 0; i < numFrames; i++ ){
					ofSetupScreen();
					ofClear(0,0,0,255);
					ofxSuperLog::getLogger()->getDisplayLogger().draw(ofGetWidth(), ofGetHeight());
					ofGetMainLoop()->pollEvents();
					if(ofGetWindowPtr()->getWindowShouldClose()){
						ofLogFatalError("ofxApp") << "Quitting by user action";
						std::exit(-1);
					}
					ofGetWindowPtr()->swapBuffers();
					ofSleepMillis(16);
				}
			}
		}else{
			ofLogFatalError("ofxApp") << "Terminating ofxApp before the app window is setup.";
		}
		std::exit(0);
	};
Beispiel #6
0
void ofxOMXPlayer::generateEGLImage()
{
	ofDisableArbTex();
	
	ofAppEGLWindow *appEGLWindow = (ofAppEGLWindow *) ofGetWindowPtr();
	display = appEGLWindow->getEglDisplay();
	context = appEGLWindow->getEglContext();

	
	tex.allocate(videoWidth, videoHeight, GL_RGBA);
	tex.getTextureData().bFlipTexture = true;
	tex.setTextureWrap(GL_REPEAT, GL_REPEAT);
	textureID = tex.getTextureData().textureID;
	
	//TODO - should be a way to use ofPixels for the getPixels() functions?
	glEnable(GL_TEXTURE_2D);

	// setup first texture
	int dataSize = videoWidth * videoHeight * 4;
	
	GLubyte* pixelData = new GLubyte [dataSize];
	
	
    memset(pixelData, 0xff, dataSize);  // white texture, opaque
	
	glBindTexture(GL_TEXTURE_2D, textureID);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, videoWidth, videoHeight, 0,
				 GL_RGBA, GL_UNSIGNED_BYTE, pixelData);
	
	delete[] pixelData;
	
	
	// Create EGL Image
	eglImage = eglCreateImageKHR(
								 display,
								 context,
								 EGL_GL_TEXTURE_2D_KHR,
								 (EGLClientBuffer)textureID,
								 0);
    glDisable(GL_TEXTURE_2D);
	if (eglImage == EGL_NO_IMAGE_KHR)
	{
		ofLogError()	<< "Create EGLImage FAIL";
		return;
	}
	else
	{
		ofLogVerbose()	<< "Create EGLImage PASS";
	}
}
//----------------------------------------------------------
void ofGLRenderer::setCurrentFBO(ofFbo * fbo){
	if(fbo!=NULL){
		ofMatrix4x4 m;
		glGetFloatv(GL_PROJECTION_MATRIX,m.getPtr());
		m =  m*matrixStack.getOrientationMatrixInverse();
		ofMatrixMode currentMode = matrixStack.getCurrentMatrixMode();
		matrixStack.matrixMode(OF_MATRIX_PROJECTION);
		matrixStack.loadMatrix(m.getPtr());
		matrixStack.setRenderSurface(*fbo);
		glMatrixMode(GL_PROJECTION);
		glLoadMatrixf(matrixStack.getProjectionMatrix().getPtr());
		matrixMode(currentMode);
	}else{
		matrixStack.setRenderSurface(*ofGetWindowPtr());
	}
}
Beispiel #8
0
//------------------------------------------
void ofNotifyKeyPressed(int key){
	static ofKeyEventArgs keyEventArgs;
	// FIXME: modifiers are being reported twice, for generic and for left/right
	// add operators to the arguments class so it can be checked for both
    if(key == OF_KEY_RIGHT_CONTROL || key == OF_KEY_LEFT_CONTROL){
        pressedKeys.insert(OF_KEY_CONTROL);
    	keyEventArgs.key = OF_KEY_CONTROL;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
    else if(key == OF_KEY_RIGHT_SHIFT || key == OF_KEY_LEFT_SHIFT){
        pressedKeys.insert(OF_KEY_SHIFT);
    	keyEventArgs.key = OF_KEY_SHIFT;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
    else if(key == OF_KEY_LEFT_ALT || key == OF_KEY_RIGHT_ALT){
        pressedKeys.insert(OF_KEY_ALT);
    	keyEventArgs.key = OF_KEY_ALT;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
    else if(key == OF_KEY_LEFT_SUPER || key == OF_KEY_RIGHT_SUPER){
        pressedKeys.insert(OF_KEY_SUPER);
    	keyEventArgs.key = OF_KEY_SUPER;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
            
	pressedKeys.insert(key);

	keyEventArgs.key = key;
	ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
	
	
	if (key == OF_KEY_ESC && bEscQuits == true){				// "escape"
        ofAppGLFWWindow *appGLFWWindow = dynamic_cast<ofAppGLFWWindow*>(ofGetWindowPtr());
        if (appGLFWWindow) {
            glfwSetWindowShouldClose(appGLFWWindow->getGLFWWindow(), true);
        }else{
            exitApp();
        }
    }
	
	
}
Beispiel #9
0
//------------------------------------------
void ofNotifyKeyPressed(int key, int keycode, int scancode, int codepoint){
	static ofKeyEventArgs keyEventArgs;
	// FIXME: modifiers are being reported twice, for generic and for left/right
	// add operators to the arguments class so it can be checked for both
    if(key == OF_KEY_RIGHT_CONTROL || key == OF_KEY_LEFT_CONTROL){
        pressedKeys.insert(OF_KEY_CONTROL);
    	keyEventArgs.key = OF_KEY_CONTROL;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
    else if(key == OF_KEY_RIGHT_SHIFT || key == OF_KEY_LEFT_SHIFT){
        pressedKeys.insert(OF_KEY_SHIFT);
    	keyEventArgs.key = OF_KEY_SHIFT;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
    else if(key == OF_KEY_LEFT_ALT || key == OF_KEY_RIGHT_ALT){
        pressedKeys.insert(OF_KEY_ALT);
    	keyEventArgs.key = OF_KEY_ALT;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
    else if(key == OF_KEY_LEFT_SUPER || key == OF_KEY_RIGHT_SUPER){
        pressedKeys.insert(OF_KEY_SUPER);
    	keyEventArgs.key = OF_KEY_SUPER;
        ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
    }
            
	pressedKeys.insert(key);

	keyEventArgs.key = key;
	keyEventArgs.keycode = keycode;
	keyEventArgs.scancode = scancode;
	keyEventArgs.codepoint = codepoint;
	ofNotifyEvent( ofEvents().keyPressed, keyEventArgs );
	
	
	if (key == OF_KEY_ESC && bEscQuits == true){				// "escape"
		ofGetWindowPtr()->windowShouldClose();
    }
	
	
}
Beispiel #10
0
ofxSosoRenderer::ofxSosoRenderer(float iWidth, float iHeight, bool iOrthographic, bool iVFlip, float iFov, float iNearDist, float iFarDist):ofGLRenderer(ofGetWindowPtr())
{
  width = iWidth;
  height = iHeight;
  orthographic = false; // Not supported yet.
  vFlip = iVFlip;
  fov = iFov;
  nearDist = iNearDist;
  farDist = iFarDist;
  
  setScreenParams(orthographic, vFlip, fov, nearDist, farDist);
}
Beispiel #11
0
//--------------------------------------------------------------
void cyrilApp::setup(){
  doResetTimers = true;
  
  ofSoundStreamSetup(0, 1, this, 44100, beat.getBufferSize(), 4);
  
  // Switch back to external data folder
  ofSetDataPathRoot("../../../data/");
  
  ofBackground(0);
  pauseProg = false;
  //lightsOn = true;
  lightsOn = true;
  isOrtho = false;
  fxOn = true;
  
  runningProg = false;
  running[0] = false;
  running[1] = false;
  running[2] = false;
  running[3] = false;
  running[4] = false;
  running[5] = false;
  running[6] = false;
  running[7] = false;
  running[8] = false;
  running[9] = false;
  error[0] = false;
  error[1] = false;
  error[2] = false;
  error[3] = false;
  error[4] = false;
  error[5] = false;
  error[6] = false;
  error[7] = false;
  error[8] = false;
  error[9] = false;

#ifdef FULL_DEBUG
	ofSetLogLevel("ofxGLEditor", OF_LOG_VERBOSE);
#endif
  
  
  editor.addCommand('z', this, &cyrilApp::toggleFx);
  editor.addCommand('f', this, &cyrilApp::toggleFullscreen);
  editor.addCommand('a', this, &cyrilApp::toggleEditor);
  editor.addCommand('d', this, &cyrilApp::toggleBackground);
  editor.addCommand('k', this, &cyrilApp::toggleLights);
  editor.addCommand('l', this, &cyrilApp::loadFile);
  editor.addCommand('s', this, &cyrilApp::saveFile);
  editor.addCommand('e', this, &cyrilApp::resetTimers);
  editor.addCommand('p', this, &cyrilApp::pauseProgram);
  editor.addCommand('r', this, &cyrilApp::runScript);
  editor.addCommand('o', this, &cyrilApp::toggleOrtho);
  
  editorVisible = true;
  
  lastSignalReport = -1;
  
  // Init evaluation stack to empty
  _state.stk = new stack<float>;
  // Initialise our own matrix stack
  // TODO: replace with call to get from current renderer?
  _state.ms = new ofMatrixStack(*ofGetWindowPtr());
  // Initialise empty paticle system
  _state.ps = new vector<Particle*>;
  // Initialise empty variable/register map
  _state.sym = new map<int, float>;
  // Initialise palettes
  _state.cs = new map<int, Palette *>;
  // Initialise sprites
  _state.img = new map<int, ofImage *>;
  _state.parent = NULL;
  _state.light = new ofLight();
  //_state.light = NULL;
  
  
  // Directory watcher for data folder
  codeWatcher.registerAllEvents(this);
  spriteWatcher.registerAllEvents(this);
  codeWatcher.addPath(ofToDataPath("code", true), true, &fileFilter);
  spriteWatcher.addPath(ofToDataPath("sprites", true), true, &fileFilter);
  
  
  (*_state.sym)[REG_X_MAX] = 640;
  (*_state.sym)[REG_Y_MAX] = 480;
  (*_state.sym)[REG_X_MID] = (*_state.sym)[REG_X_MAX] / 2.0;
  (*_state.sym)[REG_Y_MID] = (*_state.sym)[REG_Y_MAX] / 2.0;
  
  (*_state.sym)[REG_X_SCALE] = 100;
  (*_state.sym)[REG_Y_SCALE] = 100;
  (*_state.sym)[REG_Z_SCALE] = 100;
  
  (*_state.sym)[REG_PI] = PI;
  (*_state.sym)[REG_TWO_PI] = TWO_PI;
  
  (*_state.sym)[REG_PARTICLE_HEALTH] = 1;
  (*_state.sym)[REG_PARTICLE_DECAY] = 0.1;
  
  // Reserve some space for Particle System
  _state.ps->reserve(2000);
  
  // Global settings
  ofEnableDepthTest();
	ofSetVerticalSync(true);
  if (lightsOn) {
    ofEnableLighting();
    _state.light->setAmbientColor(ofColor(0,0,0));
    _state.light->setDiffuseColor(ofColor(255,255,255));
    _state.light->setSpecularColor(ofColor(255,255,255));
    _state.light->setPointLight();
    _state.light->setAttenuation(1.f,0.f,0.f);
  }
  
  autoClearBg = true;
  ofSetBackgroundAuto(true);
  
  // changed this...
  cursorVisible = true;
  //ofHideCursor();
#ifdef __APPLE__
  //CGDisplayHideCursor(NULL); // <- OK
#endif
  
  
  (*_state.sym)[REG_FRAME] = 0;
  
  edBuf.allocate();
  edBuf.begin();
  ofClear(0,0,0,0);
  edBuf.end();
  
  ofEnableAlphaBlending();
  ofEnableAntiAliasing();
  ofEnableSmoothing();
  
  isFullScreen = false;
  //ofSetFullscreen(true);
  
	//mainOutputSyphonServer.setName("Cyril Main Output");
	//mClient.setup();
  //mClient.set("","Cyril Server");
  
	// listen on the given port
	//cout << "listening for osc messages on port " << PORT << endl;
	//receiver.setup(PORT);
  
  // Configure the ofxPostProcessing effects
  _state.post = ofxPostProcessing();
  _state.post.init(ofGetWidth(), ofGetHeight());
  _state.post.setFlip(false);
  _state.kaleido = _state.post.createPass<KaleidoscopePass>();
  _state.noisewarp = _state.post.createPass<NoiseWarpPass>();
  _state.pixelate = _state.post.createPass<PixelatePass>();
  _state.bloom = _state.post.createPass<BloomPass>();
}
//----------------------------------------------------------
void ofGLRenderer::update(){
    matrixStack.setRenderSurface(*ofGetWindowPtr());
}
Beispiel #13
0
void mui_init(){
	#if TARGET_OS_IPHONE
	if( mui::MuiConfig::detectRetina ){
		ofAppiOSWindow * w = ofAppiOSWindow::getInstance();
		if( w->isRetinaEnabled() ){
			mui::MuiConfig::scaleFactor = 2;
			mui::MuiConfig::useRetinaAssets = true;
		}
	}
	#endif
	//TODO: allow retina in osx too!
	
	Poco::Path appPath;
	#if TARGET_OS_IPHONE
		// http://www.cocoabuilder.com/archive/cocoa/193451-finding-out-executable-location-from-c-program.html
		CFBundleRef bundle = CFBundleGetMainBundle();
		CFURLRef    url  = CFBundleCopyExecutableURL(bundle); // CFBundleCopyResourcesDirectoryURL(bundle);
		CFURLRef absolute = CFURLCopyAbsoluteURL(url);
		CFStringRef path  = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
		CFIndex    maxLength = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
		char        *result = (char*)malloc(maxLength);
		
		if(result) {
			if(!CFStringGetFileSystemRepresentation(path,result, maxLength)) {
				free(result);
				result = NULL;
			}
		}
		
		CFRelease(path);
		CFRelease(url);
		CFRelease(absolute);
		appPath = Poco::Path(result);
		appPath = appPath.parent();
	#elif TARGET_OS_MAC
		// http://www.cocoabuilder.com/archive/cocoa/193451-finding-out-executable-location-from-c-program.html
		CFBundleRef bundle = CFBundleGetMainBundle();
		CFURLRef    url  = CFBundleCopyExecutableURL(bundle); // CFBundleCopyResourcesDirectoryURL(bundle);
		CFURLRef absolute = CFURLCopyAbsoluteURL(url);
		CFStringRef path  = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
		CFIndex    maxLength = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
		char        *result = (char*)malloc(maxLength);
		
		if(result) {
			if(!CFStringGetFileSystemRepresentation(path,result, maxLength)) {
				free(result);
				result = NULL;
			}
		}
		
		CFRelease(path);
		CFRelease(url);
		CFRelease(absolute);
		appPath = Poco::Path(result);
		appPath = appPath.parent().parent().pushDirectory("Resources");
	
		if( mui::MuiConfig::detectRetina ){
			ofAppGLFWWindow * window = dynamic_cast<ofAppGLFWWindow*>(ofGetWindowPtr());
			if( window != NULL ){
				mui::MuiConfig::scaleFactor = window->getPixelScreenCoordScale();
			}
		}
	#else
		appPath = Poco::Path(ofToDataPath("", true));
	#endif
	
	mui::MuiConfig::dataPath = appPath.absolute();
}
Beispiel #14
0
	//--------------------------------------------------------------
	void BaseEngine::setClipboardString(const char * text)
	{
		ofGetWindowPtr()->setClipboardString(text);
	}
Beispiel #15
0
	//--------------------------------------------------------------
	const char* BaseEngine::getClipboardString()
	{
		return &ofGetWindowPtr()->getClipboardString()[0];
	}
/// \brief Callback de sortie de programme (nettoyage au besoin)
///
/// \return void
///
///
void Core::exit()
{
    ofGetWindowPtr()->windowShouldClose();
}
void ofxTextInputField::setClipboard(string clippy)
{
	glfwSetClipboardString( (GLFWwindow*) ofGetWindowPtr()->getCocoaWindow(), clippy.c_str());
}