Beispiel #1
0
/*! This function initializes CX functionality. It should probably only be called once, at program start.
\param config The intial CX configuration.
\return `true` if intialization was successful, `false` if there was an error. If there was an error, it should be logged.
*/
bool initializeCX(CX_InitConfiguation config) {

	if (config.clockPrecisionTestIterations < 10000) {
		config.clockPrecisionTestIterations = 10000;
	}

#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 9 && OF_VERSION_PATCH >= 0
	ofInit();
#else //Older versions...
	ofSetWorkingDirectoryToDefault();
#endif
	
	ofSetEscapeQuitsApp(false);

	CX::Instances::Log.captureOFLogMessages(config.captureOFLogMessages);
	CX::Instances::Log.levelForAllModules(CX_Logger::Level::LOG_ALL);
	CX::Instances::Log.levelForModule(CX_Logger::Level::LOG_NOTICE, "ofShader"); //Try to eliminate some of the verbose shader gobbeldygook.

	CX::Private::learnOpenGLVersion(); //Should come before reopenWindow.

	bool openedSucessfully = CX::reopenWindow(config.windowConfig); //or for the first time.

	if (!openedSucessfully) {
		CX::Instances::Log.error("CX_EntryPoint") << "The window was not opened successfully.";
	} else {
		// Set up the clock
		CX::Instances::Clock.setup(nullptr, true, config.clockPrecisionTestIterations);

		CX::Instances::Input.pollEvents(); //Do this so that the window is at least minimally responding and doesn't get killed by the OS.
			//This must happen after the window is configured because it relies on GLFW.

		if (config.framePeriodEstimationInterval != CX_Millis(0)) {
			CX::Instances::Disp.estimateFramePeriod(config.framePeriodEstimationInterval);
			CX::Instances::Log.notice("CX_EntryPoint") << "Estimated frame period for display: " << CX::Instances::Disp.getFramePeriod().millis() << " ms.";
		}

		setupKeyboardShortcuts();


		// Set up sound
		CX::Instances::SoundPlayer.setup(&CX::Instances::SoundStream);
		CX::Instances::SoundRecorder.setup(&CX::Instances::SoundStream);


		//This is temporary: I think there's an oF bug about it
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR == 8
		glfwSetWindowPos(CX::Private::glfwContext, 200, 200);
#endif
		
	}

	CX::Instances::Log.verbose() << endl << endl << "### End of startup logging data ###" << endl << endl;
	CX::Instances::Log.flush(); //Flush logs after setup, so user can see if any errors happened during setup.

	CX::Instances::Log.levelForAllModules(CX_Logger::Level::LOG_NOTICE);
	CX::Instances::Log.levelForModule(CX_Logger::Level::LOG_WARNING, "ofFbo"); //It isn't clear that this should be here, but the fbos
		//are really verbose when allocated and it is a lot of gibberish.

	return openedSucessfully;
}
Beispiel #2
0
//========================================================================
int main( ){
    ofSetWorkingDirectoryToDefault(); 
	ofSetupOpenGL(1024,768,OF_WINDOW);			// <-------- setup the GL context

	// this kicks off the running of my app
	// can be OF_WINDOW or OF_FULLSCREEN
	// pass in width and height too:
	ofRunApp(new ofApp());

}
void ofInit(){
	if(initialized()) return;
	initialized() = true;

#if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS)
    // manage own exit
#else
	atexit(ofExitCallback);
#endif

#if defined(TARGET_LINUX) || defined(TARGET_OSX)
	// see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals
	signal(SIGTERM, &ofSignalHandler);
	signal(SIGQUIT, &ofSignalHandler);
	signal(SIGINT,  &ofSignalHandler);

	signal(SIGHUP,  &ofSignalHandler); // not much to be done here

	// http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals
	signal(SIGABRT, &ofSignalHandler);  // abort signal
#endif

	#ifdef WIN32_HIGH_RES_TIMING
		timeBeginPeriod(1);		// ! experimental, sets high res time
								// you need to call timeEndPeriod.
								// if you quit the app other than "esc"
								// (ie, close the console, kill the process, etc)
								// at exit wont get called, and the time will
								// remain high res, that could mess things
								// up on your system.
								// info here:http://www.geisswerks.com/ryan/FAQS/timing.html
	#endif

	ofSeedRandom();
	ofResetElapsedTimeCounter();
	ofSetWorkingDirectoryToDefault();

#ifdef TARGET_LINUX
	if(std::locale().name() == "C"){
		try{
			std::locale::global(std::locale("C.UTF-8"));
		}catch(...){
			if(ofToLower(std::locale("").name()).find("utf-8")==std::string::npos){
				ofLogWarning("ofInit") << "Couldn't set UTF-8 locale, string manipulation functions\n"
						"won't work correctly for non ansi characters unless you specify a UTF-8 locale\n"
						"manually using std::locale::global(std::locale(\"locale\"))\n"
						"available locales can be queried with 'locale -a' in a terminal.";
			}
		}
	}
#endif
}
Beispiel #4
0
void ofInit(){
	static bool initialized = false;
	if(initialized) return;
	initialized = true;
	Poco::ErrorHandler::set(new ofThreadErrorLogger);

#if defined(TARGET_ANDROID) || defined(TARGET_IOS)
    // manage own exit
#else
	atexit(ofExitCallback);
#endif

#if defined(TARGET_LINUX) || defined(TARGET_OSX)
	// see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals
	signal(SIGTERM, &ofSignalHandler);
	signal(SIGQUIT, &ofSignalHandler);
	signal(SIGINT,  &ofSignalHandler);

	signal(SIGHUP,  &ofSignalHandler); // not much to be done here

	// http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals
	signal(SIGABRT, &ofSignalHandler);  // abort signal
#endif

	#ifdef WIN32_HIGH_RES_TIMING
		timeBeginPeriod(1);		// ! experimental, sets high res time
								// you need to call timeEndPeriod.
								// if you quit the app other than "esc"
								// (ie, close the console, kill the process, etc)
								// at exit wont get called, and the time will
								// remain high res, that could mess things
								// up on your system.
								// info here:http://www.geisswerks.com/ryan/FAQS/timing.html
	#endif

	ofSeedRandom();
	ofResetElapsedTimeCounter();
	ofSetWorkingDirectoryToDefault();
}
Beispiel #5
0
// the same hack but in this case the shared_ptr will delete, old versions created the testApp as new...
//--------------------------------------
void ofRunApp(ofBaseApp * OFSA){

	OFSAptr = ofPtr<ofBaseApp>(OFSA);
	if(OFSAptr){
		OFSAptr->mouseX = 0;
		OFSAptr->mouseY = 0;
	}

#ifndef TARGET_ANDROID
	atexit(ofExitCallback);
#endif

#if defined(TARGET_LINUX) || defined(TARGET_OSX)
	// see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals
	signal(SIGTERM, &sighandler);
    signal(SIGQUIT, &sighandler);
	signal(SIGINT,  &sighandler);

	signal(SIGKILL, &sighandler); // not much to be done here
	signal(SIGHUP,  &sighandler); // not much to be done here

	// http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals
    signal(SIGABRT, &sighandler);  // abort signal
#endif


	#ifdef WIN32_HIGH_RES_TIMING
		timeBeginPeriod(1);		// ! experimental, sets high res time
								// you need to call timeEndPeriod.
								// if you quit the app other than "esc"
								// (ie, close the console, kill the process, etc)
								// at exit wont get called, and the time will
								// remain high res, that could mess things
								// up on your system.
								// info here:http://www.geisswerks.com/ryan/FAQS/timing.html

	#endif

	window->initializeWindow();

	ofSeedRandom();
	ofResetElapsedTimeCounter();
	ofSetWorkingDirectoryToDefault();
	

    ofAddListener(ofEvents().setup,OFSAptr.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().update,OFSAptr.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().draw,OFSAptr.get(),&ofBaseApp::draw,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().exit,OFSAptr.get(),&ofBaseApp::exit,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().keyPressed,OFSAptr.get(),&ofBaseApp::keyPressed,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().keyReleased,OFSAptr.get(),&ofBaseApp::keyReleased,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mouseMoved,OFSAptr.get(),&ofBaseApp::mouseMoved,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mouseDragged,OFSAptr.get(),&ofBaseApp::mouseDragged,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mousePressed,OFSAptr.get(),&ofBaseApp::mousePressed,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().mouseReleased,OFSAptr.get(),&ofBaseApp::mouseReleased,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().windowEntered,OFSAptr.get(),&ofBaseApp::windowEntry,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().windowResized,OFSAptr.get(),&ofBaseApp::windowResized,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().messageEvent,OFSAptr.get(),&ofBaseApp::messageReceived,OF_EVENT_ORDER_APP);
    ofAddListener(ofEvents().fileDragEvent,OFSAptr.get(),&ofBaseApp::dragged,OF_EVENT_ORDER_APP);

	window->runAppViaInfiniteLoop(OFSAptr.get());
}
Beispiel #6
0
//--------------------------------------------------------------
void ofApp::setup(){
  ofSetWorkingDirectoryToDefault();

	                           //Game search/sort
  //************************************************************//
	game_search.listDir("/home/mini/games/");                            //<-----This is for games directory
	//game_search.allowExt("sh");
	game_search.sort();
	game_search.getFiles();
  	currentFile = 0;
    currentFile1 = 0;
  //sets up a file to write to  
  	/**
    --->open .info file and seach for "bin" type within text 
    --->either way drop emulator path into .txt file with game path 
  	**/

                            //.info Search/Sort
  	//*****************code to get list of files **************//
  	//ofDirectory ;
  	info_dir.listDir("/usr/share/libretro/info/");        //<----This is for .info directory
    info_dir.sort();
  //	int numFiles = info_dir.listDir();
	//*************************loop through files/open and each file in list******************/
  /*	for(int i = 0; i<numFiles; ++i){
   		//open files
   		ifstream fin;
  		std::vector<string>data;
  		//pattern = "bin";
   		fin.open(info_dir.getPath(i).c_str() );
   	//*************************read open file and pattern match text***********************/
   	/*		while(fin!=NULL){
   				std::string str;
   				getline(fin, str);
   				data.push_back(str);
   				size_t found = str.find(pattern);      //<---was pattern[i];    
   				//print found
   					if (found != std::string::npos){
              //ofLogVerbose(info_dir.getPath(i));
              info_result.push_back(info_dir.getName(i));
   					}
   			}
   		
   	}
    //**************************sort and delete duplicates .info results vector*****************/
    /*sort(info_result.begin(),info_result.end());
    info_result.erase( unique(info_result.begin(), info_result.end()), info_result.end() );
   
    //**************************print result of parse**********************/
    /*for(int i = 0; i<(int)info_result.size(); i++){
      cout<<"yes! "<<info_result[i]<<" <------This" <<endl;
    }*/
    //copy vector to string
    //std::copy(info_result.begin(), info_result.end(), emuInfo);
  	



    /***************************Emulator search/sort*****************************************/
    /****************************************************************************************/
    emu_dir.listDir("/usr/lib/libretro/"); //<---This is for emulator directory
    emu_dir.sort();

    ofSetDataPathRoot("/home/mini/programs/_sega/");
    shPath = ofToDataPath("game.sh", true);
    //-- Path to data

    




    /*int emuNum = emu_dir.size();
    int infoNum = info_result.size();
    //extract just name of emu file
    for(int i = 0;i<emuNum; ++i){
      std::string name = emu_dir.getName(i);
      int lastIndex = name.find_last_of(".");
      string res = name.substr(0, lastIndex);
      raw_emu_name.push_back(res);
    //ofLogVerbose(name.substr(0, lastIndex));  
    }
    //extract just name of info file
    for(int i = 0; i<infoNum; ++i){
      std::string name = info_result[i];
      int lastIndex = name.find_last_of(".");
      string res = name.substr(0, lastIndex);
      raw_info_name.push_back(res);
      //ofLogVerbose(info_result[i].substr(0, lastIndex));
    }
    
    //Need to grab name of string in from info reult and match with raw emu name.
    for(int i = 0; i<infoNum; ++i){
        //ofLogVerbose("got emu_dir index");
        for(int p = 0; p<emuNum; ++p){
          //ofLogVerbose("Im in second loop");
          size_t got = raw_emu_name[p].find(raw_info_name[i]);
          if(got != string::npos){ 
            //ofLogVerbose("got_emu_name!");
            string path = emu_dir.getPath(p);        //get names of both
            emu_result.push_back(path);
          }else{
            //ofLogVerbose("dont got emu_name :(");
          }
      }
    }

    for(int i = 0; i<infoNum; ++i){
    cout<<"Emulator :"<<emu_result[i]<<" !\n";
    }

    
    ----Need to----
    --->get pattern from game selection
    --->put filename paths into .sh with game name
	**/

  
	
	
	

}