Skip to content

Commit 6869e2f

Browse files
authored
ofFunctions to retrieve information about internal render state (#7757)
1 parent 5e4b783 commit 6869e2f

4 files changed

Lines changed: 554 additions & 551 deletions

File tree

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

3-
#include "ofWindowSettings.h"
43
#include "ofConstants.h"
54
#include "ofMainLoop.h"
5+
#include "ofWindowSettings.h"
66

77
class ofRectangle;
88
class ofAppBaseWindow;
@@ -11,15 +11,14 @@ class ofBaseApp;
1111
class ofBaseRenderer;
1212
class ofCoreEvents;
1313

14-
1514
void ofInit();
16-
void ofSetupOpenGL(int w, int h, ofWindowMode screenMode); // sets up the opengl context!
17-
std::shared_ptr<ofAppBaseWindow> ofCreateWindow(const ofWindowSettings & settings); // sets up the opengl context!
15+
void ofSetupOpenGL(int w, int h, ofWindowMode screenMode); // sets up the opengl context!
16+
std::shared_ptr<ofAppBaseWindow> ofCreateWindow(const ofWindowSettings & settings); // sets up the opengl context!
1817
std::shared_ptr<ofMainLoop> ofGetMainLoop();
1918
void ofSetMainLoop(const std::shared_ptr<ofMainLoop> & mainLoop);
2019

21-
template<typename Window>
22-
void ofSetupOpenGL(const std::shared_ptr<Window> & windowPtr, int w, int h, ofWindowMode screenMode){
20+
template <typename Window>
21+
void ofSetupOpenGL(const std::shared_ptr<Window> & windowPtr, int w, int h, ofWindowMode screenMode) {
2322
ofInit();
2423
ofWindowSettings settings;
2524
settings.setSize(w, h);
@@ -32,83 +31,83 @@ void ofSetupOpenGL(const std::shared_ptr<Window> & windowPtr, int w, int h, ofWi
3231
//TODO: remove me when we remove the ofSetupOpenGL legacy approach.
3332
void ofSetupOpenGL(const std::shared_ptr<ofAppGLFWWindow> & windowPtr, int w, int h, ofWindowMode screenMode);
3433

35-
template<typename Window>
36-
static void noopDeleter(Window*){}
34+
template <typename Window>
35+
static void noopDeleter(Window *) { }
3736

38-
template<typename Window>
39-
void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode){
37+
template <typename Window>
38+
void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode) {
4039
std::shared_ptr<Window> window = std::shared_ptr<Window>(windowPtr, std::function<void(Window *)>(noopDeleter<Window>));
41-
ofSetupOpenGL(window,w,h,screenMode);
40+
ofSetupOpenGL(window, w, h, screenMode);
4241
}
4342

44-
4543
int ofRunApp(std::shared_ptr<ofBaseApp> && OFSA);
4644
int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated
4745
void ofRunApp(const std::shared_ptr<ofAppBaseWindow> & window, std::shared_ptr<ofBaseApp> && app);
4846
int ofRunMainLoop();
4947

50-
5148
ofBaseApp * ofGetAppPtr();
5249

53-
void ofExit(int status=0);
50+
void ofExit(int status = 0);
5451

55-
bool ofIsCurrentThreadTheMainThread();
52+
bool ofIsCurrentThreadTheMainThread();
5653
std::thread::id ofGetMainThreadId();
5754

5855
//-------------------------- time
59-
float ofGetFrameRate();
60-
float ofGetTargetFrameRate();
61-
uint64_t ofGetFrameNum();
62-
void ofSetFrameRate(int targetRate);
63-
double ofGetLastFrameTime();
64-
void ofSetTimeModeSystem();
65-
uint64_t ofGetFixedStepForFps(double fps);
66-
void ofSetTimeModeFixedRate(uint64_t stepNanos = ofGetFixedStepForFps(60)); //default nanos for 1 frame at 60fps
67-
void ofSetTimeModeFiltered(float alpha = 0.9);
68-
69-
void ofSetOrientation(ofOrientation orientation, bool vFlip=true);
70-
ofOrientation ofGetOrientation();
56+
float ofGetFrameRate();
57+
float ofGetTargetFrameRate();
58+
bool ofGetTargetFrameRateEnabled();
59+
uint64_t ofGetFrameNum();
60+
void ofSetFrameRate(int targetRate);
61+
double ofGetLastFrameTime();
62+
void ofSetTimeModeSystem();
63+
ofTimeMode ofGetTimeMode();
64+
uint64_t ofGetFixedStepForFps(double fps);
65+
void ofSetTimeModeFixedRate(uint64_t stepNanos = ofGetFixedStepForFps(60)); //default nanos for 1 frame at 60fps
66+
void ofSetTimeModeFiltered(float alpha = 0.9);
67+
68+
void ofSetOrientation(ofOrientation orientation, bool vFlip = true);
69+
ofOrientation ofGetOrientation();
7170

7271
//-------------------------- cursor
73-
void ofHideCursor();
74-
void ofShowCursor();
72+
void ofHideCursor();
73+
void ofShowCursor();
7574
//-------------------------- window / screen
76-
int ofGetWindowPositionX();
77-
int ofGetWindowPositionY();
78-
int ofGetScreenWidth();
79-
int ofGetScreenHeight();
80-
int ofGetWindowMode();
81-
int ofGetWidth(); // ofGetWidth is correct for orientation
82-
int ofGetHeight();
83-
int ofGetWindowWidth(); // ofGetWindowWidth is correct for actual window coordinates - so doesn't change with orientation.
84-
int ofGetWindowHeight();
75+
int ofGetWindowPositionX();
76+
int ofGetWindowPositionY();
77+
int ofGetScreenWidth();
78+
int ofGetScreenHeight();
79+
int ofGetWindowMode();
80+
int ofGetWidth(); // ofGetWidth is correct for orientation
81+
int ofGetHeight();
82+
int ofGetWindowWidth(); // ofGetWindowWidth is correct for actual window coordinates - so doesn't change with orientation.
83+
int ofGetWindowHeight();
8584

8685
std::string ofGetClipboardString();
87-
void ofSetClipboardString(const std::string & str);
86+
void ofSetClipboardString(const std::string & str);
8887

8988
/// \returns a random number between 0 and the width of the window.
9089
float ofRandomWidth();
9190

9291
/// \returns a random number between 0 and the height of the window.
9392
float ofRandomHeight();
94-
bool ofDoesHWOrientation();
95-
glm::vec2 ofGetWindowSize();
96-
ofRectangle ofGetWindowRect();
93+
bool ofDoesHWOrientation();
94+
glm::vec2 ofGetWindowSize();
95+
ofRectangle ofGetWindowRect();
9796
ofAppBaseWindow * ofGetWindowPtr();
9897
std::shared_ptr<ofAppBaseWindow> ofGetCurrentWindow();
9998

100-
void ofSetWindowPosition(int x, int y);
101-
void ofSetWindowShape(int width, int height);
102-
void ofSetWindowTitle(std::string title);
103-
void ofEnableSetupScreen();
104-
void ofDisableSetupScreen();
105-
void ofSetFullscreen(bool fullscreen);
106-
void ofToggleFullscreen();
99+
void ofSetWindowPosition(int x, int y);
100+
void ofSetWindowShape(int width, int height);
101+
void ofSetWindowTitle(std::string title);
102+
void ofEnableSetupScreen();
103+
void ofDisableSetupScreen();
104+
void ofSetFullscreen(bool fullscreen);
105+
void ofToggleFullscreen();
107106
//-------------------------- sync
108-
void ofSetVerticalSync(bool bSync);
107+
void ofSetVerticalSync(bool bSync);
109108

110109
ofCoreEvents & ofEvents();
111-
void ofSetCurrentRenderer(std::shared_ptr<ofBaseRenderer> renderer,bool setDefaults=false);
110+
void ofSetCurrentRenderer(std::shared_ptr<ofBaseRenderer> renderer, bool setDefaults = false);
112111
std::shared_ptr<ofBaseRenderer> & ofGetCurrentRenderer();
113112
void ofSetEscapeQuitsApp(bool bQuitOnEsc);
114113

@@ -117,8 +116,8 @@ void ofSetEscapeQuitsApp(bool bQuitOnEsc);
117116
typedef unsigned long Window;
118117
struct _XDisplay;
119118
typedef struct _XDisplay Display;
120-
Display* ofGetX11Display();
121-
Window ofGetX11Window();
119+
Display * ofGetX11Display();
120+
Window ofGetX11Window();
122121
#endif
123122

124123
#if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES)
@@ -134,11 +133,11 @@ EGLSurface ofGetEGLSurface();
134133
#endif
135134

136135
#if defined(TARGET_OSX)
137-
void * ofGetNSGLContext();
138-
void * ofGetCocoaWindow();
136+
void * ofGetNSGLContext();
137+
void * ofGetCocoaWindow();
139138
#endif
140139

141140
#if defined(TARGET_WIN32)
142-
HGLRC ofGetWGLContext();
143-
HWND ofGetWin32Window();
141+
HGLRC ofGetWGLContext();
142+
HWND ofGetWin32Window();
144143
#endif

0 commit comments

Comments
 (0)