reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofAppRunner.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofWindowSettings.h"
4#include "ofConstants.h"
5#include "ofMainLoop.h"
6
7class ofRectangle;
10class ofBaseApp;
11class ofBaseRenderer;
12class ofCoreEvents;
13
14
15void ofInit();
16void ofSetupOpenGL(int w, int h, ofWindowMode screenMode); // sets up the opengl context!
17std::shared_ptr<ofAppBaseWindow> ofCreateWindow(const ofWindowSettings & settings); // sets up the opengl context!
18std::shared_ptr<ofMainLoop> ofGetMainLoop();
19void ofSetMainLoop(const std::shared_ptr<ofMainLoop> & mainLoop);
20
21template<typename Window>
22void ofSetupOpenGL(const std::shared_ptr<Window> & windowPtr, int w, int h, ofWindowMode screenMode){
23 ofInit();
24 ofWindowSettings settings;
25 settings.setSize(w, h);
26 settings.windowMode = screenMode;
27 ofGetMainLoop()->addWindow(windowPtr);
28 windowPtr->setup(settings);
29}
30
31//special case so we preserve supplied settngs
32//TODO: remove me when we remove the ofSetupOpenGL legacy approach.
33void ofSetupOpenGL(const std::shared_ptr<ofAppGLFWWindow> & windowPtr, int w, int h, ofWindowMode screenMode);
34
35template<typename Window>
36static void noopDeleter(Window*){}
37
38template<typename Window>
39void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode){
40 std::shared_ptr<Window> window = std::shared_ptr<Window>(windowPtr, std::function<void(Window *)>(noopDeleter<Window>));
41 ofSetupOpenGL(window,w,h,screenMode);
42}
43
44
45int ofRunApp(std::shared_ptr<ofBaseApp> && OFSA);
46int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated
47void ofRunApp(const std::shared_ptr<ofAppBaseWindow> & window, std::shared_ptr<ofBaseApp> && app);
48int ofRunMainLoop();
49
50
52
53void ofExit(int status=0);
54
56std::thread::id ofGetMainThreadId();
57
58//-------------------------- time
59float ofGetFrameRate();
61uint64_t ofGetFrameNum();
62void ofSetFrameRate(int targetRate);
63double ofGetLastFrameTime();
65uint64_t ofGetFixedStepForFps(double fps);
66void ofSetTimeModeFixedRate(uint64_t stepNanos = ofGetFixedStepForFps(60)); //default nanos for 1 frame at 60fps
67void ofSetTimeModeFiltered(float alpha = 0.9);
68
69void ofSetOrientation(ofOrientation orientation, bool vFlip=true);
71
72//-------------------------- cursor
73void ofHideCursor();
74void ofShowCursor();
75//-------------------------- window / screen
80int ofGetWindowMode();
81int ofGetWidth(); // ofGetWidth is correct for orientation
82int ofGetHeight();
83int ofGetWindowWidth(); // ofGetWindowWidth is correct for actual window coordinates - so doesn't change with orientation.
85
86std::string ofGetClipboardString();
87void ofSetClipboardString(const std::string & str);
88
90float ofRandomWidth();
91
93float ofRandomHeight();
95glm::vec2 ofGetWindowSize();
98std::shared_ptr<ofAppBaseWindow> ofGetCurrentWindow();
99
100void ofSetWindowPosition(int x, int y);
101void ofSetWindowShape(int width, int height);
102void ofSetWindowTitle(std::string title);
105void ofSetFullscreen(bool fullscreen);
106void ofToggleFullscreen();
107//-------------------------- sync
108void ofSetVerticalSync(bool bSync);
109
111void ofSetCurrentRenderer(std::shared_ptr<ofBaseRenderer> renderer,bool setDefaults=false);
112std::shared_ptr<ofBaseRenderer> & ofGetCurrentRenderer();
113void ofSetEscapeQuitsApp(bool bQuitOnEsc);
114
115//-------------------------- native window handles
116#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)
117typedef unsigned long Window;
118struct _XDisplay;
119typedef struct _XDisplay Display;
120Display* ofGetX11Display();
121Window ofGetX11Window();
122#endif
123
124#if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES)
125struct __GLXcontextRec;
126typedef __GLXcontextRec * GLXContext;
127GLXContext ofGetGLXContext();
128#endif
129
130#if defined(TARGET_LINUX) && defined(TARGET_OPENGLES)
131EGLDisplay ofGetEGLDisplay();
132EGLContext ofGetEGLContext();
133EGLSurface ofGetEGLSurface();
134#endif
135
136#if defined(TARGET_OSX)
137 void * ofGetNSGLContext();
138 void * ofGetCocoaWindow();
139#endif
140
141#if defined(TARGET_WIN32)
142 HGLRC ofGetWGLContext();
143 HWND ofGetWin32Window();
144#endif
Definition ofAppBaseWindow.h:21
Definition ofAppGLFWWindow.h:62
Definition ofBaseApp.h:14
The base renderer interface.
Definition ofGraphicsBaseTypes.h:279
Definition ofEvents.h:326
A class representing a 2D rectangle.
Definition ofRectangle.h:87
Definition ofWindowSettings.h:38
void setSize(int width, int height)
Definition ofWindowSettings.h:58
ofWindowMode windowMode
Definition ofWindowSettings.h:51
unsigned int height
Definition ofAppEGLWindow.cpp:125
unsigned int width
Definition ofAppEGLWindow.cpp:124
void * EGLSurface
Definition ofAppEGLWindow.h:29
void * EGLContext
Definition ofAppEGLWindow.h:30
unsigned long Window
Definition ofAppEGLWindow.h:21
void * EGLDisplay
Definition ofAppEGLWindow.h:27
struct _XDisplay Display
Definition ofAppEGLWindow.h:23
void ofExit(int status=0)
Definition ofAppRunner.cpp:346
float ofGetFrameRate()
Definition ofEvents.cpp:20
void ofSetClipboardString(const std::string &str)
Definition ofAppRunner.cpp:428
void ofSetCurrentRenderer(std::shared_ptr< ofBaseRenderer > renderer, bool setDefaults=false)
void ofSetFrameRate(int targetRate)
Definition ofEvents.cpp:10
bool ofIsCurrentThreadTheMainThread()
Definition ofAppRunner.cpp:331
int ofGetScreenWidth()
Definition ofAppRunner.cpp:395
int ofGetWindowHeight()
Definition ofAppRunner.cpp:418
std::string ofGetClipboardString()
Definition ofAppRunner.cpp:423
int ofGetWindowPositionX()
Definition ofAppRunner.cpp:385
void ofSetTimeModeFixedRate(uint64_t stepNanos=ofGetFixedStepForFps(60))
Definition ofUtils.cpp:263
int ofGetWidth()
Definition ofAppRunner.cpp:405
ofBaseApp * ofGetAppPtr()
Definition ofAppRunner.cpp:322
uint64_t ofGetFixedStepForFps(double fps)
Definition ofUtils.cpp:242
int ofRunMainLoop()
Definition ofAppRunner.cpp:210
int ofGetHeight()
Definition ofAppRunner.cpp:409
std::shared_ptr< ofAppBaseWindow > ofCreateWindow(const ofWindowSettings &settings)
Definition ofAppRunner.cpp:231
std::shared_ptr< ofBaseRenderer > & ofGetCurrentRenderer()
Definition ofAppRunner.cpp:317
void ofEnableSetupScreen()
Definition ofAppRunner.cpp:464
void ofSetMainLoop(const std::shared_ptr< ofMainLoop > &mainLoop)
glm::vec2 ofGetWindowSize()
Definition ofAppRunner.cpp:438
void ofSetEscapeQuitsApp(bool bQuitOnEsc)
Definition ofAppRunner.cpp:312
void ofSetWindowShape(int width, int height)
Definition ofAppRunner.cpp:380
ofOrientation ofGetOrientation()
Definition ofAppRunner.cpp:370
void ofSetupOpenGL(int w, int h, ofWindowMode screenMode)
Definition ofAppRunner.cpp:216
int ofGetWindowWidth()
Definition ofAppRunner.cpp:414
void ofSetOrientation(ofOrientation orientation, bool vFlip=true)
Definition ofAppRunner.cpp:361
uint64_t ofGetFrameNum()
Definition ofEvents.cpp:50
ofCoreEvents & ofEvents()
Definition ofAppRunner.cpp:297
float ofGetTargetFrameRate()
Definition ofEvents.cpp:30
int ofGetWindowMode()
Definition ofAppRunner.cpp:484
void ofSetWindowPosition(int x, int y)
Definition ofAppRunner.cpp:375
void ofSetFullscreen(bool fullscreen)
Definition ofAppRunner.cpp:479
ofAppBaseWindow * ofGetWindowPtr()
Definition ofAppRunner.cpp:336
void ofHideCursor()
Definition ofAppRunner.cpp:351
float ofRandomWidth()
Definition ofAppRunner.cpp:444
int ofGetWindowPositionY()
Definition ofAppRunner.cpp:390
int ofRunApp(std::shared_ptr< ofBaseApp > &&OFSA)
void ofDisableSetupScreen()
Definition ofAppRunner.cpp:469
int ofGetScreenHeight()
Definition ofAppRunner.cpp:400
float ofRandomHeight()
Definition ofAppRunner.cpp:449
void ofInit()
Definition ofAppRunner.cpp:117
std::shared_ptr< ofMainLoop > ofGetMainLoop()
Definition ofAppRunner.cpp:176
void ofSetWindowTitle(std::string title)
Definition ofAppRunner.cpp:459
std::thread::id ofGetMainThreadId()
Definition ofAppRunner.cpp:327
double ofGetLastFrameTime()
Definition ofEvents.cpp:40
void ofSetTimeModeFiltered(float alpha=0.9)
Definition ofUtils.cpp:279
std::shared_ptr< ofAppBaseWindow > ofGetCurrentWindow()
Definition ofAppRunner.cpp:341
void ofSetTimeModeSystem()
Definition ofUtils.cpp:247
ofRectangle ofGetWindowRect()
Definition ofAppRunner.cpp:454
bool ofDoesHWOrientation()
Definition ofAppRunner.cpp:433
void ofSetVerticalSync(bool bSync)
Definition ofAppRunner.cpp:489
void ofShowCursor()
Definition ofAppRunner.cpp:356
void ofToggleFullscreen()
Definition ofAppRunner.cpp:474
ofOrientation
Used to represent the available screen orientations.
Definition ofWindowSettings.h:25
ofWindowMode
Used to represent the available windowing modes for the application.
Definition ofWindowSettings.h:8