//--------------------------------------
int ofGetWindowPositionX(){
	return (int)window->getWindowPosition().x;
}
HGLRC ofGetWGLContext(){
	return window->getWGLContext();
}
// 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());
}
EGLContext ofGetEGLContext(){
	return window->getEGLContext();
}
void * ofGetNSGLContext(){
	return window->getNSGLContext();
}
Display* ofGetX11Display(){
	return window->getX11Display();
}
GLXContext ofGetGLXContext(){
	return window->getGLXContext();
}
//--------------------------------------------------
int ofGetWindowWidth(){
	return (int)window->getWindowSize().x;
}
//--------------------------------------------------
int ofGetWindowHeight(){
	return (int)window->getWindowSize().y;
}
//--------------------------------------------------
int ofGetWidth(){
	return (int)window->getWidth();
}
//--------------------------------------------------
int ofGetHeight(){
	return (int)window->getHeight();
}
//--------------------------------------
int ofGetScreenHeight(){
	return (int)window->getScreenSize().y;
}
//--------------------------------------
int ofGetScreenWidth(){
	return (int)window->getScreenSize().x;
}
//--------------------------------------
int ofGetWindowPositionY(){
	return (int)window->getWindowPosition().y;
}
//--------------------------------------
int ofGetWindowMode(){
	return window->getWindowMode();
}
//--------------------------------------------------
bool ofDoesHWOrientation(){
	return window->doesHWOrientation();
}
//--------------------------------------
void ofSetVerticalSync(bool bSync){
	window->setVerticalSync(bSync);
}
//--------------------------------------------------
ofPoint	ofGetWindowSize() {
	//this can't be return ofPoint(ofGetWidth(), ofGetHeight()) as width and height change based on orientation.
	return window->getWindowSize();
}
Window  ofGetX11Window(){
	return window->getX11Window();
}
//--------------------------------------
void ofSetWindowTitle(string title){
	window->setWindowTitle(title);
}
EGLDisplay ofGetEGLDisplay(){
	return window->getEGLDisplay();
}
//----------------------------------------------------------
void ofEnableSetupScreen(){
	window->enableSetupScreen();
}
EGLSurface ofGetEGLSurface(){
	return window->getEGLSurface();
}
//----------------------------------------------------------
void ofDisableSetupScreen(){
	window->disableSetupScreen();
}
void * ofGetCocoaWindow(){
	return window->getCocoaWindow();
}
//--------------------------------------
void ofToggleFullscreen(){
	window->toggleFullscreen();
}
HWND ofGetWin32Window(){
	return window->getWin32Window();
}
//--------------------------------------
void ofSetFullscreen(bool fullscreen){
	window->setFullscreen(fullscreen);
}
예제 #29
0
//--------------------------------------
ofBaseApp * ofGetAppPtr(){
	return OFSAptr.get();
}
//--------------------------------------
void ofSetWindowShape(int width, int height){
	window->setWindowShape(width, height);
}