ofDocsdocumentation application ofAppRunner (functions)

ofAppRunner (functions)


noopDeleter( ... )

void noopDeleter(Window *)

ofDisableSetupScreen( )

void ofDisableSetupScreen()

Every update/draw cycle, the function ofSetupScreen is called. That function sets the perspective, coordinate system, and some other openGL parameters. If you need to use your own parameters, the call to that function can be disabled with ofDisableSetupScreen.


ofDoesHWOrientation( )

bool ofDoesHWOrientation()

This returns whether your current device does hardware orientation. An iPhone, for instance, does hardware orientation, which you might notice when you tilt your iPhone to the side, hence ofDoesHWOrientation() would return true. Tilting your laptop to the side does not do the same thing, hence ofDoesHWOrientation() would return false.


ofEnableSetupScreen( )

void ofEnableSetupScreen()

Re-enables the call to ofSetupScreen after being disabled with ofDisableSetupScreen


ofEvents( )

ofCoreEvents & ofEvents()

ofExit( ... )

void ofExit(int status=0)

This exits your app, causing it to quit.


ofGetAppPtr( )

ofBaseApp * ofGetAppPtr()

Useful to access the variables in the main app from other classes. The pointer returned by this function has to be cast from an ofBaseApp pointer, to a pointer to your inherited class, before being used. ie:


//ofApp.h
class ofApp: public ofBaseApp{
    // ...
    int someVar;
}

//myClass.cpp
#include myClass.h
#include "ofApp.h" // don't forget to add this line!

void myClass::method(){
    ofLog() << "Value from main app: " << ((ofApp*)ofGetAppPtr())-

ofGetClipboardString( )

string ofGetClipboardString()

ofGetFixedStepForFps( ... )

uint64_t ofGetFixedStepForFps(double fps)

ofGetFrameNum( )

uint64_t ofGetFrameNum()

Get the number of frames rendered since the program started.

Returns: the number of frames rendered since the program started.

This returns the current frame as an int, counting up to (depending on your system) 2147483647 before rolling over back to 0. Don't worry though, at 60 frames a second you have 68 years until it rolls over though.


ofGetFrameRate( )

float ofGetFrameRate()

note: this code is implemented inside the ofAppRunner.


ofGetGLXContext( )

GLXContext ofGetGLXContext()

ofGetHeight( )

int ofGetHeight()

This gets the height of your ofApp window. Useful for finding the middle of the screen like so: ofVec2f middle(ofGetWidth()/2, ofGetHeight()/2)


ofGetLastFrameTime( )

double ofGetLastFrameTime()

ofGetOrientation( )

ofOrientation ofGetOrientation()

ofGetScreenHeight( )

int ofGetScreenHeight()

note: this code is implemented inside the ofAppRunner


ofGetScreenWidth( )

int ofGetScreenWidth()

note: this code is implemented inside the ofAppRunner


ofGetTargetFrameRate( )

float ofGetTargetFrameRate()

ofGetWidth( )

int ofGetWidth()

This gets the width of your ofApp window. Useful for finding the middle of the screen like so: ofVec2f middle(ofGetWidth()/2, ofGetHeight()/2)


ofGetWindowHeight( )

int ofGetWindowHeight()

ofGetWindowMode( )

int ofGetWindowMode()

eg:

int mode = ofGetWindowMode();
		
if(mode == OF_WINDOW){
	cout << "mode is: window mode " << endl;
}else if(mode == OF_FULLSCREEN){
	cout << "mode is: fullscreen mode" << endl;
}else if(mode == OF_GAME_MODE){
	cout << "mode is: game mode" << endl;	
}

note: this code is implemented inside the ofAppRunner


ofGetWindowPositionX( )

int ofGetWindowPositionX()

This is the x position of your window inside your screen. How exactly this is returned is dependent on your operating system but it's pretty consistent across platforms. note: this code is implemented inside the ofAppRunner


ofGetWindowPositionY( )

int ofGetWindowPositionY()

This is the y position of your window inside your screen. How exactly this is returned is dependent on your operating system but it's pretty consistent across platforms. note: this code is implemented inside the ofAppRunner


ofGetWindowPtr( )

ofAppBaseWindow * ofGetWindowPtr()

ofGetWindowRect( )

ofRectangle ofGetWindowRect()

ofGetWindowSize( )

glm::vec2 ofGetWindowSize()

This is the size of your window as it's drawn on your screen. How exactly this is returned is dependent on your operating system but it's pretty consistent across platforms.


ofGetWindowWidth( )

int ofGetWindowWidth()

ofGetX11Display( )

Display * ofGetX11Display()

ofGetX11Window( )

Window ofGetX11Window()

ofHideCursor( )

void ofHideCursor()

This hides the mouse cursor, useful if you're doing a clever app that has no need for mouse interaction, evil if you are. note: this code is implemented inside the ofAppRunner.


ofInit( )

void ofInit()

ofRandomHeight( )

float ofRandomHeight()

Returns: a random number between 0 and the height of the window.


ofRandomWidth( )

float ofRandomWidth()

Returns: a random number between 0 and the width of the window.


ofRunApp( ... )

int ofRunApp(ofBaseApp *OFSA)

ofRunMainLoop( )

int ofRunMainLoop()

ofSetClipboardString( ... )

void ofSetClipboardString(const string &str)

ofSetEscapeQuitsApp( ... )

void ofSetEscapeQuitsApp(bool bQuitOnEsc)

ofSetFrameRate( ... )

void ofSetFrameRate(int targetRate)

Attempts to set the frame rate to a given target by sleeping a certain amount per frame. The results of this may vary based if vertical sync is enabled or disabled (either at the card level or via code), because this locks the drawing to intervals where the screen refreshes.


ofSetFullscreen( ... )

void ofSetFullscreen(bool fullscreen)

Change the app window mode to fullscreen or window depending on the boolean parameter. Enables or disables fullscreen mode for your app's window. note: this code is implemented inside the ofAppRunner.


ofSetOrientation( ... )

void ofSetOrientation(ofOrientation orientation, bool vFlip=true)

ofSetTimeModeFiltered( ... )

void ofSetTimeModeFiltered(float alpha)

ofSetTimeModeFixedRate( ... )

void ofSetTimeModeFixedRate(uint64_t stepNanos)

ofSetTimeModeSystem( )

void ofSetTimeModeSystem()

ofSetVerticalSync( ... )

void ofSetVerticalSync(bool bSync)

Synchronizes the redraw of the screen to the vertical refresh rate of the screen. The monitor or projector redraws the screen at usually 60 frames per second. If vertical sync is not enabled your application runs as fast as possible and the screen can be drawing half of one frame and half of the previous frame, creating an effect called tearing.

Vertical sync is enabled by default since 0.8.0. You can disable it calling ofSetVerticalSync(false).


ofSetWindowPosition( ... )

void ofSetWindowPosition(int x, int y)

Moves the app window to the x and y coordinates specified. For example: coordinates of (0,0) would set the top-left corner of your app window to the top-left corner of the screen. note: this code is implemented inside the ofAppRunner


ofSetWindowShape( ... )

void ofSetWindowShape(int width, int height)

Sets the dimension of your app's window. note: this code is implemented inside the ofAppRunner


ofSetWindowTitle( ... )

void ofSetWindowTitle(string title)

ofSetupOpenGL( ... )

void ofSetupOpenGL(Window *windowPtr, int w, int h, ofWindowMode screenMode)

ofSetupOpenGL( ... )

void ofSetupOpenGL(int w, int h, ofWindowMode screenMode)

ofShowCursor( )

void ofShowCursor()

Shows the mouse cursor again when it's been hidden with ofHideCursor makes the cursor visible. note: this code is implemented inside the ofAppRunner


ofToggleFullscreen( )

void ofToggleFullscreen()