global functions
- noopDeleter()
- ofCreateWindow()
- ofDoesHWOrientation()
- ofEvents()
- ofExit()
- ofGetAppPtr()
- ofGetClipboardString()
- ofGetCurrentRenderer()
- ofGetCurrentWindow()
- ofGetFixedStepForFps()
- ofGetFrameNum()
- ofGetFrameRate()
- ofGetGLXContext()
- ofGetHeight()
- ofGetLastFrameTime()
- ofGetMainLoop()
- ofGetOrientation()
- ofGetScreenHeight()
- ofGetScreenWidth()
- ofGetTargetFrameRate()
- ofGetWidth()
- ofGetWindowHeight()
- ofGetWindowMode()
- ofGetWindowPositionX()
- ofGetWindowPositionY()
- ofGetWindowPtr()
- ofGetWindowRect()
- ofGetWindowSize()
- ofGetWindowWidth()
- ofGetX11Display()
- ofGetX11Window()
- ofHideCursor()
- ofInit()
- ofRandomHeight()
- ofRandomWidth()
- ofRunApp()
- ofRunMainLoop()
- ofSetClipboardString()
- ofSetCurrentRenderer()
- ofSetEscapeQuitsApp()
- ofSetFrameRate()
- ofSetFullscreen()
- ofSetMainLoop()
- ofSetOrientation()
- ofSetTimeModeFiltered()
- ofSetTimeModeFixedRate()
- ofSetTimeModeSystem()
- ofSetVerticalSync()
- ofSetWindowPosition()
- ofSetWindowShape()
- ofSetWindowTitle()
- ofShowCursor()
- ofToggleFullscreen()
ofCreateWindow(...)
shared_ptr< ofAppBaseWindow > ofCreateWindow(const ofWindowSettings &settings)
Creates a new app window and returns it as a shared_ptr. You can change the window's settings, like its size, position, decoration, and resizability in its ofWindowSettings.
To share assets between multiple windows, such as for drawing any ofBaseHasPixels object, you have to share contexts. This can be done by pointing a window to the shareContextWith field in another window's settings, as in the multiWindowOneAppExample.
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.
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())->someVariable;
}
ofGetFrameNum()
uint64_t ofGetFrameNum()
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.
Documentation from code comments
Get the number of frames rendered since the program started.
Returns: the number of frames rendered since the program started.
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)
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)
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
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.
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.
ofRandomHeight()
float ofRandomHeight()
Documentation from code comments
Returns: a random number between 0 and the height of the window.
ofRandomWidth()
float ofRandomWidth()
Documentation from code comments
Returns: a random number between 0 and the width of the window.
ofRunApp(...)
void ofRunApp(shared_ptr< ofAppBaseWindow > window, shared_ptr< ofBaseApp > &&app)
Begins the openGL cycle of the application. It's only called once from main function in main.cpp after setting the window with ofSetupOpenGL. From 0.06 the app is deleted on exit, so you need to call this function as shown in syntax:
ofRunApp(new ofApp());
ofSetCurrentRenderer(...)
void ofSetCurrentRenderer(shared_ptr< ofBaseRenderer > renderer, bool setDefaults=false)
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.
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
ofSetupOpenGL(...)
void ofSetupOpenGL(shared_ptr< Window > windowPtr, int w, int h, ofWindowMode screenMode)
Sets up the window aspect and mode. This function should be called only from the main function in main.cpp. w and h are the width and height of the window. screenMode can be one of: - OF_WINDOW: normal window - OF_FULLSCREEN: fullscreen, the size of the app will be that of the current screen resolution. The w and h parameters will be ignored.
ofSetupOpenGL(...)
void ofSetupOpenGL(shared_ptr< ofAppGLFWWindow > windowPtr, 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
Last updated Saturday, 17 August 2024 20:48:42 UTC - 99bfb4fd7929e233b87b05758efc36f91505592e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue