From 367a71bc749d5ec96cf46b9840aa4015333b9bab Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 10 Jan 2024 15:23:44 -0300 Subject: [PATCH 001/143] simplify ifdefs with typedef --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 6 +----- libs/openFrameworks/app/ofAppGLFWWindow.h | 23 ++++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 50493d7acfe..05b0f12b1a4 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -133,11 +133,7 @@ void ofAppGLFWWindow::setStencilBits(int stencil) { } //------------------------------------------------------------ -#ifdef TARGET_OPENGLES -void ofAppGLFWWindow::setup(const ofGLESWindowSettings & settings) { -#else -void ofAppGLFWWindow::setup(const ofGLWindowSettings & settings) { -#endif +void ofAppGLFWWindow::setup(const ofSetupWindowSettings & settings) { const ofGLFWWindowSettings * glSettings = dynamic_cast(&settings); if (glSettings) { setup(*glSettings); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 180016559fb..93a13b26b04 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -18,21 +18,19 @@ template class ofPixels_; typedef ofPixels_ ofPixels; + #ifdef TARGET_OPENGLES -class ofGLFWWindowSettings : public ofGLESWindowSettings { +typedef ofGLESWindowSettings ofSetupWindowSettings; #else -class ofGLFWWindowSettings : public ofGLWindowSettings { +typedef ofGLWindowSettings ofSetupWindowSettings; #endif + +class ofGLFWWindowSettings: public ofSetupWindowSettings { public: ofGLFWWindowSettings() { } -#ifdef TARGET_OPENGLES - ofGLFWWindowSettings(const ofGLESWindowSettings & settings) - : ofGLESWindowSettings(settings) { } -#else - ofGLFWWindowSettings(const ofGLWindowSettings & settings) - : ofGLWindowSettings(settings) { } -#endif + ofGLFWWindowSettings(const ofSetupWindowSettings & settings) + :ofSetupWindowSettings(settings){} #ifdef TARGET_RASPBERRY_PI int numSamples = 0; @@ -81,11 +79,8 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { // this functions are only meant to be called from inside OF don't call them from your code using ofAppBaseWindow::setup; -#ifdef TARGET_OPENGLES - void setup(const ofGLESWindowSettings & settings); -#else - void setup(const ofGLWindowSettings & settings); -#endif + + void setup(const ofSetupWindowSettings & settings); void setup(const ofGLFWWindowSettings & settings); void update(); void draw(); From ed1baca6d8c79403eb724d9502692885a3148630 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 10 Jan 2024 16:51:45 -0300 Subject: [PATCH 002/143] setWindowRectangle --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 16 +++++++++++++++- libs/openFrameworks/app/ofAppGLFWWindow.h | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 05b0f12b1a4..a69d47cbcb9 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -546,7 +546,7 @@ void ofAppGLFWWindow::setWindowShouldClose() { } //------------------------------------------------------------ -void ofAppGLFWWindow::setWindowTitle(std::string title) { +void ofAppGLFWWindow::setWindowTitle(const std::string & title) { settings.title = title; glfwSetWindowTitle(windowP, settings.title.c_str()); } @@ -656,6 +656,20 @@ ofWindowMode ofAppGLFWWindow::getWindowMode() { return settings.windowMode; } +//------------------------------------------------------------ +void ofAppGLFWWindow::setWindowRectangle(const ofRectangle & rect) { +// cout << "setWindowRectangle " << rect << endl; + if(settings.windowMode == OF_WINDOW){ + windowW = rect.width; + windowH = rect.height; + } + currentW = rect.width; + currentH = rect.height; + + // Now using just one GLFW call to set the entire rectangle. + glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, currentW, currentH, GLFW_DONT_CARE); +} + //------------------------------------------------------------ void ofAppGLFWWindow::setWindowPosition(int x, int y) { glfwSetWindowPos(windowP, x / pixelScreenCoordScale, y / pixelScreenCoordScale); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 93a13b26b04..49026af42b4 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -104,7 +104,9 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { glm::vec2 getScreenSize(); glm::vec2 getWindowPosition(); - void setWindowTitle(std::string title); + void setWindowTitle(const std::string & title); + + void setWindowRectangle(const ofRectangle & rect); void setWindowPosition(int x, int y); void setWindowShape(int w, int h); From fc8a20fa440e1e4846b3a1b9cf9d0090df738ae8 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Jan 2024 12:59:32 -0300 Subject: [PATCH 003/143] update --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 23 ++++++++-------- libs/openFrameworks/app/ofAppGLFWWindow.h | 29 ++++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index a69d47cbcb9..d1a692d712f 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -341,6 +341,7 @@ void ofAppGLFWWindow::setup(const ofGLFWWindowSettings & _settings) { if (targetWindowMode == OF_WINDOW) { auto position = getWindowPosition(); + setWindowShape(windowW, windowH); setWindowPosition(position.x, position.y); } @@ -477,7 +478,9 @@ void ofAppGLFWWindow::pollEvents() { //-------------------------------------------- void ofAppGLFWWindow::draw() { currentRenderer->startRender(); - if (bEnableSetupScreen) currentRenderer->setupScreen(); + if (bEnableSetupScreen) { + currentRenderer->setupScreen(); + } events().notifyDraw(); @@ -572,17 +575,13 @@ glm::vec2 ofAppGLFWWindow::getWindowSize() { //------------------------------------------------------------ glm::vec2 ofAppGLFWWindow::getWindowPosition() { - int x, y; - glfwGetWindowPos(windowP, &x, &y); - - x *= pixelScreenCoordScale; - y *= pixelScreenCoordScale; - - if (orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180) { - return glm::vec2 { x, y }; - } else { - return glm::vec2(x, y); //NOTE: shouldn't this be (y,x) ?????? - } + glm::ivec2 pos { 0, 0 }; + glfwGetWindowPos(windowP, &pos.x, &pos.y); + // if ( orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT ) { + // std::swap(pos.x, pos.y); + // } + // return pos * glm::vec2 { pixelScreenCoordScale, pixelScreenCoordScale }; + return pos; } //------------------------------------------------------------ diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 49026af42b4..ac332be77ff 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -20,8 +20,11 @@ typedef ofPixels_ ofPixels; #ifdef TARGET_OPENGLES +// FIXME: Rever o nome ofAppBaseXWindow, aplicar no resto do codigo o typedef +typedef ofAppBaseGLESWindow ofAppBaseXWindow; typedef ofGLESWindowSettings ofSetupWindowSettings; #else +typedef ofAppBaseGLWindow ofAppBaseXWindow; typedef ofGLWindowSettings ofSetupWindowSettings; #endif @@ -188,19 +191,19 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { private: static ofAppGLFWWindow * setCurrent(GLFWwindow* windowP); - static void mouse_cb(GLFWwindow* windowP_, int button, int state, int mods); - static void motion_cb(GLFWwindow* windowP_, double x, double y); - static void entry_cb(GLFWwindow* windowP_, int entered); - static void keyboard_cb(GLFWwindow* windowP_, int key, int scancode, int action, int mods); - static void char_cb(GLFWwindow* windowP_, uint32_t key); - static void resize_cb(GLFWwindow* windowP_, int w, int h); - static void position_cb(GLFWwindow* windowP_, int x, int y); - static void framebuffer_size_cb(GLFWwindow* windowP_, int w, int h); - static void exit_cb(GLFWwindow* windowP_); - static void scroll_cb(GLFWwindow* windowP_, double x, double y); - static void drop_cb(GLFWwindow* windowP_, int numFiles, const char** dropString); - static void error_cb(int errorCode, const char* errorDescription); - static void refresh_cb(GLFWwindow * windowP_); + static void mouse_cb(GLFWwindow* windowP_, int button, int state, int mods); + static void motion_cb(GLFWwindow* windowP_, double x, double y); + static void entry_cb(GLFWwindow* windowP_, int entered); + static void keyboard_cb(GLFWwindow* windowP_, int key, int scancode, int action, int mods); + static void char_cb(GLFWwindow* windowP_, uint32_t key); + static void resize_cb(GLFWwindow* windowP_, int w, int h); + static void position_cb(GLFWwindow* windowP_, int x, int y); + static void framebuffer_size_cb(GLFWwindow* windowP_, int w, int h); + static void exit_cb(GLFWwindow* windowP_); + static void scroll_cb(GLFWwindow* windowP_, double x, double y); + static void drop_cb(GLFWwindow* windowP_, int numFiles, const char** dropString); + static void error_cb(int errorCode, const char* errorDescription); + static void refresh_cb(GLFWwindow * windowP_); void close(); From 639b5dac2908aff005a800f6f2a45e480a45b5fa Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Jan 2024 18:37:01 -0300 Subject: [PATCH 004/143] vec2 to ivec2 --- libs/openFrameworks/app/ofAppBaseWindow.h | 14 +++--- libs/openFrameworks/app/ofAppEGLWindow.cpp | 22 +++++----- libs/openFrameworks/app/ofAppEGLWindow.h | 47 +++++++++++---------- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 11 +++-- libs/openFrameworks/app/ofAppGLFWWindow.h | 6 +-- libs/openFrameworks/app/ofAppGlutWindow.cpp | 8 ++-- libs/openFrameworks/app/ofAppGlutWindow.h | 8 ++-- libs/openFrameworks/app/ofAppNoWindow.cpp | 6 +-- libs/openFrameworks/app/ofAppNoWindow.h | 6 +-- libs/openFrameworks/app/ofAppRunner.cpp | 7 ++- libs/openFrameworks/app/ofAppRunner.h | 3 +- 11 files changed, 75 insertions(+), 63 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 0a0f5cff50d..1e4641f8e92 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -7,6 +7,7 @@ class ofBaseApp; class ofBaseRenderer; class ofCoreEvents; +class ofRectangle; #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) struct __GLXcontextRec; @@ -41,10 +42,11 @@ class ofAppBaseWindow{ virtual void setWindowPosition(int x, int y){} virtual void setWindowShape(int w, int h){} + virtual void setWindowRectangle(const ofRectangle & rect){} - virtual glm::vec2 getWindowPosition(){ return glm::vec2(); } - virtual glm::vec2 getWindowSize(){ return glm::vec2(); } - virtual glm::vec2 getScreenSize(){ return glm::vec2(); } + virtual glm::ivec2 getWindowPosition() { return glm::vec2(); } + virtual glm::ivec2 getWindowSize() { return glm::vec2(); } + virtual glm::ivec2 getScreenSize() { return glm::vec2(); } virtual void setOrientation(ofOrientation orientation){ } virtual ofOrientation getOrientation(){ return OF_ORIENTATION_DEFAULT; } @@ -54,7 +56,7 @@ class ofAppBaseWindow{ virtual int getWidth(){ return 0; } virtual int getHeight(){ return 0; } - virtual void setWindowTitle(std::string title){} + virtual void setWindowTitle(const std::string & title){} virtual ofWindowMode getWindowMode(){ return OF_WINDOW; } @@ -101,7 +103,7 @@ class ofAppBaseWindow{ #endif }; -class ofAppBaseGLWindow: public ofAppBaseWindow{ +class ofAppBaseGLWindow: public ofAppBaseWindow { public: virtual ~ofAppBaseGLWindow(){} virtual void setup(const ofGLWindowSettings & settings)=0; @@ -115,7 +117,7 @@ class ofAppBaseGLWindow: public ofAppBaseWindow{ } }; -class ofAppBaseGLESWindow: public ofAppBaseWindow{ +class ofAppBaseGLESWindow: public ofAppBaseWindow { public: virtual ~ofAppBaseGLESWindow(){} virtual void setup(const ofGLESWindowSettings & settings)=0; diff --git a/libs/openFrameworks/app/ofAppEGLWindow.cpp b/libs/openFrameworks/app/ofAppEGLWindow.cpp index 72395ffe63f..305f4504d63 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.cpp +++ b/libs/openFrameworks/app/ofAppEGLWindow.cpp @@ -839,9 +839,9 @@ void ofAppEGLWindow::draw() { // take care of any requests for a new screen mode if (windowMode != OF_GAME_MODE && bNewScreenMode){ if( windowMode == OF_FULLSCREEN){ - setWindowRect(getScreenRect()); + setWindowRectangle(getScreenRect()); } else if( windowMode == OF_WINDOW ){ - setWindowRect(nonFullscreenWindowRect); + setWindowRectangle(nonFullscreenWindowRect); } bNewScreenMode = false; } @@ -918,9 +918,9 @@ void ofAppEGLWindow::destroyNativeEvents() { } //------------------------------------------------------------ -void ofAppEGLWindow::setWindowRect(const ofRectangle& requestedWindowRect) { +void ofAppEGLWindow::setWindowRectangle(const ofRectangle& requestedWindowRect) { if(!isWindowInited) { - ofLogError("ofAppEGLWindow") << "setWindowRect(): window not inited"; + ofLogError("ofAppEGLWindow") << "setWindowRectangle(): window not inited"; return; } @@ -937,9 +937,9 @@ void ofAppEGLWindow::setWindowRect(const ofRectangle& requestedWindowRect) { (unsigned int)newRect.width, (unsigned int)newRect.height); if(ret == BadValue) { - ofLogError("ofAppEGLWindow") << "setWindowRect(): XMoveResizeWindow returned BadValue"; + ofLogError("ofAppEGLWindow") << "setWindowRectangle(): XMoveResizeWindow returned BadValue"; } else if(ret == BadWindow) { - ofLogError("ofAppEGLWindow") << "setWindowRect(): XMoveResizeWindow returned BadWindow"; + ofLogError("ofAppEGLWindow") << "setWindowRectangle(): XMoveResizeWindow returned BadWindow"; } else { // all is good currentWindowRect = newRect; @@ -1083,22 +1083,22 @@ void ofAppEGLWindow::showCursor(){ } //------------------------------------------------------------ -void ofAppEGLWindow::setWindowTitle(string title) { +void ofAppEGLWindow::setWindowTitle(const string & title) { ofLogNotice("ofAppEGLWindow") << "setWindowTitle(): not implemented"; } //------------------------------------------------------------ -glm::vec2 ofAppEGLWindow::getWindowSize(){ +glm::ivec2 ofAppEGLWindow::getWindowSize(){ return {currentWindowRect.width, currentWindowRect.height}; } //------------------------------------------------------------ -glm::vec2 ofAppEGLWindow::getWindowPosition(){ +glm::ivec2 ofAppEGLWindow::getWindowPosition(){ return glm::vec2(currentWindowRect.getPosition()); } //------------------------------------------------------------ -glm::vec2 ofAppEGLWindow::getScreenSize(){ +glm::ivec2 ofAppEGLWindow::getScreenSize(){ unsigned int screenWidth = 0; unsigned int screenHeight = 0; @@ -1242,7 +1242,7 @@ void ofAppEGLWindow::setWindowShape(int w, int h){ } } else { #ifdef TARGET_RASPBERRY_PI_LEGACY - setWindowRect(ofRectangle(currentWindowRect.x,currentWindowRect.y,w,h)); + setWindowRectangle(ofRectangle(currentWindowRect.x,currentWindowRect.y,w,h)); nonFullscreenWindowRect = currentWindowRect; #else ofLogError("ofAppEGLWindow") << "setWindowPosition(): no native window type for this system, perhaps try X11?"; diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index f935cda5c3b..c2f08dac791 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -59,7 +59,7 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { typedef ofAppEGLWindowSettings Settings; ofAppEGLWindow(); - virtual ~ofAppEGLWindow(); + ~ofAppEGLWindow(); static void loop(){}; static bool doesLoop(){ return false; } @@ -84,35 +84,36 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { void setThreadTimeout(long timeOut){ threadTimeout = timeOut; } - virtual void hideCursor(); - virtual void showCursor(); + void hideCursor(); + void showCursor(); - virtual void setWindowPosition(int x, int y); - virtual void setWindowShape(int w, int h); + void setWindowPosition(int x, int y); + void setWindowShape(int w, int h); + void setWindowRectangle(const ofRectangle & rect); - virtual glm::vec2 getWindowPosition(); - virtual glm::vec2 getWindowSize(); - virtual glm::vec2 getScreenSize(); + glm::ivec2 getWindowPosition(); + glm::ivec2 getWindowSize(); + glm::ivec2 getScreenSize(); - virtual void setOrientation(ofOrientation orientation); - virtual ofOrientation getOrientation(); - virtual bool doesHWOrientation(); + void setOrientation(ofOrientation orientation); + ofOrientation getOrientation(); + bool doesHWOrientation(); //this is used by ofGetWidth and now determines the window width based on orientation - virtual int getWidth(); - virtual int getHeight(); + int getWidth(); + int getHeight(); - virtual void setWindowTitle(std::string title); // TODO const correct + void setWindowTitle(const std::string & title); // TODO const correct - virtual ofWindowMode getWindowMode(); + ofWindowMode getWindowMode(); - virtual void setFullscreen(bool fullscreen); - virtual void toggleFullscreen(); + void setFullscreen(bool fullscreen); + void toggleFullscreen(); - virtual void enableSetupScreen(); - virtual void disableSetupScreen(); + void enableSetupScreen(); + void disableSetupScreen(); - virtual void setVerticalSync(bool enabled); + void setVerticalSync(bool enabled); EGLDisplay getEglDisplay() const; EGLSurface getEglSurface() const; @@ -130,14 +131,14 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { protected: - void setWindowRect(const ofRectangle& requestedWindowRect); + void setWindowRect(const ofRectangle & requestedWindowRect); + ofRectangle getScreenRect(); // bool create - virtual void setupPeripherals(); + void setupPeripherals(); - virtual ofRectangle getScreenRect(); int getWindowWidth(); int getWindowHeight(); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index d1a692d712f..9f02c2115f9 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -35,6 +35,9 @@ using std::numeric_limits; using std::shared_ptr; using std::vector; +using std::cout; +using std::endl; + //------------------------------------------------------- ofAppGLFWWindow::ofAppGLFWWindow() @@ -560,7 +563,7 @@ int ofAppGLFWWindow::getPixelScreenCoordScale() { } //------------------------------------------------------------ -glm::vec2 ofAppGLFWWindow::getWindowSize() { +glm::ivec2 ofAppGLFWWindow::getWindowSize() { if (settings.windowMode == OF_GAME_MODE) { const GLFWvidmode * desktopMode = glfwGetVideoMode(glfwGetWindowMonitor(windowP)); if (desktopMode) { @@ -574,9 +577,9 @@ glm::vec2 ofAppGLFWWindow::getWindowSize() { } //------------------------------------------------------------ -glm::vec2 ofAppGLFWWindow::getWindowPosition() { +glm::ivec2 ofAppGLFWWindow::getWindowPosition() { glm::ivec2 pos { 0, 0 }; - glfwGetWindowPos(windowP, &pos.x, &pos.y); + glfwGetWindowPos( windowP, &pos.x, &pos.y ); // if ( orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT ) { // std::swap(pos.x, pos.y); // } @@ -610,7 +613,7 @@ int ofAppGLFWWindow::getCurrentMonitor() { } //------------------------------------------------------------ -glm::vec2 ofAppGLFWWindow::getScreenSize() { +glm::ivec2 ofAppGLFWWindow::getScreenSize() { int count; GLFWmonitor ** monitors = glfwGetMonitors(&count); if (count > 0) { diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index ac332be77ff..9924cdeef07 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -103,9 +103,9 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { void * getWindowContext() { return getGLFWWindow(); } ofGLFWWindowSettings getSettings() { return settings; } - glm::vec2 getWindowSize(); - glm::vec2 getScreenSize(); - glm::vec2 getWindowPosition(); + glm::ivec2 getWindowSize(); + glm::ivec2 getScreenSize(); + glm::ivec2 getWindowPosition(); void setWindowTitle(const std::string & title); diff --git a/libs/openFrameworks/app/ofAppGlutWindow.cpp b/libs/openFrameworks/app/ofAppGlutWindow.cpp index fa19c6702dc..033ff990f99 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.cpp +++ b/libs/openFrameworks/app/ofAppGlutWindow.cpp @@ -394,17 +394,17 @@ void ofAppGlutWindow::loop(){ } //------------------------------------------------------------ -void ofAppGlutWindow::setWindowTitle(std::string title){ +void ofAppGlutWindow::setWindowTitle(const std::string & title){ glutSetWindowTitle(title.c_str()); } //------------------------------------------------------------ -glm::vec2 ofAppGlutWindow::getWindowSize(){ +glm::ivec2 ofAppGlutWindow::getWindowSize(){ return {windowW, windowH}; } //------------------------------------------------------------ -glm::vec2 ofAppGlutWindow::getWindowPosition(){ +glm::ivec2 ofAppGlutWindow::getWindowPosition(){ int x = glutGet(GLUT_WINDOW_X); int y = glutGet(GLUT_WINDOW_Y); if( orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180 ){ @@ -415,7 +415,7 @@ glm::vec2 ofAppGlutWindow::getWindowPosition(){ } //------------------------------------------------------------ -glm::vec2 ofAppGlutWindow::getScreenSize(){ +glm::ivec2 ofAppGlutWindow::getScreenSize(){ int width = glutGet(GLUT_SCREEN_WIDTH); int height = glutGet(GLUT_SCREEN_HEIGHT); if( orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180 ){ diff --git a/libs/openFrameworks/app/ofAppGlutWindow.h b/libs/openFrameworks/app/ofAppGlutWindow.h index 41366c1b372..472eb7e4cba 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.h +++ b/libs/openFrameworks/app/ofAppGlutWindow.h @@ -46,13 +46,13 @@ class ofAppGlutWindow : public ofAppBaseGLWindow { void setFullscreen(bool fullScreen); void toggleFullscreen(); - void setWindowTitle(std::string title); + void setWindowTitle(const std::string & title); void setWindowPosition(int x, int y); void setWindowShape(int w, int h); - glm::vec2 getWindowPosition(); - glm::vec2 getWindowSize(); - glm::vec2 getScreenSize(); + glm::ivec2 getWindowPosition(); + glm::ivec2 getWindowSize(); + glm::ivec2 getScreenSize(); void setOrientation(ofOrientation orientation); ofOrientation getOrientation(); diff --git a/libs/openFrameworks/app/ofAppNoWindow.cpp b/libs/openFrameworks/app/ofAppNoWindow.cpp index 33fc8caceaa..1b45fd58124 100644 --- a/libs/openFrameworks/app/ofAppNoWindow.cpp +++ b/libs/openFrameworks/app/ofAppNoWindow.cpp @@ -279,17 +279,17 @@ void ofAppNoWindow::exitApp(){ } //---------------------------------------------------------- -glm::vec2 ofAppNoWindow::getWindowPosition(){ +glm::ivec2 ofAppNoWindow::getWindowPosition(){ return {0.f, 0.f}; } //---------------------------------------------------------- -glm::vec2 ofAppNoWindow::getWindowSize(){ +glm::ivec2 ofAppNoWindow::getWindowSize(){ return {width, height}; } //---------------------------------------------------------- -glm::vec2 ofAppNoWindow::getScreenSize(){ +glm::ivec2 ofAppNoWindow::getScreenSize(){ return {width, height}; } diff --git a/libs/openFrameworks/app/ofAppNoWindow.h b/libs/openFrameworks/app/ofAppNoWindow.h index 5549c1d2a94..04de8bd2099 100644 --- a/libs/openFrameworks/app/ofAppNoWindow.h +++ b/libs/openFrameworks/app/ofAppNoWindow.h @@ -24,9 +24,9 @@ class ofAppNoWindow : public ofAppBaseWindow { void update(); void draw(); - glm::vec2 getWindowPosition(); - glm::vec2 getWindowSize(); - glm::vec2 getScreenSize(); + glm::ivec2 getWindowPosition(); + glm::ivec2 getWindowSize(); + glm::ivec2 getScreenSize(); int getWidth(); int getHeight(); diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index ea1c2f4477c..21dc3180edc 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -370,6 +370,11 @@ void ofSetWindowShape(int width, int height){ mainLoop()->getCurrentWindow()->setWindowShape(width, height); } +//-------------------------------------- +void ofSetWindowRectangle(const ofRectangle & rect){ + mainLoop()->getCurrentWindow()->setWindowRectangle(rect); +} + //-------------------------------------- int ofGetWindowPositionX(){ return (int)mainLoop()->getCurrentWindow()->getWindowPosition().x; @@ -424,7 +429,7 @@ bool ofDoesHWOrientation(){ } //-------------------------------------------------- -glm::vec2 ofGetWindowSize() { +glm::ivec2 ofGetWindowSize() { //this can't return glm::vec2(ofGetWidth(), ofGetHeight()) as width and height change based on orientation. return mainLoop()->getCurrentWindow()->getWindowSize(); } diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 24ba2ce9dcf..b8c087026d0 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -90,13 +90,14 @@ float ofRandomWidth(); /// \returns a random number between 0 and the height of the window. float ofRandomHeight(); bool ofDoesHWOrientation(); -glm::vec2 ofGetWindowSize(); +glm::ivec2 ofGetWindowSize(); ofRectangle ofGetWindowRect(); ofAppBaseWindow * ofGetWindowPtr(); std::shared_ptr ofGetCurrentWindow(); void ofSetWindowPosition(int x, int y); void ofSetWindowShape(int width, int height); +void ofSetWindowRectangle(const ofRectangle & rect); void ofSetWindowTitle(std::string title); void ofEnableSetupScreen(); void ofDisableSetupScreen(); From 9d9c4bc7a2bb0c081292435ec781d68a107a1b10 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Jan 2024 19:00:16 -0300 Subject: [PATCH 005/143] orientation set and get on primitive now --- libs/openFrameworks/app/ofAppBaseWindow.h | 6 ++++-- libs/openFrameworks/app/ofAppEGLWindow.cpp | 10 ---------- libs/openFrameworks/app/ofAppEGLWindow.h | 3 --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 10 ---------- libs/openFrameworks/app/ofAppGLFWWindow.h | 5 ----- libs/openFrameworks/app/ofAppGlutWindow.cpp | 10 ---------- libs/openFrameworks/app/ofAppGlutWindow.h | 5 +---- libs/openFrameworks/app/ofAppNoWindow.cpp | 1 + libs/openFrameworks/app/ofAppRunner.cpp | 2 ++ 9 files changed, 8 insertions(+), 44 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 1e4641f8e92..aa78e3467e3 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -48,8 +48,8 @@ class ofAppBaseWindow{ virtual glm::ivec2 getWindowSize() { return glm::vec2(); } virtual glm::ivec2 getScreenSize() { return glm::vec2(); } - virtual void setOrientation(ofOrientation orientation){ } - virtual ofOrientation getOrientation(){ return OF_ORIENTATION_DEFAULT; } + virtual void setOrientation(ofOrientation orientationIn) { orientation = orientationIn; } + virtual ofOrientation getOrientation() { return orientation; } virtual bool doesHWOrientation(){ return false; } //this is used by ofGetWidth and now determines the window width based on orientation @@ -101,6 +101,8 @@ class ofAppBaseWindow{ virtual HGLRC getWGLContext(){ return 0; } virtual HWND getWin32Window(){ return 0; } #endif + + ofOrientation orientation; }; class ofAppBaseGLWindow: public ofAppBaseWindow { diff --git a/libs/openFrameworks/app/ofAppEGLWindow.cpp b/libs/openFrameworks/app/ofAppEGLWindow.cpp index 305f4504d63..8c658b0e63f 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.cpp +++ b/libs/openFrameworks/app/ofAppEGLWindow.cpp @@ -1143,16 +1143,6 @@ int ofAppEGLWindow::getHeight(){ return currentWindowRect.width; } -//------------------------------------------------------------ -void ofAppEGLWindow::setOrientation(ofOrientation orientationIn){ - orientation = orientationIn; -} - -//------------------------------------------------------------ -ofOrientation ofAppEGLWindow::getOrientation(){ - return orientation; -} - //------------------------------------------------------------ bool ofAppEGLWindow::doesHWOrientation() { return false; diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index c2f08dac791..713a69c2188 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -95,8 +95,6 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { glm::ivec2 getWindowSize(); glm::ivec2 getScreenSize(); - void setOrientation(ofOrientation orientation); - ofOrientation getOrientation(); bool doesHWOrientation(); //this is used by ofGetWidth and now determines the window width based on orientation @@ -151,7 +149,6 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { std::string eglDisplayString; int nFramesSinceWindowResized; ///< \brief The number of frames passed/shown since the window got resized. - ofOrientation orientation; void threadedFunction(); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 9f02c2115f9..189850e39a6 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1079,16 +1079,6 @@ void ofAppGLFWWindow::toggleFullscreen() { } } -//------------------------------------------------------------ -void ofAppGLFWWindow::setOrientation(ofOrientation orientation) { - this->orientation = orientation; -} - -//------------------------------------------------------------ -ofOrientation ofAppGLFWWindow::getOrientation() { - return orientation; -} - //------------------------------------------------------------ static void rotateMouseXY(ofOrientation orientation, int w, int h, double & x, double & y) { int savedY; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 9924cdeef07..bbbd8e5b297 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -113,9 +113,6 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { void setWindowPosition(int x, int y); void setWindowShape(int w, int h); - void setOrientation(ofOrientation orientation); - ofOrientation getOrientation(); - ofWindowMode getWindowMode(); void setFullscreen(bool fullscreen); @@ -241,8 +238,6 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { ofBaseApp * ofAppPtr; - ofOrientation orientation; - bool iconSet; #ifdef TARGET_WIN32 diff --git a/libs/openFrameworks/app/ofAppGlutWindow.cpp b/libs/openFrameworks/app/ofAppGlutWindow.cpp index 033ff990f99..a6c6a857937 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.cpp +++ b/libs/openFrameworks/app/ofAppGlutWindow.cpp @@ -441,16 +441,6 @@ int ofAppGlutWindow::getHeight(){ return windowW; } -//------------------------------------------------------------ -void ofAppGlutWindow::setOrientation(ofOrientation orientationIn){ - orientation = orientationIn; -} - -//------------------------------------------------------------ -ofOrientation ofAppGlutWindow::getOrientation(){ - return orientation; -} - //------------------------------------------------------------ void ofAppGlutWindow::setWindowPosition(int x, int y){ glutPositionWindow(x,y); diff --git a/libs/openFrameworks/app/ofAppGlutWindow.h b/libs/openFrameworks/app/ofAppGlutWindow.h index 472eb7e4cba..73b5e73a56a 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.h +++ b/libs/openFrameworks/app/ofAppGlutWindow.h @@ -53,10 +53,7 @@ class ofAppGlutWindow : public ofAppBaseGLWindow { glm::ivec2 getWindowPosition(); glm::ivec2 getWindowSize(); glm::ivec2 getScreenSize(); - - void setOrientation(ofOrientation orientation); - ofOrientation getOrientation(); - + int getWidth(); int getHeight(); diff --git a/libs/openFrameworks/app/ofAppNoWindow.cpp b/libs/openFrameworks/app/ofAppNoWindow.cpp index 1b45fd58124..4cfa8c80a55 100644 --- a/libs/openFrameworks/app/ofAppNoWindow.cpp +++ b/libs/openFrameworks/app/ofAppNoWindow.cpp @@ -119,6 +119,7 @@ class ofNoopRenderer: public ofBaseRenderer{ void setupGraphicDefaults(){}; void setupScreen(){}; + // FIXME: this is not standard with the other window modes. void setOrientation(ofOrientation, bool){} bool isVFlipped() const{return true;} glm::mat4 getCurrentMatrix(ofMatrixMode) const{return glm::mat4(1.0);}; diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 21dc3180edc..f37490ae28b 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -347,6 +347,7 @@ void ofShowCursor(){ } //-------------------------------------- +// FIXME: this is not standard with the other window modes. void ofSetOrientation(ofOrientation orientation, bool vFlip){ mainLoop()->getCurrentWindow()->setOrientation(orientation); // TODO: every window should set orientation on it's renderer @@ -399,6 +400,7 @@ int ofGetScreenHeight(){ int ofGetWidth(){ return (int)mainLoop()->getCurrentWindow()->getWidth(); } + //-------------------------------------------------- int ofGetHeight(){ return (int)mainLoop()->getCurrentWindow()->getHeight(); From 7ac88ef0bc7bfe4d43cf5a55f367960b47dc0bb6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 14 Jan 2024 19:09:47 -0300 Subject: [PATCH 006/143] windowmode to primitive class --- libs/openFrameworks/app/ofAppBaseWindow.h | 7 +++++-- libs/openFrameworks/app/ofAppEGLWindow.cpp | 6 ------ libs/openFrameworks/app/ofAppEGLWindow.h | 3 --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 1 - libs/openFrameworks/app/ofAppGLFWWindow.h | 2 -- libs/openFrameworks/app/ofAppGlutWindow.cpp | 5 ----- libs/openFrameworks/app/ofAppGlutWindow.h | 2 -- 7 files changed, 5 insertions(+), 21 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index aa78e3467e3..83ef2ad65fa 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -58,7 +58,7 @@ class ofAppBaseWindow{ virtual void setWindowTitle(const std::string & title){} - virtual ofWindowMode getWindowMode(){ return OF_WINDOW; } + virtual ofWindowMode getWindowMode() { return OF_WINDOW; } virtual void setFullscreen(bool fullscreen){} virtual void toggleFullscreen(){} @@ -102,7 +102,10 @@ class ofAppBaseWindow{ virtual HWND getWin32Window(){ return 0; } #endif - ofOrientation orientation; +private: + ofOrientation orientation = OF_ORIENTATION_DEFAULT; + ofWindowMode windowMode = OF_WINDOW; + }; class ofAppBaseGLWindow: public ofAppBaseWindow { diff --git a/libs/openFrameworks/app/ofAppEGLWindow.cpp b/libs/openFrameworks/app/ofAppEGLWindow.cpp index 8c658b0e63f..32ded88d460 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.cpp +++ b/libs/openFrameworks/app/ofAppEGLWindow.cpp @@ -387,7 +387,6 @@ void ofAppEGLWindow::setup(const ofAppEGLWindowSettings & _settings) { buttonInUse = 0; bEnableSetupScreen = true; eglDisplayString = ""; - orientation = OF_ORIENTATION_DEFAULT; //TODO: 2.0f is an arbitrary factor that makes mouse speed ok at 1024x768, // to be totally correct we might need to take into account screen size @@ -1240,11 +1239,6 @@ void ofAppEGLWindow::setWindowShape(int w, int h){ } } -//------------------------------------------------------------ -ofWindowMode ofAppEGLWindow::getWindowMode(){ - return windowMode; -} - //------------------------------------------------------------ void ofAppEGLWindow::toggleFullscreen(){ if( windowMode == OF_GAME_MODE) return; diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index 713a69c2188..c66a6b83aad 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -103,8 +103,6 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { void setWindowTitle(const std::string & title); // TODO const correct - ofWindowMode getWindowMode(); - void setFullscreen(bool fullscreen); void toggleFullscreen(); @@ -141,7 +139,6 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { int getWindowWidth(); int getWindowHeight(); - ofWindowMode windowMode; bool bNewScreenMode; ///< \brief This indicates if a (new) window rectangle has to be adjusted. int buttonInUse; ///< \brief Mouse button currently in use. bool bEnableSetupScreen; ///< \brief This indicates the need/intent to draw a setup screen. diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 189850e39a6..85d172b5c71 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -47,7 +47,6 @@ ofAppGLFWWindow::ofAppGLFWWindow() buttonPressed = false; bWindowNeedsShowing = true; - orientation = OF_ORIENTATION_DEFAULT; targetWindowMode = OF_WINDOW; ofAppPtr = nullptr; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index bbbd8e5b297..30181297fd2 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -113,8 +113,6 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { void setWindowPosition(int x, int y); void setWindowShape(int w, int h); - ofWindowMode getWindowMode(); - void setFullscreen(bool fullscreen); void toggleFullscreen(); diff --git a/libs/openFrameworks/app/ofAppGlutWindow.cpp b/libs/openFrameworks/app/ofAppGlutWindow.cpp index a6c6a857937..7992817cd09 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.cpp +++ b/libs/openFrameworks/app/ofAppGlutWindow.cpp @@ -472,11 +472,6 @@ void ofAppGlutWindow::showCursor(){ #endif } -//------------------------------------------------------------ -ofWindowMode ofAppGlutWindow::getWindowMode(){ - return windowMode; -} - //------------------------------------------------------------ void ofAppGlutWindow::toggleFullscreen(){ if( windowMode == OF_GAME_MODE)return; diff --git a/libs/openFrameworks/app/ofAppGlutWindow.h b/libs/openFrameworks/app/ofAppGlutWindow.h index 73b5e73a56a..4aa56730fc1 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.h +++ b/libs/openFrameworks/app/ofAppGlutWindow.h @@ -57,8 +57,6 @@ class ofAppGlutWindow : public ofAppBaseGLWindow { int getWidth(); int getHeight(); - ofWindowMode getWindowMode(); - void enableSetupScreen(); void disableSetupScreen(); From 1bf4e4f1d237f8d3298c4aea33bc53315892d3cb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 12:41:35 -0300 Subject: [PATCH 007/143] simplification of window settings --- libs/openFrameworks/app/ofAppBaseWindow.h | 70 +++++++------ libs/openFrameworks/app/ofAppGLFWWindow.cpp | 31 +++--- libs/openFrameworks/app/ofAppGLFWWindow.h | 60 ++--------- libs/openFrameworks/app/ofAppGlutWindow.h | 5 +- libs/openFrameworks/app/ofAppRunner.cpp | 4 +- libs/openFrameworks/app/ofWindowSettings.h | 110 +++++++++----------- scripts/osx/cc.sh | 1 + scripts/osx/cxx.sh | 1 + 8 files changed, 113 insertions(+), 169 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 83ef2ad65fa..ef266510c27 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -20,13 +20,17 @@ struct _XDisplay; typedef struct _XDisplay Display; #endif -class ofAppBaseWindow{ +class ofAppBaseWindow { public: ofAppBaseWindow(){} virtual ~ofAppBaseWindow(){} - virtual void setup(const ofWindowSettings & settings)=0; +// virtual void setup(const ofWindowSettings & settings); + + virtual void setup(const ofWindowSettings & settings){ + + } virtual void update()=0; virtual void draw()=0; virtual bool getWindowShouldClose(){ @@ -58,7 +62,8 @@ class ofAppBaseWindow{ virtual void setWindowTitle(const std::string & title){} - virtual ofWindowMode getWindowMode() { return OF_WINDOW; } + virtual ofWindowMode getWindowMode() { return settings.windowMode; } + virtual void setFullscreen(bool fullscreen){} virtual void toggleFullscreen(){} @@ -102,36 +107,37 @@ class ofAppBaseWindow{ virtual HWND getWin32Window(){ return 0; } #endif -private: + ofWindowSettings settings; + +//private: ofOrientation orientation = OF_ORIENTATION_DEFAULT; ofWindowMode windowMode = OF_WINDOW; - -}; - -class ofAppBaseGLWindow: public ofAppBaseWindow { -public: - virtual ~ofAppBaseGLWindow(){} - virtual void setup(const ofGLWindowSettings & settings)=0; - void setup(const ofWindowSettings & settings){ - const ofGLWindowSettings * glSettings = dynamic_cast(&settings); - if(glSettings){ - setup(*glSettings); - }else{ - setup(ofGLWindowSettings(settings)); - } - } }; -class ofAppBaseGLESWindow: public ofAppBaseWindow { -public: - virtual ~ofAppBaseGLESWindow(){} - virtual void setup(const ofGLESWindowSettings & settings)=0; - void setup(const ofWindowSettings & settings){ - const ofGLESWindowSettings * glSettings = dynamic_cast(&settings); - if(glSettings){ - setup(*glSettings); - }else{ - setup(ofGLESWindowSettings(settings)); - } - } -}; +//class ofAppBaseGLWindow: public ofAppBaseWindow { +//public: +// virtual ~ofAppBaseGLWindow(){} +// virtual void setup(const ofWindowSettings & settings)=0; +// void setup(const ofWindowSettings & settings){ +// const ofGLWindowSettings * glSettings = dynamic_cast(&settings); +// if(glSettings){ +// setup(*glSettings); +// }else{ +// setup(ofGLWindowSettings(settings)); +// } +// } +//}; +// +//class ofAppBaseGLESWindow: public ofAppBaseWindow { +//public: +// virtual ~ofAppBaseGLESWindow(){} +// virtual void setup(const ofGLESWindowSettings & settings)=0; +// void setup(const ofWindowSettings & settings){ +// const ofGLESWindowSettings * glSettings = dynamic_cast(&settings); +// if(glSettings){ +// setup(*glSettings); +// }else{ +// setup(ofGLESWindowSettings(settings)); +// } +// } +//}; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 85d172b5c71..feb5cafbb02 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -135,16 +135,8 @@ void ofAppGLFWWindow::setStencilBits(int stencil) { } //------------------------------------------------------------ -void ofAppGLFWWindow::setup(const ofSetupWindowSettings & settings) { - const ofGLFWWindowSettings * glSettings = dynamic_cast(&settings); - if (glSettings) { - setup(*glSettings); - } else { - setup(ofGLFWWindowSettings(settings)); - } -} +void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { -void ofAppGLFWWindow::setup(const ofGLFWWindowSettings & _settings) { if (windowP) { ofLogError() << "window already setup, probably you are mixing old and new style setup"; ofLogError() << "call only ofCreateWindow(settings) or ofSetupOpenGL(...)"; @@ -407,7 +399,7 @@ void ofAppGLFWWindow::setup(const ofGLFWWindowSettings & _settings) { #ifdef TARGET_LINUX //------------------------------------------------------------ -void ofAppGLFWWindow::setWindowIcon(const std::string & path) { +void ofAppGLFWWindow::setWindowIcon(const of::filesystem::path & path) { ofPixels iconPixels; ofLoadImage(iconPixels, path); setWindowIcon(iconPixels); @@ -558,11 +550,19 @@ void ofAppGLFWWindow::setWindowTitle(const std::string & title) { //------------------------------------------------------------ int ofAppGLFWWindow::getPixelScreenCoordScale() { + + // TODO: + // discover which monitor this window return pixelScreenCoordScale; } //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getWindowSize() { +// glm::ivec2 ws; +// glfwGetWindowPos(windowP, &ws.x, &ws.y); +// cout << ws << endl; +// return ws; + if (settings.windowMode == OF_GAME_MODE) { const GLFWvidmode * desktopMode = glfwGetVideoMode(glfwGetWindowMonitor(windowP)); if (desktopMode) { @@ -577,7 +577,7 @@ glm::ivec2 ofAppGLFWWindow::getWindowSize() { //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getWindowPosition() { - glm::ivec2 pos { 0, 0 }; + glm::ivec2 pos; glfwGetWindowPos( windowP, &pos.x, &pos.y ); // if ( orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT ) { // std::swap(pos.x, pos.y); @@ -652,11 +652,6 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { return windowP; } -//------------------------------------------------------------ -ofWindowMode ofAppGLFWWindow::getWindowMode() { - return settings.windowMode; -} - //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRectangle(const ofRectangle & rect) { // cout << "setWindowRectangle " << rect << endl; @@ -938,8 +933,8 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // make sure to save current pos if not specified in settings if (settings.isPositionSet()) { - auto pos = getWindowPosition(); - settings.setPosition(ofVec2f(pos.x, pos.y)); + // FIXME: This is a little absurd + settings.setPosition(getWindowPosition()); } //make sure the window is getting the mouse/key events diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 30181297fd2..fbeaa0a1b5e 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -19,57 +19,15 @@ class ofPixels_; typedef ofPixels_ ofPixels; -#ifdef TARGET_OPENGLES -// FIXME: Rever o nome ofAppBaseXWindow, aplicar no resto do codigo o typedef -typedef ofAppBaseGLESWindow ofAppBaseXWindow; -typedef ofGLESWindowSettings ofSetupWindowSettings; -#else -typedef ofAppBaseGLWindow ofAppBaseXWindow; -typedef ofGLWindowSettings ofSetupWindowSettings; -#endif - -class ofGLFWWindowSettings: public ofSetupWindowSettings { -public: - ofGLFWWindowSettings() { } - - ofGLFWWindowSettings(const ofSetupWindowSettings & settings) - :ofSetupWindowSettings(settings){} - -#ifdef TARGET_RASPBERRY_PI - int numSamples = 0; -#else - int numSamples = 4; -#endif - - bool doubleBuffering = true; - int redBits = 8; - int greenBits = 8; - int blueBits = 8; - int alphaBits = 8; - int depthBits = 24; - int stencilBits = 0; - bool stereo = false; - bool visible = true; - bool iconified = false; - bool decorated = true; - bool resizable = true; - bool transparent = false; - bool maximized = false; - int monitor = 0; - bool multiMonitorFullScreen = false; - std::shared_ptr shareContextWith; -}; - -#ifdef TARGET_OPENGLES -class ofAppGLFWWindow : public ofAppBaseGLESWindow { -#else -class ofAppGLFWWindow : public ofAppBaseGLWindow { -#endif - +class ofAppGLFWWindow : public ofAppBaseWindow { public: ofAppGLFWWindow(); ~ofAppGLFWWindow(); + + +// ofWindowMode getWindowMode() { return settings.windowMode; } + // Can't be copied, use shared_ptr ofAppGLFWWindow(ofAppGLFWWindow & w) = delete; ofAppGLFWWindow & operator=(ofAppGLFWWindow & w) = delete; @@ -83,8 +41,7 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { // this functions are only meant to be called from inside OF don't call them from your code using ofAppBaseWindow::setup; - void setup(const ofSetupWindowSettings & settings); - void setup(const ofGLFWWindowSettings & settings); + void setup(const ofWindowSettings & settings); void update(); void draw(); bool getWindowShouldClose(); @@ -101,7 +58,7 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { GLFWwindow * getGLFWWindow(); void * getWindowContext() { return getGLFWWindow(); } - ofGLFWWindowSettings getSettings() { return settings; } + ofWindowSettings getSettings() { return settings; } glm::ivec2 getWindowSize(); glm::ivec2 getScreenSize(); @@ -160,7 +117,7 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { Window getX11Window(); XIC getX11XIC(); - void setWindowIcon(const std::string & path); + void setWindowIcon(const of::filesystem::path & path); void setWindowIcon(const ofPixels & iconPixels); #endif @@ -209,7 +166,6 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { std::unique_ptr coreEvents; std::shared_ptr currentRenderer; - ofGLFWWindowSettings settings; ofWindowMode targetWindowMode; diff --git a/libs/openFrameworks/app/ofAppGlutWindow.h b/libs/openFrameworks/app/ofAppGlutWindow.h index 4aa56730fc1..f9c1a3b73ce 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.h +++ b/libs/openFrameworks/app/ofAppGlutWindow.h @@ -16,8 +16,7 @@ typedef ofPixels & ofPixelsRef; class ofBaseApp; class ofBaseRenderer; -class ofAppGlutWindow : public ofAppBaseGLWindow { - +class ofAppGlutWindow : public ofAppBaseWindow { public: ofAppGlutWindow(); @@ -30,7 +29,7 @@ class ofAppGlutWindow : public ofAppBaseGLWindow { static void pollEvents(){ } using ofAppBaseWindow::setup; - void setup(const ofGLWindowSettings & settings); + void setup(const ofWindowSettings & settings); void update(); void draw(); void close(); diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index f37490ae28b..8549a97ab84 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -203,11 +203,10 @@ int ofRunMainLoop(){ //-------------------------------------- void ofSetupOpenGL(int w, int h, ofWindowMode screenMode){ + ofWindowSettings settings; #ifdef TARGET_OPENGLES - ofGLESWindowSettings settings; settings.glesVersion = 1; #else - ofGLWindowSettings settings; settings.glVersionMajor = 2; settings.glVersionMinor = 1; #endif @@ -447,6 +446,7 @@ float ofRandomHeight() { } //-------------------------------------------------- +// FIXME: This is wrong. doesn't consider window offset. ofRectangle ofGetWindowRect() { return ofRectangle(0, 0, ofGetWindowWidth(), ofGetWindowHeight()); } diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index 782ce556f4d..9e5fc64af45 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -1,5 +1,7 @@ #pragma once +class ofAppBaseWindow; + #define GLM_FORCE_CTOR_INIT #include "glm/vec2.hpp" #include @@ -35,22 +37,15 @@ enum ofOrientation: short{ OF_ORIENTATION_UNKNOWN = 5 }; -class ofWindowSettings{ +class ofWindowSettings { public: - ofWindowSettings() - :windowMode(OF_WINDOW) - ,width(1024) - ,height(768) - ,sizeSet(false) - ,position(0,0) - ,positionSet(false){} - + ofWindowSettings(){} virtual ~ofWindowSettings(){}; - + std::string title; - ofWindowMode windowMode; + ofWindowMode windowMode = OF_WINDOW; - void setPosition(const glm::vec2 & position) { + void setPosition(const glm::ivec2 & position) { this->position = position; this->positionSet = true; } @@ -73,7 +68,7 @@ class ofWindowSettings{ return height; } - const glm::vec2 & getPosition() const { + const glm::ivec2 & getPosition() const { return position; } @@ -81,60 +76,51 @@ class ofWindowSettings{ return positionSet; } -protected: - int width; - int height; - bool sizeSet; - glm::vec2 position; - bool positionSet; -}; - -class ofGLWindowSettings: public ofWindowSettings{ -public: - ofGLWindowSettings() - :glVersionMajor(2) - ,glVersionMinor(1){} - - ofGLWindowSettings(const ofWindowSettings & settings) - :ofWindowSettings(settings) - ,glVersionMajor(2) - ,glVersionMinor(1){ - const ofGLWindowSettings * glSettings = dynamic_cast(&settings); - if(glSettings){ - glVersionMajor = glSettings->glVersionMajor; - glVersionMinor = glSettings->glVersionMinor; - } - } - - virtual ~ofGLWindowSettings(){}; - - void setGLVersion(int major, int minor){ + void setGLVersion(int major, int minor) { glVersionMajor = major; glVersionMinor = minor; } - - int glVersionMajor; - int glVersionMinor; -}; - -class ofGLESWindowSettings: public ofWindowSettings{ -public: - ofGLESWindowSettings() - :glesVersion(1){} - - ofGLESWindowSettings(const ofWindowSettings & settings) - :ofWindowSettings(settings), glesVersion(1) { - const ofGLESWindowSettings * glesSettings = dynamic_cast(&settings); - if(glesSettings){ - glesVersion = glesSettings->glesVersion; - } - } - - virtual ~ofGLESWindowSettings(){}; - + void setGLESVersion(int version){ glesVersion = version; } - int glesVersion; + int glVersionMajor = 2; + int glVersionMinor = 1; + + int glesVersion = 1; + + + // GLFW specific ones +#ifdef TARGET_RASPBERRY_PI + int numSamples = 0; +#else + int numSamples = 4; +#endif + + bool doubleBuffering = true; + int redBits = 8; + int greenBits = 8; + int blueBits = 8; + int alphaBits = 8; + int depthBits = 24; + int stencilBits = 0; + bool stereo = false; + bool visible = true; + bool iconified = false; + bool decorated = true; + bool resizable = true; + bool transparent = false; + bool maximized = false; + int monitor = 0; + bool multiMonitorFullScreen = false; + std::shared_ptr shareContextWith; + + +protected: + int width { 1024 }; + int height { 768 }; + bool sizeSet { false }; + glm::ivec2 position { 0, 0 }; + bool positionSet { false }; }; diff --git a/scripts/osx/cc.sh b/scripts/osx/cc.sh index c4814cd5272..e501e02aa68 100755 --- a/scripts/osx/cc.sh +++ b/scripts/osx/cc.sh @@ -1,2 +1,3 @@ #!/bin/zsh ${ccache} clang "$@" +# clang "$@" diff --git a/scripts/osx/cxx.sh b/scripts/osx/cxx.sh index 48bd528bffa..ab44ff4837c 100755 --- a/scripts/osx/cxx.sh +++ b/scripts/osx/cxx.sh @@ -1,3 +1,4 @@ #!/bin/zsh ${ccache} clang++ "$@" +# clang++ "$@" From eec5842c727474d00a122bde10b0f717e2d444ba Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 14:34:30 -0300 Subject: [PATCH 008/143] more --- libs/openFrameworks/app/ofAppBaseWindow.h | 26 +++-- libs/openFrameworks/app/ofAppEGLWindow.cpp | 14 +-- libs/openFrameworks/app/ofAppEGLWindow.h | 2 +- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 102 ++++++++---------- libs/openFrameworks/app/ofAppGLFWWindow.h | 10 +- libs/openFrameworks/app/ofAppRunner.cpp | 4 +- libs/openFrameworks/app/ofAppRunner.h | 2 +- .../project/osx/config.osx.default.mk | 2 +- 8 files changed, 76 insertions(+), 86 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index ef266510c27..a07ddc0c7b8 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -3,11 +3,12 @@ #include "ofWindowSettings.h" // MARK: Target #include "ofConstants.h" +//class ofRectangle; +#include "ofRectangle.h" class ofBaseApp; class ofBaseRenderer; class ofCoreEvents; -class ofRectangle; #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) struct __GLXcontextRec; @@ -24,33 +25,41 @@ class ofAppBaseWindow { public: ofAppBaseWindow(){} - virtual ~ofAppBaseWindow(){} +// virtual ~ofAppBaseWindow(){} + ~ofAppBaseWindow(){} // virtual void setup(const ofWindowSettings & settings); - virtual void setup(const ofWindowSettings & settings){ - - } + virtual void setup(const ofWindowSettings & settings)=0; virtual void update()=0; virtual void draw()=0; + virtual std::shared_ptr & renderer() = 0; + virtual ofCoreEvents & events() = 0; + +// virtual void setup(const ofWindowSettings & settings) {}; +// virtual void update() {}; +// virtual void draw() {}; +// virtual std::shared_ptr & renderer() =0; +// virtual ofCoreEvents & events() =0; + + virtual bool getWindowShouldClose(){ return false; } virtual void setWindowShouldClose(){} virtual void close(){} - virtual ofCoreEvents & events() = 0; - virtual std::shared_ptr & renderer() = 0; virtual void hideCursor(){} virtual void showCursor(){} virtual void setWindowPosition(int x, int y){} virtual void setWindowShape(int w, int h){} - virtual void setWindowRectangle(const ofRectangle & rect){} + virtual void setWindowRect(const ofRectangle & rect){} virtual glm::ivec2 getWindowPosition() { return glm::vec2(); } virtual glm::ivec2 getWindowSize() { return glm::vec2(); } virtual glm::ivec2 getScreenSize() { return glm::vec2(); } + virtual ofRectangle getWindowRect() { return ofRectangle(); } virtual void setOrientation(ofOrientation orientationIn) { orientation = orientationIn; } virtual ofOrientation getOrientation() { return orientation; } @@ -63,7 +72,6 @@ class ofAppBaseWindow { virtual void setWindowTitle(const std::string & title){} virtual ofWindowMode getWindowMode() { return settings.windowMode; } - virtual void setFullscreen(bool fullscreen){} virtual void toggleFullscreen(){} diff --git a/libs/openFrameworks/app/ofAppEGLWindow.cpp b/libs/openFrameworks/app/ofAppEGLWindow.cpp index 32ded88d460..f4dcfd232eb 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.cpp +++ b/libs/openFrameworks/app/ofAppEGLWindow.cpp @@ -838,9 +838,9 @@ void ofAppEGLWindow::draw() { // take care of any requests for a new screen mode if (windowMode != OF_GAME_MODE && bNewScreenMode){ if( windowMode == OF_FULLSCREEN){ - setWindowRectangle(getScreenRect()); + setWindowRect(getScreenRect()); } else if( windowMode == OF_WINDOW ){ - setWindowRectangle(nonFullscreenWindowRect); + setWindowRect(nonFullscreenWindowRect); } bNewScreenMode = false; } @@ -917,9 +917,9 @@ void ofAppEGLWindow::destroyNativeEvents() { } //------------------------------------------------------------ -void ofAppEGLWindow::setWindowRectangle(const ofRectangle& requestedWindowRect) { +void ofAppEGLWindow::setWindowRect(const ofRectangle& requestedWindowRect) { if(!isWindowInited) { - ofLogError("ofAppEGLWindow") << "setWindowRectangle(): window not inited"; + ofLogError("ofAppEGLWindow") << "setWindowRect(): window not inited"; return; } @@ -936,9 +936,9 @@ void ofAppEGLWindow::setWindowRectangle(const ofRectangle& requestedWindowRect) (unsigned int)newRect.width, (unsigned int)newRect.height); if(ret == BadValue) { - ofLogError("ofAppEGLWindow") << "setWindowRectangle(): XMoveResizeWindow returned BadValue"; + ofLogError("ofAppEGLWindow") << "setWindowRect(): XMoveResizeWindow returned BadValue"; } else if(ret == BadWindow) { - ofLogError("ofAppEGLWindow") << "setWindowRectangle(): XMoveResizeWindow returned BadWindow"; + ofLogError("ofAppEGLWindow") << "setWindowRect(): XMoveResizeWindow returned BadWindow"; } else { // all is good currentWindowRect = newRect; @@ -1231,7 +1231,7 @@ void ofAppEGLWindow::setWindowShape(int w, int h){ } } else { #ifdef TARGET_RASPBERRY_PI_LEGACY - setWindowRectangle(ofRectangle(currentWindowRect.x,currentWindowRect.y,w,h)); + setWindowRect(ofRectangle(currentWindowRect.x,currentWindowRect.y,w,h)); nonFullscreenWindowRect = currentWindowRect; #else ofLogError("ofAppEGLWindow") << "setWindowPosition(): no native window type for this system, perhaps try X11?"; diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index c66a6b83aad..819246203a7 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -89,7 +89,7 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { void setWindowPosition(int x, int y); void setWindowShape(int w, int h); - void setWindowRectangle(const ofRectangle & rect); + void setWindowRect(const ofRectangle & rect); glm::ivec2 getWindowPosition(); glm::ivec2 getWindowSize(); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index feb5cafbb02..c6f888c8083 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -557,32 +557,25 @@ int ofAppGLFWWindow::getPixelScreenCoordScale() { } //------------------------------------------------------------ -glm::ivec2 ofAppGLFWWindow::getWindowSize() { -// glm::ivec2 ws; -// glfwGetWindowPos(windowP, &ws.x, &ws.y); -// cout << ws << endl; -// return ws; +ofRectangle ofAppGLFWWindow::getWindowRect() { + glm::ivec2 pos; + glfwGetWindowPos( windowP, &pos.x, &pos.y ); + glm::ivec2 size; + glfwGetWindowSize(windowP, &size.x, &size.y); + return ofRectangle(pos.x, pos.y, size.x, size.y); +} - if (settings.windowMode == OF_GAME_MODE) { - const GLFWvidmode * desktopMode = glfwGetVideoMode(glfwGetWindowMonitor(windowP)); - if (desktopMode) { - return { desktopMode->width * pixelScreenCoordScale, desktopMode->height * pixelScreenCoordScale }; - } else { - return { currentW * pixelScreenCoordScale, currentH * pixelScreenCoordScale }; - } - } else { - return { currentW * pixelScreenCoordScale, currentH * pixelScreenCoordScale }; - } +//------------------------------------------------------------ +glm::ivec2 ofAppGLFWWindow::getWindowSize() { + glm::ivec2 size; + glfwGetWindowSize(windowP, &size.x, &size.y); + return size; } //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getWindowPosition() { glm::ivec2 pos; glfwGetWindowPos( windowP, &pos.x, &pos.y ); - // if ( orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT ) { - // std::swap(pos.x, pos.y); - // } - // return pos * glm::vec2 { pixelScreenCoordScale, pixelScreenCoordScale }; return pos; } @@ -653,8 +646,8 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { } //------------------------------------------------------------ -void ofAppGLFWWindow::setWindowRectangle(const ofRectangle & rect) { -// cout << "setWindowRectangle " << rect << endl; +void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { +// cout << "setWindowRect " << rect << endl; if(settings.windowMode == OF_WINDOW){ windowW = rect.width; windowH = rect.height; @@ -723,17 +716,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { targetWindowMode = OF_WINDOW; } -#if defined(TARGET_OSX) - NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); - if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { - settings.windowMode = OF_FULLSCREEN; - if (targetWindowMode == OF_WINDOW) { - [cocoaWindow toggleFullScreen:nil]; - } - } else { - [cocoaWindow setHasShadow:NO]; - } -#endif + //we only want to change window mode if the requested window is different to the current one. bool bChanged = targetWindowMode != settings.windowMode; @@ -864,14 +847,31 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // setWindowShape(windowW, windowH); + + #elif defined(TARGET_OSX) + NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); + if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { + if (targetWindowMode == OF_WINDOW) { + [cocoaWindow toggleFullScreen:nil]; + } else { + settings.windowMode = OF_FULLSCREEN; + } + } + if (targetWindowMode == OF_FULLSCREEN) { - //---------------------------------------------------- [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; - NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); - [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; + [cocoaWindow setHasShadow:YES]; + } else { + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; + [cocoaWindow setHasShadow:NO]; + } + + if (targetWindowMode == OF_FULLSCREEN) { + //---------------------------------------------------- int monitorCount; GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); @@ -879,19 +879,11 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { int currentMonitor = getCurrentMonitor(); auto screenSize = getScreenSize(); - if (orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT) { - std::swap(screenSize.x, screenSize.y); - } - ofRectangle allScreensSpace; // save window shape before going fullscreen - auto pos = getWindowPosition(); - auto size = getWindowSize(); - windowRect.x = pos.x; - windowRect.y = pos.y; - windowRect.width = size.x; - windowRect.height = size.y; + windowRect = getWindowRect(); + cout << "windowRect " << windowRect << endl; if (settings.multiMonitorFullScreen && monitorCount > 1) { @@ -936,10 +928,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // FIXME: This is a little absurd settings.setPosition(getWindowPosition()); } - - //make sure the window is getting the mouse/key events - [cocoaWindow makeFirstResponder:cocoaWindow.contentView]; - } else if (targetWindowMode == OF_WINDOW) { // set window shape if started in fullscreen @@ -953,10 +941,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { setWindowShape(windowRect.width, windowRect.height); setWindowTitle(settings.title); - [NSApp setPresentationOptions:NSApplicationPresentationDefault]; - NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); - [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; - //---------------------------------------------------- // if we have recorded the screen position, put it there // if not, better to let the system do it (and put it where it wants) @@ -964,10 +948,12 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { setWindowPosition(windowRect.x, windowRect.y); } - //---------------------------------------------------- - //make sure the window is getting the mouse/key events - [cocoaWindow makeFirstResponder:cocoaWindow.contentView]; } + + //---------------------------------------------------- + //make sure the window is getting the mouse/key events + [cocoaWindow makeFirstResponder:cocoaWindow.contentView]; + #elif defined(TARGET_WIN32) if (targetWindowMode == OF_FULLSCREEN) { // save window shape before going fullscreen @@ -988,10 +974,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { float fullscreenW = getScreenSize().x; float fullscreenH = getScreenSize().y; - if (orientation == OF_ORIENTATION_90_LEFT || orientation == OF_ORIENTATION_90_RIGHT) { - std::swap(fullscreenW, fullscreenH); - } - int xpos = 0; int ypos = 0; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index fbeaa0a1b5e..d785c2da534 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -14,6 +14,7 @@ typedef struct _XIC * XIC; class ofBaseApp; struct GLFWwindow; class ofCoreEvents; + template class ofPixels_; typedef ofPixels_ ofPixels; @@ -24,8 +25,6 @@ class ofAppGLFWWindow : public ofAppBaseWindow { ofAppGLFWWindow(); ~ofAppGLFWWindow(); - - // ofWindowMode getWindowMode() { return settings.windowMode; } // Can't be copied, use shared_ptr @@ -39,7 +38,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { static void pollEvents(); // this functions are only meant to be called from inside OF don't call them from your code - using ofAppBaseWindow::setup; +// using ofAppBaseWindow::setup; void setup(const ofWindowSettings & settings); void update(); @@ -60,13 +59,14 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void * getWindowContext() { return getGLFWWindow(); } ofWindowSettings getSettings() { return settings; } - glm::ivec2 getWindowSize(); glm::ivec2 getScreenSize(); + glm::ivec2 getWindowSize(); glm::ivec2 getWindowPosition(); + ofRectangle getWindowRect(); void setWindowTitle(const std::string & title); - void setWindowRectangle(const ofRectangle & rect); + void setWindowRect(const ofRectangle & rect); void setWindowPosition(int x, int y); void setWindowShape(int w, int h); diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 8549a97ab84..edf1470ae19 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -371,8 +371,8 @@ void ofSetWindowShape(int width, int height){ } //-------------------------------------- -void ofSetWindowRectangle(const ofRectangle & rect){ - mainLoop()->getCurrentWindow()->setWindowRectangle(rect); +void ofSetWindowRect(const ofRectangle & rect){ + mainLoop()->getCurrentWindow()->setWindowRect(rect); } //-------------------------------------- diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index b8c087026d0..e7dd8f3a98b 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -97,7 +97,7 @@ std::shared_ptr ofGetCurrentWindow(); void ofSetWindowPosition(int x, int y); void ofSetWindowShape(int width, int height); -void ofSetWindowRectangle(const ofRectangle & rect); +void ofSetWindowRect(const ofRectangle & rect); void ofSetWindowTitle(std::string title); void ofEnableSetupScreen(); void ofDisableSetupScreen(); diff --git a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk index dd1dc35cc7c..4926da1687e 100644 --- a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk +++ b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk @@ -226,7 +226,7 @@ PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cp # third party -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/boost/include/boost/% +PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/boost/% ifeq ($(USE_FMOD),0) From 3508e3a3239460407a2b618532c5e1d1edd52666 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 16:13:25 -0300 Subject: [PATCH 009/143] more simplification --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 170 +++++--------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 2 +- 2 files changed, 42 insertions(+), 130 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index c6f888c8083..be4f5063321 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -315,11 +315,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { windowW = settings.getWidth(); windowH = settings.getHeight(); -#ifdef TARGET_RASPBERRY_PI - windowRect.width = windowW; - windowRect.height = windowH; -#endif - glfwMakeContextCurrent(windowP); int framebufferW, framebufferH, tmpWindowW, tmpWindowH; @@ -647,41 +642,37 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { -// cout << "setWindowRect " << rect << endl; - if(settings.windowMode == OF_WINDOW){ - windowW = rect.width; - windowH = rect.height; - } - currentW = rect.width; - currentH = rect.height; - // Now using just one GLFW call to set the entire rectangle. - glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, currentW, currentH, GLFW_DONT_CARE); + glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } //------------------------------------------------------------ void ofAppGLFWWindow::setWindowPosition(int x, int y) { - glfwSetWindowPos(windowP, x / pixelScreenCoordScale, y / pixelScreenCoordScale); +// glfwSetWindowPos(windowP, x / pixelScreenCoordScale, y / pixelScreenCoordScale); + glfwSetWindowPos(windowP, x, y); } //------------------------------------------------------------ void ofAppGLFWWindow::setWindowShape(int w, int h) { - if (settings.windowMode == OF_WINDOW) { - windowW = w; - windowH = h; - } - currentW = w / pixelScreenCoordScale; - currentH = h / pixelScreenCoordScale; +// if (settings.windowMode == OF_WINDOW) { +// windowW = w; +// windowH = h; +// } +// currentW = w / pixelScreenCoordScale; +// currentH = h / pixelScreenCoordScale; +// +//#ifdef TARGET_OSX +// auto pos = getWindowPosition(); +// glfwSetWindowSize(windowP, currentW, currentH); +// if (pos != getWindowPosition()) { +// setWindowPosition(pos.x, pos.y); +// } +//#else +// glfwSetWindowSize(windowP, currentW, currentH); +//#endif + + glfwSetWindowSize(windowP, w, h); -#ifdef TARGET_OSX - auto pos = getWindowPosition(); - glfwSetWindowSize(windowP, currentW, currentH); - if (pos != getWindowPosition()) { - setWindowPosition(pos.x, pos.y); - } -#else - glfwSetWindowSize(windowP, currentW, currentH); -#endif } //------------------------------------------------------------ @@ -711,6 +702,8 @@ void ofAppGLFWWindow::disableSetupScreen() { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { if (fullscreen) { + // save window shape before going fullscreen + windowRect = getWindowRect(); targetWindowMode = OF_FULLSCREEN; } else { targetWindowMode = OF_WINDOW; @@ -731,14 +724,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { Display * display = glfwGetX11Display(); if (targetWindowMode == OF_FULLSCREEN) { - #ifdef TARGET_RASPBERRY_PI - // save window shape before going fullscreen - if (windowP) { - int tmpW, tmpH; - glfwGetWindowSize(windowP, &tmpW, &tmpH); - windowRect.setSize(tmpW, tmpH); - } - #endif int monitorCount; GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); @@ -863,91 +848,32 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { if (targetWindowMode == OF_FULLSCREEN) { [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; - [cocoaWindow setHasShadow:YES]; + [cocoaWindow setHasShadow:NO]; } else { [NSApp setPresentationOptions:NSApplicationPresentationDefault]; [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; - [cocoaWindow setHasShadow:NO]; + [cocoaWindow setHasShadow:YES]; } if (targetWindowMode == OF_FULLSCREEN) { //---------------------------------------------------- - - int monitorCount; - GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); - - int currentMonitor = getCurrentMonitor(); - auto screenSize = getScreenSize(); - - ofRectangle allScreensSpace; - - // save window shape before going fullscreen - windowRect = getWindowRect(); - cout << "windowRect " << windowRect << endl; - - if (settings.multiMonitorFullScreen && monitorCount > 1) { - - //calc the sum Rect of all the monitors - for (int i = 0; i < monitorCount; i++) { - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitors[i]); - int x, y; - glfwGetMonitorPos(monitors[i], &x, &y); - ofRectangle screen = ofRectangle(x, y, desktopMode->width, desktopMode->height); - allScreensSpace = allScreensSpace.getUnion(screen); - } - //for OS X we need to set this first as the window size affects the window positon - //need to account for the pixel density factor when we're getting the values from glfw - setWindowShape(allScreensSpace.width * pixelScreenCoordScale, allScreensSpace.height * pixelScreenCoordScale); - setWindowPosition(allScreensSpace.x, allScreensSpace.y); - - } else if (monitorCount > 1 && currentMonitor < monitorCount) { - int xpos; - int ypos; - glfwGetMonitorPos(monitors[currentMonitor], &xpos, &ypos); - - // Scale (if needed) to physical pixels size, since setWindowPosition - // uses physical pixel dimensions. On HIDPI screens pixelScreenCoordScale - // is likely to be 2, on "normal" screens pixelScreenCoordScale will be 1: - xpos *= pixelScreenCoordScale; - ypos *= pixelScreenCoordScale; - - //we do this as setWindowShape affects the position of the monitor - //normally we would just call setWindowShape first, but on multi monitor you see the window bleed onto the second monitor as it first changes shape and is then repositioned. - //this first moves it over in X, does the screen resize and then by calling it again its set correctly in y. - setWindowPosition(xpos, ypos); - setWindowShape(screenSize.x, screenSize.y); - setWindowPosition(xpos, ypos); - } else { - //for OS X we need to set this first as the window size affects the window positon - setWindowShape(screenSize.x, screenSize.y); - setWindowPosition(0, 0); - } - - // make sure to save current pos if not specified in settings - if (settings.isPositionSet()) { - // FIXME: This is a little absurd - settings.setPosition(getWindowPosition()); - } - } else if (targetWindowMode == OF_WINDOW) { - - // set window shape if started in fullscreen - if (windowRect.width == 0 && windowRect.height == 0) { - windowRect.x = getWindowPosition().x; - windowRect.y = getWindowPosition().y; - windowRect.width = getWindowSize().x; - windowRect.height = getWindowSize().y; - } - - setWindowShape(windowRect.width, windowRect.height); + + GLFWmonitor* monitor = glfwGetWindowMonitor(windowP); + const GLFWvidmode * desktopMode = glfwGetVideoMode(monitor); + glm::ivec2 pos; + glfwGetMonitorPos(monitor, &pos.x, &pos.y); + + ofRectangle fsRect { (float)pos.x, (float)pos.y, (float)desktopMode->width, (float)desktopMode->height }; + // FIXME: TODO: Get rectangle for multiple windows. +// if (settings.multiMonitorFullScreen && monitorCount > 1) { +//// fsRect = +// } + setWindowRect(fsRect); + } + + else if (targetWindowMode == OF_WINDOW) { + setWindowRect(windowRect); setWindowTitle(settings.title); - - //---------------------------------------------------- - // if we have recorded the screen position, put it there - // if not, better to let the system do it (and put it where it wants) - if (ofGetFrameNum() > 0) { - setWindowPosition(windowRect.x, windowRect.y); - } - } //---------------------------------------------------- @@ -956,13 +882,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { #elif defined(TARGET_WIN32) if (targetWindowMode == OF_FULLSCREEN) { - // save window shape before going fullscreen - auto pos = getWindowPosition(); - auto size = getWindowSize(); - windowRect.x = pos.x; - windowRect.y = pos.y; - windowRect.width = size.x; - windowRect.height = size.y; //---------------------------------------------------- HWND hwnd = glfwGetWin32Window(windowP); @@ -1016,13 +935,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { currentH = fullscreenH; } else if (targetWindowMode == OF_WINDOW) { - // set window shape if started in fullscreen - if (windowRect.width == 0 && windowRect.height == 0) { - windowRect.x = getWindowPosition().x; - windowRect.y = getWindowPosition().y; - windowRect.width = getWindowSize().x; - windowRect.height = getWindowSize().y; - } HWND hwnd = glfwGetWin32Window(windowP); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index d785c2da534..acd1804be57 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -174,7 +174,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { int currentW, currentH; /// Extents of the window client area, which may be scaled by pixelsScreenCoordScale to map to physical framebuffer pixels. float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH). - ofRectangle windowRect; + ofRectangle windowRect { 20, 20, 1024, 768 }; int buttonInUse; bool buttonPressed; From 9902141c50cbfec6765b4cb9f9947a5c626e817a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 16:36:30 -0300 Subject: [PATCH 010/143] typedefs --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 21 +-------------------- libs/openFrameworks/app/ofWindowSettings.h | 3 +++ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index be4f5063321..c42e309d724 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -230,6 +230,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; } + if (settings.windowMode == OF_FULLSCREEN) { int count = 0; auto monitors = glfwGetMonitors(&count); @@ -642,37 +643,17 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { - // Now using just one GLFW call to set the entire rectangle. glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } //------------------------------------------------------------ void ofAppGLFWWindow::setWindowPosition(int x, int y) { -// glfwSetWindowPos(windowP, x / pixelScreenCoordScale, y / pixelScreenCoordScale); glfwSetWindowPos(windowP, x, y); } //------------------------------------------------------------ void ofAppGLFWWindow::setWindowShape(int w, int h) { -// if (settings.windowMode == OF_WINDOW) { -// windowW = w; -// windowH = h; -// } -// currentW = w / pixelScreenCoordScale; -// currentH = h / pixelScreenCoordScale; -// -//#ifdef TARGET_OSX -// auto pos = getWindowPosition(); -// glfwSetWindowSize(windowP, currentW, currentH); -// if (pos != getWindowPosition()) { -// setWindowPosition(pos.x, pos.y); -// } -//#else -// glfwSetWindowSize(windowP, currentW, currentH); -//#endif - glfwSetWindowSize(windowP, w, h); - } //------------------------------------------------------------ diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index 9e5fc64af45..e525631ab60 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -124,3 +124,6 @@ class ofWindowSettings { glm::ivec2 position { 0, 0 }; bool positionSet { false }; }; + +typedef ofWindowSettings ofGLWindowSettings; +typedef ofWindowSettings ofGLESWindowSettings; From 2a80aa2123fe46aac7925b1e88e23a5669652744 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 16:48:31 -0300 Subject: [PATCH 011/143] shared ptr fix --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 12 +++--------- libs/openFrameworks/app/ofWindowSettings.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index c42e309d724..a3ad47692a1 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -683,20 +683,15 @@ void ofAppGLFWWindow::disableSetupScreen() { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { if (fullscreen) { + targetWindowMode = OF_FULLSCREEN; // save window shape before going fullscreen windowRect = getWindowRect(); - targetWindowMode = OF_FULLSCREEN; } else { targetWindowMode = OF_WINDOW; } - - //we only want to change window mode if the requested window is different to the current one. - bool bChanged = targetWindowMode != settings.windowMode; - if (!bChanged) { - return; - } + if (targetWindowMode == settings.windowMode) return; #ifdef TARGET_LINUX #include @@ -837,9 +832,8 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { } if (targetWindowMode == OF_FULLSCREEN) { - //---------------------------------------------------- - GLFWmonitor* monitor = glfwGetWindowMonitor(windowP); + const GLFWvidmode * desktopMode = glfwGetVideoMode(monitor); glm::ivec2 pos; glfwGetMonitorPos(monitor, &pos.x, &pos.y); diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index e525631ab60..c9d9c8120c7 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -5,6 +5,7 @@ class ofAppBaseWindow; #define GLM_FORCE_CTOR_INIT #include "glm/vec2.hpp" #include +#include /// \brief Used to represent the available windowing modes for the application. enum ofWindowMode{ @@ -116,7 +117,6 @@ class ofWindowSettings { bool multiMonitorFullScreen = false; std::shared_ptr shareContextWith; - protected: int width { 1024 }; int height { 768 }; From 0082f441e4801e558b90af6d0c4d1673463bac23 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 16:52:48 -0300 Subject: [PATCH 012/143] emscripten --- addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp | 2 +- addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index 9da595ce412..db973562405 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -27,7 +27,7 @@ ofxAppEmscriptenWindow::~ofxAppEmscriptenWindow() { } //------------------------------------------------------------ -void ofxAppEmscriptenWindow::setup(const ofGLESWindowSettings & settings){ +void ofxAppEmscriptenWindow::setup(const ofWindowSettings & settings){ setWindowShape(settings.getWidth(),settings.getHeight()); EmscriptenWebGLContextAttributes attrs; diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h index 4d871d73be9..10d8934a23b 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h @@ -16,7 +16,7 @@ #include #include // For Emscripten WebGL API headers (see also webgl/webgl1_ext.h and webgl/webgl2.h) -class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { +class ofxAppEmscriptenWindow: public ofAppBaseWindow { public: ofxAppEmscriptenWindow(); ~ofxAppEmscriptenWindow(); @@ -28,7 +28,7 @@ class ofxAppEmscriptenWindow: public ofAppBaseGLESWindow { static void loop(); - void setup(const ofGLESWindowSettings & settings); + void setup(const ofWindowSettings & settings); void hideCursor(); // void showCursor(); From 6d39ddebcab3acca53aa594e28f3ca96bb15f3e3 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 16:59:57 -0300 Subject: [PATCH 013/143] remove glut window --- libs/openFrameworks/app/ofAppGlutWindow.cpp | 4 ++-- libs/openFrameworks/app/ofMainLoop.cpp | 2 -- libs/openFrameworks/ofMain.h | 12 ++++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGlutWindow.cpp b/libs/openFrameworks/app/ofAppGlutWindow.cpp index 7992817cd09..db0559a1a11 100644 --- a/libs/openFrameworks/app/ofAppGlutWindow.cpp +++ b/libs/openFrameworks/app/ofAppGlutWindow.cpp @@ -29,7 +29,6 @@ // glut works with static callbacks UGH, so we need static variables here: -static ofWindowMode windowMode; static bool bNewScreenMode; static int buttonInUse; static bool bEnableSetupScreen; @@ -42,7 +41,8 @@ static int nonFullScreenY; static int windowW; static int windowH; static int nFramesSinceWindowResized; -static ofOrientation orientation; +//static ofWindowMode windowMode; +//static ofOrientation orientation; static ofAppGlutWindow * instance; #ifdef TARGET_WIN32 diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index dfb2c0bcc83..7b871d49773 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -19,8 +19,6 @@ #include "ofAppAndroidWindow.h" #include "ofxAndroidUtils.h" #include "ofxAndroidApp.h" -#elif defined(TARGET_RASPBERRY_PI) && defined(TARGET_GLFW_WINDOW) - #include "ofAppGLFWWindow.h" #elif defined(TARGET_RASPBERRY_PI) #include "ofAppEGLWindow.h" #elif defined(TARGET_EMSCRIPTEN) diff --git a/libs/openFrameworks/ofMain.h b/libs/openFrameworks/ofMain.h index 3c6dcb3610a..3ea1ae12331 100644 --- a/libs/openFrameworks/ofMain.h +++ b/libs/openFrameworks/ofMain.h @@ -78,12 +78,12 @@ #include "ofBaseApp.h" #include "ofMainLoop.h" #include "ofWindowSettings.h" -#if !defined(TARGET_OF_IOS) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) - #include "ofAppGLFWWindow.h" - #if !defined(TARGET_LINUX_ARM) - #include "ofAppGlutWindow.h" - #endif -#endif +//#if !defined(TARGET_OF_IOS) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) +// #include "ofAppGLFWWindow.h" +// #if !defined(TARGET_LINUX_ARM) +// #include "ofAppGlutWindow.h" +// #endif +//#endif //-------------------------- // audio From 04990f09818e2661c6931f26946535d5f66d1d8b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 17:17:02 -0300 Subject: [PATCH 014/143] remove glut window, ofGetWindowPosition --- libs/openFrameworks/app/ofAppBaseWindow.h | 28 ------------------- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 31 +++++++++++++-------- libs/openFrameworks/app/ofAppRunner.cpp | 7 ++++- libs/openFrameworks/app/ofAppRunner.h | 1 + libs/openFrameworks/ofMain.h | 6 ++-- 5 files changed, 30 insertions(+), 43 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index a07ddc0c7b8..f060863f95a 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -121,31 +121,3 @@ class ofAppBaseWindow { ofOrientation orientation = OF_ORIENTATION_DEFAULT; ofWindowMode windowMode = OF_WINDOW; }; - -//class ofAppBaseGLWindow: public ofAppBaseWindow { -//public: -// virtual ~ofAppBaseGLWindow(){} -// virtual void setup(const ofWindowSettings & settings)=0; -// void setup(const ofWindowSettings & settings){ -// const ofGLWindowSettings * glSettings = dynamic_cast(&settings); -// if(glSettings){ -// setup(*glSettings); -// }else{ -// setup(ofGLWindowSettings(settings)); -// } -// } -//}; -// -//class ofAppBaseGLESWindow: public ofAppBaseWindow { -//public: -// virtual ~ofAppBaseGLESWindow(){} -// virtual void setup(const ofGLESWindowSettings & settings)=0; -// void setup(const ofWindowSettings & settings){ -// const ofGLESWindowSettings * glSettings = dynamic_cast(&settings); -// if(glSettings){ -// setup(*glSettings); -// }else{ -// setup(ofGLESWindowSettings(settings)); -// } -// } -//}; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index a3ad47692a1..c96a6c6592b 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -832,18 +832,27 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { } if (targetWindowMode == OF_FULLSCREEN) { + cout << "xx " << &windowP << " xx" << endl; + if (windowP == nullptr) { + cout << "windowP is nullptr" << endl; + } GLFWmonitor* monitor = glfwGetWindowMonitor(windowP); - - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitor); - glm::ivec2 pos; - glfwGetMonitorPos(monitor, &pos.x, &pos.y); - - ofRectangle fsRect { (float)pos.x, (float)pos.y, (float)desktopMode->width, (float)desktopMode->height }; - // FIXME: TODO: Get rectangle for multiple windows. -// if (settings.multiMonitorFullScreen && monitorCount > 1) { -//// fsRect = -// } - setWindowRect(fsRect); + if (!monitor) { + monitor = glfwGetPrimaryMonitor(); + } + if (monitor) { + + const GLFWvidmode * desktopMode = glfwGetVideoMode(monitor); + glm::ivec2 pos; + glfwGetMonitorPos(monitor, &pos.x, &pos.y); + + ofRectangle fsRect { (float)pos.x, (float)pos.y, (float)desktopMode->width, (float)desktopMode->height }; + // FIXME: TODO: Get rectangle for multiple windows. + // if (settings.multiMonitorFullScreen && monitorCount > 1) { + //// fsRect = + // } + setWindowRect(fsRect); + } } else if (targetWindowMode == OF_WINDOW) { diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index edf1470ae19..72d4299c47a 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -371,10 +371,15 @@ void ofSetWindowShape(int width, int height){ } //-------------------------------------- -void ofSetWindowRect(const ofRectangle & rect){ +void ofSetWindowRect(const ofRectangle & rect) { mainLoop()->getCurrentWindow()->setWindowRect(rect); } +//-------------------------------------- +glm::ivec2 ofGetWindowPosition() { + return mainLoop()->getCurrentWindow()->getWindowPosition(); +} + //-------------------------------------- int ofGetWindowPositionX(){ return (int)mainLoop()->getCurrentWindow()->getWindowPosition().x; diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index e7dd8f3a98b..4f573dab8de 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -71,6 +71,7 @@ ofOrientation ofGetOrientation(); void ofHideCursor(); void ofShowCursor(); //-------------------------- window / screen +glm::ivec2 ofGetWindowPosition(); int ofGetWindowPositionX(); int ofGetWindowPositionY(); int ofGetScreenWidth(); diff --git a/libs/openFrameworks/ofMain.h b/libs/openFrameworks/ofMain.h index 3ea1ae12331..602116e0589 100644 --- a/libs/openFrameworks/ofMain.h +++ b/libs/openFrameworks/ofMain.h @@ -78,12 +78,12 @@ #include "ofBaseApp.h" #include "ofMainLoop.h" #include "ofWindowSettings.h" -//#if !defined(TARGET_OF_IOS) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) -// #include "ofAppGLFWWindow.h" +#if !defined(TARGET_OF_IOS) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) + #include "ofAppGLFWWindow.h" // #if !defined(TARGET_LINUX_ARM) // #include "ofAppGlutWindow.h" // #endif -//#endif +#endif //-------------------------- // audio From 4fdeff735cbb236d6086fa8f4a311e494e5c0bc6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 17:38:02 -0300 Subject: [PATCH 015/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index c96a6c6592b..1dfa0bde7d0 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -643,6 +643,8 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { + cout << "setWindowRect " << rect << endl; + glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -653,6 +655,7 @@ void ofAppGLFWWindow::setWindowPosition(int x, int y) { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowShape(int w, int h) { + cout << "setWindowShape " << w << " : " << h << endl; glfwSetWindowSize(windowP, w, h); } @@ -684,14 +687,17 @@ void ofAppGLFWWindow::disableSetupScreen() { void ofAppGLFWWindow::setFullscreen(bool fullscreen) { if (fullscreen) { targetWindowMode = OF_FULLSCREEN; - // save window shape before going fullscreen - windowRect = getWindowRect(); } else { targetWindowMode = OF_WINDOW; } //we only want to change window mode if the requested window is different to the current one. if (targetWindowMode == settings.windowMode) return; + + if (targetWindowMode == OF_FULLSCREEN) { + // save window shape before going fullscreen + windowRect = getWindowRect(); + } #ifdef TARGET_LINUX #include @@ -832,21 +838,19 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { } if (targetWindowMode == OF_FULLSCREEN) { - cout << "xx " << &windowP << " xx" << endl; - if (windowP == nullptr) { - cout << "windowP is nullptr" << endl; - } +// cout << "xx " << &windowP << " xx" << endl; GLFWmonitor* monitor = glfwGetWindowMonitor(windowP); if (!monitor) { monitor = glfwGetPrimaryMonitor(); } if (monitor) { - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitor); glm::ivec2 pos; glfwGetMonitorPos(monitor, &pos.x, &pos.y); +// cout << "monitor pos " << pos << endl; ofRectangle fsRect { (float)pos.x, (float)pos.y, (float)desktopMode->width, (float)desktopMode->height }; + cout << "fsRect " << fsRect << endl; // FIXME: TODO: Get rectangle for multiple windows. // if (settings.multiMonitorFullScreen && monitorCount > 1) { //// fsRect = @@ -856,6 +860,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { } else if (targetWindowMode == OF_WINDOW) { + cout << "OF_WINDOW, windowRect = " << windowRect << endl; setWindowRect(windowRect); setWindowTitle(settings.title); } From 892f17559989615e26c19f05f70cf42245e9f4d9 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 17:51:51 -0300 Subject: [PATCH 016/143] all monitors properties --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 41 ++++++++++++++++++++- libs/openFrameworks/app/ofAppGLFWWindow.h | 33 +++++++++++++++-- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 1dfa0bde7d0..e61c06fcf93 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -75,12 +75,13 @@ void ofAppGLFWWindow::close() { glfwSetCursorEnterCallback( windowP, nullptr ); glfwSetKeyCallback( windowP, nullptr ); glfwSetWindowSizeCallback( windowP, nullptr ); - glfwSetWindowPosCallback(windowP, nullptr); + glfwSetWindowPosCallback(windowP, nullptr); glfwSetFramebufferSizeCallback( windowP, nullptr); glfwSetWindowCloseCallback( windowP, nullptr ); glfwSetScrollCallback( windowP, nullptr ); glfwSetDropCallback( windowP, nullptr ); - glfwSetWindowRefreshCallback(windowP, nullptr); + glfwSetWindowRefreshCallback(windowP, nullptr); + glfwSetMonitorCallback(monitor_cb); //hide the window before we destroy it stops a flicker on OS X on exit. glfwHideWindow(windowP); @@ -143,6 +144,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError() << "calling window->setup() after ofCreateWindow() is not necessary and won't do anything"; return; } + settings = _settings; if (!glfwInit()) { @@ -150,6 +152,11 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { return; } + updateMonitorProperties(); + cout << "allScreensSpace " << allMonitors.allScreensSpace << endl; + + + // ofLogNotice("ofAppGLFWWindow") << "WINDOW MODE IS " << screenMode; glfwDefaultWindowHints(); @@ -435,6 +442,11 @@ shared_ptr & ofAppGLFWWindow::renderer() { void ofAppGLFWWindow::update() { events().notifyUpdate(); + if (allMonitors.updateMonitor) { + updateMonitorProperties(); + allMonitors.updateMonitor = false; + } + //show the window right before the first draw call. if (bWindowNeedsShowing && windowP) { glfwShowWindow(windowP); @@ -1470,6 +1482,11 @@ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { instance->draw(); } +//------------------------------------------------------------ +void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { + allMonitors.updateMonitor = true; +} + //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { ofAppGLFWWindow * instance = setCurrent(windowP_); @@ -1649,3 +1666,23 @@ HWND ofAppGLFWWindow::getWin32Window() { } #endif + + + +void ofAppGLFWWindow::updateMonitorProperties() { + allMonitors.rects.clear(); + allMonitors.allScreensSpace = { 0,0,0,0 }; // reset ofRectangle; + + int numberOfMonitors; +// GLFWmonitor** monitors = glfwGetMonitors(&numberOfMonitors); + allMonitors.monitors = glfwGetMonitors(&numberOfMonitors); + + for (int i=0; i < numberOfMonitors; i++){ + glm::ivec2 pos; + glfwGetMonitorPos(allMonitors.monitors[i], &pos.x, &pos.y); + const GLFWvidmode * desktopMode = glfwGetVideoMode(allMonitors.monitors[i]); + ofRectangle rect = ofRectangle( pos.x, pos.y, desktopMode->width, desktopMode->height ); + allMonitors.rects.emplace_back(rect); + allMonitors.allScreensSpace = allMonitors.allScreensSpace.getUnion(rect); + } +} diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index acd1804be57..893de9c6224 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -13,6 +13,7 @@ typedef struct _XIC * XIC; class ofBaseApp; struct GLFWwindow; +struct GLFWmonitor; class ofCoreEvents; template @@ -151,12 +152,13 @@ class ofAppGLFWWindow : public ofAppBaseWindow { static void resize_cb(GLFWwindow* windowP_, int w, int h); static void position_cb(GLFWwindow* windowP_, int x, int y); static void framebuffer_size_cb(GLFWwindow* windowP_, int w, int h); - static void exit_cb(GLFWwindow* windowP_); - static void scroll_cb(GLFWwindow* windowP_, double x, double y); + static void exit_cb(GLFWwindow * windowP_); + static void scroll_cb(GLFWwindow * windowP_, double x, double y); static void drop_cb(GLFWwindow* windowP_, int numFiles, const char** dropString); - static void error_cb(int errorCode, const char* errorDescription); + static void error_cb(int errorCode, const char * errorDescription); static void refresh_cb(GLFWwindow * windowP_); - + static void monitor_cb(GLFWmonitor * monitor, int event); + void close(); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) @@ -197,6 +199,29 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #ifdef TARGET_WIN32 LONG lExStyle, lStyle; #endif // TARGET_WIN32 + + + void updateMonitorProperties(); }; + +static struct ofMonitors { +public: + ofMonitors() {} + ~ofMonitors() {} + std::vector rects; + ofRectangle allScreensSpace; + ofRectangle rectWindow; + bool changed = true; + GLFWmonitor** monitors; + bool updateMonitor = true; + +} allMonitors; + +// TODO: Remove. + +//static bool updateMonitor = true; +//static bool updatePixelScreenCoordScale = true; + + //#endif From ef9b37d39970f92bcc37364363f678793558c6ad Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 21:18:49 -0300 Subject: [PATCH 017/143] ios --- addons/ofxiOS/src/app/ofAppiOSWindow.h | 7 +- addons/ofxiOS/src/app/ofAppiOSWindow.mm | 324 ++++++++++++------------ 2 files changed, 159 insertions(+), 172 deletions(-) diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.h b/addons/ofxiOS/src/app/ofAppiOSWindow.h index 0408f003b1c..934bbcaa457 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.h +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.h @@ -179,7 +179,6 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow { static void pollEvents(){ } void setup(const ofWindowSettings & _settings); - void setup(const ofGLESWindowSettings & _settings); void setup(const ofiOSWindowSettings & _settings); void setup(); @@ -198,9 +197,9 @@ class ofAppiOSWindow : public ofAppBaseGLESWindow { virtual void setWindowPosition(int x, int y); virtual void setWindowShape(int w, int h); - virtual glm::vec2 getWindowPosition(); - virtual glm::vec2 getWindowSize(); - virtual glm::vec2 getScreenSize(); + virtual glm::ivec2 getWindowPosition(); + virtual glm::ivec2 getWindowSize(); + virtual glm::ivec2 getScreenSize(); #if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV) virtual void setOrientation(ofOrientation orientation); diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.mm b/addons/ofxiOS/src/app/ofAppiOSWindow.mm index 153c8a8b7d3..b5fbf35e7e9 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.mm +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.mm @@ -1,5 +1,5 @@ /*********************************************************************** - + Copyright (c) 2008, 2009, Memo Akten, www.memo.tv *** The Mega Super Awesome Visuals Company *** * All rights reserved. @@ -12,34 +12,34 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of MSA Visuals nor the names of its contributors + * * Neither the name of MSA Visuals nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THE POSSIBILITY OF SUCH DAMAGE. * - * ***********************************************************************/ + * ***********************************************************************/ #include #include "ofAppiOSWindow.h" #include "ofGLRenderer.h" #include "ofGLProgrammableRenderer.h" #if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV) - #include "ofxiOSAppDelegate.h" - #include "ofxiOSViewController.h" - const std::string appDelegateName = "ofxiOSAppDelegate"; + #include "ofxiOSAppDelegate.h" + #include "ofxiOSViewController.h" + const std::string appDelegateName = "ofxiOSAppDelegate"; #elif TARGET_OS_TV - #include "ofxtvOSAppDelegate.h" - #include "ofxtvOSViewController.h" - const std::string appDelegateName = "ofxtvOSAppDelegate"; + #include "ofxtvOSAppDelegate.h" + #include "ofxtvOSViewController.h" + const std::string appDelegateName = "ofxtvOSAppDelegate"; #endif #include "ofxiOSGLKView.h" #include "ofxiOSEAGLView.h" @@ -53,53 +53,42 @@ //----------------------------------------------------------------------------------- constructor / destructor. ofAppiOSWindow::ofAppiOSWindow() : hasExited(false) { if(_instance == NULL) { - _instance = this; - } else { - ofLog(OF_LOG_ERROR, "ofAppiOSWindow instantiated more than once"); - } - bRetinaSupportedOnDevice = false; - bRetinaSupportedOnDeviceChecked = false; + _instance = this; + } else { + ofLog(OF_LOG_ERROR, "ofAppiOSWindow instantiated more than once"); + } + bRetinaSupportedOnDevice = false; + bRetinaSupportedOnDeviceChecked = false; } ofAppiOSWindow::~ofAppiOSWindow() { - close(); + close(); _instance = NULL; } void ofAppiOSWindow::close() { - if(hasExited == false){ - hasExited = true; - events().notifyExit(); - events().disable(); - } + if(hasExited == false){ + hasExited = true; + events().notifyExit(); + events().disable(); + } } void ofAppiOSWindow::setup(const ofWindowSettings & _settings) { - const ofiOSWindowSettings * iosSettings = dynamic_cast(&_settings); - if(iosSettings){ - setup(*iosSettings); - } else{ - setup(ofiOSWindowSettings(_settings)); - } -} - -void ofAppiOSWindow::setup(const ofGLESWindowSettings & _settings) { - const ofiOSWindowSettings * iosSettings = dynamic_cast(&_settings); - if(iosSettings){ - setup(*iosSettings); - } else{ - setup(ofiOSWindowSettings(_settings)); - } + const ofiOSWindowSettings * iosSettings = dynamic_cast(&_settings); + if(iosSettings){ + setup(*iosSettings); + } else{ + setup(ofiOSWindowSettings(_settings)); + } } void ofAppiOSWindow::setup(const ofiOSWindowSettings & _settings) { - settings = _settings; + settings = _settings; setup(); } void ofAppiOSWindow::setup() { - - if(settings.setupOrientation == OF_ORIENTATION_UNKNOWN) { settings.setupOrientation = OF_ORIENTATION_DEFAULT; } @@ -109,51 +98,50 @@ } else { currentRenderer = std::shared_ptr(new ofGLRenderer(this)); } - hasExited = false; } //----------------------------------------------------------------------------------- opengl setup. void ofAppiOSWindow::setupOpenGL(int w, int h, ofWindowMode screenMode) { settings.windowMode = screenMode; // use this as flag for displaying status bar or not - setup(settings); + setup(settings); } void ofAppiOSWindow::loop() { - startAppWithDelegate(appDelegateName); + startAppWithDelegate(appDelegateName); } void ofAppiOSWindow::run(ofBaseApp * appPtr){ - startAppWithDelegate(appDelegateName); + startAppWithDelegate(appDelegateName); } void ofAppiOSWindow::startAppWithDelegate(std::string appDelegateClassName) { - static bool bAppCreated = false; - if(bAppCreated == true) { - return; - } - bAppCreated = true; - - @autoreleasepool { - UIApplicationMain(0, nil, nil, [NSString stringWithUTF8String:appDelegateClassName.c_str()]); - } + static bool bAppCreated = false; + if(bAppCreated == true) { + return; + } + bAppCreated = true; + + @autoreleasepool { + UIApplicationMain(0, nil, nil, [NSString stringWithUTF8String:appDelegateClassName.c_str()]); + } } void ofAppiOSWindow::update() { - + } void ofAppiOSWindow::draw() { - + } //----------------------------------------------------------------------------------- cursor. void ofAppiOSWindow::hideCursor() { - // not supported on iOS. + // not supported on iOS. } void ofAppiOSWindow::showCursor() { - // not supported on iOS. + // not supported on iOS. } //----------------------------------------------------------------------------------- window / screen properties. @@ -165,21 +153,21 @@ // not supported on iOS. } -glm::vec2 ofAppiOSWindow::getWindowPosition() { +glm::ivec2 ofAppiOSWindow::getWindowPosition() { if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT) return *[[ofxiOSGLKView getInstance] getWindowPosition]; else return *[[ofxiOSEAGLView getInstance] getWindowPosition]; } -glm::vec2 ofAppiOSWindow::getWindowSize() { +glm::ivec2 ofAppiOSWindow::getWindowSize() { if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT) return *[[ofxiOSGLKView getInstance] getWindowSize]; else return *[[ofxiOSEAGLView getInstance] getWindowSize]; } -glm::vec2 ofAppiOSWindow::getScreenSize() { +glm::ivec2 ofAppiOSWindow::getScreenSize() { if(settings.windowControllerType == METAL_KIT || settings.windowControllerType == GL_KIT) return *[[ofxiOSGLKView getInstance] getScreenSize]; else @@ -188,8 +176,8 @@ int ofAppiOSWindow::getWidth(){ if(settings.enableHardwareOrientation == true || - orientation == OF_ORIENTATION_DEFAULT || - orientation == OF_ORIENTATION_180) { + orientation == OF_ORIENTATION_DEFAULT || + orientation == OF_ORIENTATION_180) { return (int)getWindowSize().x; } return (int)getWindowSize().y; @@ -197,8 +185,8 @@ int ofAppiOSWindow::getHeight(){ if(settings.enableHardwareOrientation == true || - orientation == OF_ORIENTATION_DEFAULT || - orientation == OF_ORIENTATION_180) { + orientation == OF_ORIENTATION_DEFAULT || + orientation == OF_ORIENTATION_180) { return (int)getWindowSize().y; } return (int)getWindowSize().x; @@ -211,39 +199,39 @@ #if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV) //----------------------------------------------------------------------------------- orientation. void ofAppiOSWindow::setOrientation(ofOrientation toOrientation) { - if(orientation == toOrientation) { - return; - } - bool bOrientationPortraitOne = (orientation == OF_ORIENTATION_DEFAULT) || (orientation == OF_ORIENTATION_180); - bool bOrientationPortraitTwo = (toOrientation == OF_ORIENTATION_DEFAULT) || (toOrientation == OF_ORIENTATION_180); - bool bResized = bOrientationPortraitOne != bOrientationPortraitTwo; - - orientation = toOrientation; + if(orientation == toOrientation) { + return; + } + bool bOrientationPortraitOne = (orientation == OF_ORIENTATION_DEFAULT) || (orientation == OF_ORIENTATION_180); + bool bOrientationPortraitTwo = (toOrientation == OF_ORIENTATION_DEFAULT) || (toOrientation == OF_ORIENTATION_180); + bool bResized = bOrientationPortraitOne != bOrientationPortraitTwo; + + orientation = toOrientation; #if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV) - UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationPortrait; - switch (orientation) { - case OF_ORIENTATION_DEFAULT: - interfaceOrientation = UIInterfaceOrientationPortrait; - break; - case OF_ORIENTATION_180: - interfaceOrientation = UIInterfaceOrientationPortraitUpsideDown; - break; - case OF_ORIENTATION_90_RIGHT: - interfaceOrientation = UIInterfaceOrientationLandscapeLeft; - break; - case OF_ORIENTATION_90_LEFT: - interfaceOrientation = UIInterfaceOrientationLandscapeRight; - break; - } - - - id appDelegate = [UIApplication sharedApplication].delegate; - if([appDelegate respondsToSelector:@selector(glViewController)] == NO) { - // check app delegate has glViewController, - // otherwise calling glViewController will cause a crash. - return; - } - UIViewController * uiViewController = ((ofxiOSAppDelegate *)appDelegate).uiViewController; + UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationPortrait; + switch (orientation) { + case OF_ORIENTATION_DEFAULT: + interfaceOrientation = UIInterfaceOrientationPortrait; + break; + case OF_ORIENTATION_180: + interfaceOrientation = UIInterfaceOrientationPortraitUpsideDown; + break; + case OF_ORIENTATION_90_RIGHT: + interfaceOrientation = UIInterfaceOrientationLandscapeLeft; + break; + case OF_ORIENTATION_90_LEFT: + interfaceOrientation = UIInterfaceOrientationLandscapeRight; + break; + } + + + id appDelegate = [UIApplication sharedApplication].delegate; + if([appDelegate respondsToSelector:@selector(glViewController)] == NO) { + // check app delegate has glViewController, + // otherwise calling glViewController will cause a crash. + return; + } + UIViewController * uiViewController = ((ofxiOSAppDelegate *)appDelegate).uiViewController; if([uiViewController isKindOfClass:[ofxiOSViewController class]] == YES) { ofxiOSViewController * glViewController = (ofxiOSViewController*)uiViewController; if(glViewController) { @@ -266,88 +254,88 @@ } bool ofAppiOSWindow::doesHWOrientation() { - return settings.enableHardwareOrientation; + return settings.enableHardwareOrientation; } //----------------------------------------------------------------------------------- bool ofAppiOSWindow::enableHardwareOrientation() { - return (settings.enableHardwareOrientation = true); + return (settings.enableHardwareOrientation = true); } bool ofAppiOSWindow::disableHardwareOrientation() { - return (settings.enableHardwareOrientation = false); + return (settings.enableHardwareOrientation = false); } bool ofAppiOSWindow::enableOrientationAnimation() { - return (settings.enableHardwareOrientationAnimation = true); + return (settings.enableHardwareOrientationAnimation = true); } bool ofAppiOSWindow::disableOrientationAnimation() { - return (settings.enableHardwareOrientationAnimation = false); + return (settings.enableHardwareOrientationAnimation = false); } #endif //----------------------------------------------------------------------------------- void ofAppiOSWindow::setWindowTitle(std::string title) { - // not supported on iOS. + // not supported on iOS. } void ofAppiOSWindow::setFullscreen(bool fullscreen) { #if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV) - [[UIApplication sharedApplication] setStatusBarHidden:fullscreen withAnimation:UIStatusBarAnimationSlide]; + [[UIApplication sharedApplication] setStatusBarHidden:fullscreen withAnimation:UIStatusBarAnimationSlide]; #endif - if(fullscreen) { - settings.windowMode = OF_FULLSCREEN; - } else { - settings.windowMode = OF_WINDOW; - } + if(fullscreen) { + settings.windowMode = OF_FULLSCREEN; + } else { + settings.windowMode = OF_WINDOW; + } } void ofAppiOSWindow::toggleFullscreen() { - if(settings.windowMode == OF_FULLSCREEN) { - setFullscreen(false); - } else { - setFullscreen(true); - } + if(settings.windowMode == OF_FULLSCREEN) { + setFullscreen(false); + } else { + setFullscreen(true); + } } //----------------------------------------------------------------------------------- bool ofAppiOSWindow::enableRendererES2() { - if(isRendererES2() == true) { - return false; - } - std::shared_ptrrenderer (new ofGLProgrammableRenderer(this)); - ofSetCurrentRenderer(renderer); - return true; + if(isRendererES2() == true) { + return false; + } + std::shared_ptrrenderer (new ofGLProgrammableRenderer(this)); + ofSetCurrentRenderer(renderer); + return true; } bool ofAppiOSWindow::enableRendererES1() { - if(isRendererES1() == true) { - return false; - } - std::shared_ptr renderer(new ofGLRenderer(this)); - ofSetCurrentRenderer(renderer); - return true; + if(isRendererES1() == true) { + return false; + } + std::shared_ptr renderer(new ofGLRenderer(this)); + ofSetCurrentRenderer(renderer); + return true; } bool ofAppiOSWindow::isProgrammableRenderer() { - return (currentRenderer && currentRenderer->getType()==ofGLProgrammableRenderer::TYPE); + return (currentRenderer && currentRenderer->getType()==ofGLProgrammableRenderer::TYPE); } ofxiOSRendererType ofAppiOSWindow::getGLESVersion() { - return (ofxiOSRendererType)settings.glesVersion; + return (ofxiOSRendererType)settings.glesVersion; } bool ofAppiOSWindow::isRendererES2() { - return (isProgrammableRenderer() && settings.glesVersion == 2); + return (isProgrammableRenderer() && settings.glesVersion == 2); } bool ofAppiOSWindow::isRendererES1() { - return !isProgrammableRenderer(); + return !isProgrammableRenderer(); } //----------------------------------------------------------------------------------- @@ -360,71 +348,71 @@ }; bool ofAppiOSWindow::isSetupScreenEnabled() { - return settings.enableSetupScreen; + return settings.enableSetupScreen; } void ofAppiOSWindow::setVerticalSync(bool enabled) { - // not supported on iOS. + // not supported on iOS. } //----------------------------------------------------------------------------------- retina. bool ofAppiOSWindow::enableRetina(float retinaScale) { - if(isRetinaSupportedOnDevice()) { - settings.enableRetina = true; - settings.retinaScale = retinaScale; - } - return settings.enableRetina; + if(isRetinaSupportedOnDevice()) { + settings.enableRetina = true; + settings.retinaScale = retinaScale; + } + return settings.enableRetina; } bool ofAppiOSWindow::disableRetina() { - return (settings.enableRetina = false); + return (settings.enableRetina = false); } bool ofAppiOSWindow::isRetinaEnabled() { - return settings.enableRetina; + return settings.enableRetina; } bool ofAppiOSWindow::isRetinaSupportedOnDevice() { - if(bRetinaSupportedOnDeviceChecked) { - return bRetinaSupportedOnDevice; - } - - bRetinaSupportedOnDeviceChecked = true; - - @autoreleasepool { - if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]){ - if ([[UIScreen mainScreen] scale] > 1){ - bRetinaSupportedOnDevice = true; - } - } - } - - return bRetinaSupportedOnDevice; + if(bRetinaSupportedOnDeviceChecked) { + return bRetinaSupportedOnDevice; + } + + bRetinaSupportedOnDeviceChecked = true; + + @autoreleasepool { + if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]){ + if ([[UIScreen mainScreen] scale] > 1){ + bRetinaSupportedOnDevice = true; + } + } + } + + return bRetinaSupportedOnDevice; } float ofAppiOSWindow::getRetinaScale() { - return settings.retinaScale; + return settings.retinaScale; } //----------------------------------------------------------------------------------- depth buffer. bool ofAppiOSWindow::enableDepthBuffer() { settings.depthType = ofxiOSRendererDepthFormat::DEPTH_24; - return (settings.enableDepth = true); + return (settings.enableDepth = true); } bool ofAppiOSWindow::disableDepthBuffer() { settings.depthType = ofxiOSRendererDepthFormat::DEPTH_NONE; - return (settings.enableDepth = false); + return (settings.enableDepth = false); } bool ofAppiOSWindow::isDepthBufferEnabled() { - return settings.enableDepth; + return settings.enableDepth; } //----------------------------------------------------------------------------------- anti aliasing. bool ofAppiOSWindow::enableAntiAliasing(int samples) { settings.numOfAntiAliasingSamples = samples; - return (settings.enableAntiAliasing = true); + return (settings.enableAntiAliasing = true); } void ofAppiOSWindow::enableMultiTouch(bool isOn) { @@ -446,15 +434,15 @@ } bool ofAppiOSWindow::disableAntiAliasing() { - return (settings.enableAntiAliasing = false); + return (settings.enableAntiAliasing = false); } bool ofAppiOSWindow::isAntiAliasingEnabled() { - return settings.enableAntiAliasing; + return settings.enableAntiAliasing; } int ofAppiOSWindow::getAntiAliasingSampleCount() { - return settings.numOfAntiAliasingSamples; + return settings.numOfAntiAliasingSamples; } ofxiOSWindowControllerType ofAppiOSWindow::getWindowControllerType() { @@ -475,14 +463,14 @@ //----------------------------------------------------------------------------------- ofCoreEvents & ofAppiOSWindow::events(){ - return coreEvents; + return coreEvents; } //----------------------------------------------------------------------------------- std::shared_ptr & ofAppiOSWindow::renderer(){ - return currentRenderer; + return currentRenderer; } ofiOSWindowSettings & ofAppiOSWindow::getSettings() { - return settings; + return settings; } From 63c0cd11fc86a3e4a3ab0f4bf96fe0dcf67b4dee Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 15 Jan 2024 21:22:05 -0300 Subject: [PATCH 018/143] remove glut --- libs/openFrameworks/app/ofAppGlutWindow.cpp | 895 -------------------- libs/openFrameworks/app/ofAppGlutWindow.h | 97 --- 2 files changed, 992 deletions(-) delete mode 100644 libs/openFrameworks/app/ofAppGlutWindow.cpp delete mode 100644 libs/openFrameworks/app/ofAppGlutWindow.h diff --git a/libs/openFrameworks/app/ofAppGlutWindow.cpp b/libs/openFrameworks/app/ofAppGlutWindow.cpp deleted file mode 100644 index db0559a1a11..00000000000 --- a/libs/openFrameworks/app/ofAppGlutWindow.cpp +++ /dev/null @@ -1,895 +0,0 @@ -#include "ofAppGlutWindow.h" -#include "ofBaseApp.h" -#include "ofPixels.h" -#include "ofGLRenderer.h" - -#ifdef TARGET_WIN32 - #if (_MSC_VER) - #define GLUT_BUILDING_LIB - #include "glut.h" - #else - #include - #include - #endif - #include -#endif -#ifdef TARGET_OSX - #include - #include "../../../libs/glut/lib/osx/GLUT.framework/Versions/A/Headers/glut.h" - #include -#endif -#ifdef TARGET_LINUX - #include - #include "ofIcon.h" - #include "ofImage.h" - #include - #include - #include -#endif - -// glut works with static callbacks UGH, so we need static variables here: - -static bool bNewScreenMode; -static int buttonInUse; -static bool bEnableSetupScreen; -static bool bDoubleBuffered; - -static int requestedWidth; -static int requestedHeight; -static int nonFullScreenX; -static int nonFullScreenY; -static int windowW; -static int windowH; -static int nFramesSinceWindowResized; -//static ofWindowMode windowMode; -//static ofOrientation orientation; -static ofAppGlutWindow * instance; - -#ifdef TARGET_WIN32 - -//------------------------------------------------ - -// this is to fix a bug with glut that doesn't properly close the app -// with window closing. we grab the window procedure, store it, and parse windows messages, -// using the close and destroy messages and passing on the others... - -//------------------------------------------------ - -static WNDPROC currentWndProc; -static HWND handle = nullptr; - -// This function takes in a wParam from the WM_DROPFILES message and -// prints all the files to a message box. - -void HandleFiles(WPARAM wParam) -{ - // DragQueryFile() takes a LPWSTR for the name so we need a TCHAR string - TCHAR szName[MAX_PATH]; - - // Here we cast the wParam as a HDROP handle to pass into the next functions - HDROP hDrop = (HDROP)wParam; - - POINT pt; - DragQueryPoint(hDrop, &pt); - //ofLogNotice("ofAppGlutWindow") << "drag point: " << pt.x << pt.y; - - ofDragInfo info; - info.position.x = pt.x; - info.position.y = pt.y; - - - // This functions has a couple functionalities. If you pass in 0xFFFFFFFF in - // the second parameter then it returns the count of how many filers were drag - // and dropped. Otherwise, the function fills in the szName string array with - // the current file being queried. - int count = DragQueryFile(hDrop, 0xFFFFFFFF, szName, MAX_PATH); - - // Here we go through all the files that were drag and dropped then display them - for(int i = 0; i < count; i++) - { - // Grab the name of the file associated with index "i" in the list of files dropped. - // Be sure you know that the name is attached to the FULL path of the file. - DragQueryFile(hDrop, i, szName, MAX_PATH); - - wchar_t * s = (wchar_t*)szName; - char dfault = '?'; - const std::locale& loc = std::locale(); - std::ostringstream stm; - while( *s != L'\0' ) { - stm << std::use_facet< std::ctype >( loc ).narrow( *s++, dfault ); - } - info.files.push_back(std::string(stm.str())); - - //toUTF8(udispName, dispName); - - // Bring up a message box that displays the current file being processed - //MessageBox(GetForegroundWindow(), szName, L"Current file received", MB_OK); - } - - // Finally, we destroy the HDROP handle so the extra memory - // allocated by the application is released. - DragFinish(hDrop); - - instance->events().notifyDragEvent(info); - -} - - -static LRESULT CALLBACK winProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam){ - - //we catch close and destroy messages - //and send them to OF - - switch(Msg){ - - case WM_CLOSE: - OF_EXIT_APP(0); - break; - case WM_DESTROY: - OF_EXIT_APP(0); - break; - case WM_DROPFILES: - - // Call our function we created to display all the files. - // We pass the wParam because it's the HDROP handle. - HandleFiles(wParam); - break; - default: - return CallWindowProc(currentWndProc, handle, Msg, wParam, lParam); - break; - } - - return 0; -} - -//-------------------------------------- -static void fixCloseWindowOnWin32(){ - - //get the HWND - handle = WindowFromDC(wglGetCurrentDC()); - - // enable drag and drop of files. - DragAcceptFiles (handle, TRUE); - - //store the current message event handler for the window - currentWndProc = (WNDPROC)GetWindowLongPtr(handle, GWLP_WNDPROC); - - //tell the window to now use our event handler! - SetWindowLongPtr(handle, GWLP_WNDPROC, (LONG_PTR)winProc); -} - -#endif - - - - -//---------------------------------------------------------- -ofAppGlutWindow::ofAppGlutWindow(){ - windowMode = OF_WINDOW; - bNewScreenMode = true; - nFramesSinceWindowResized = 0; - buttonInUse = 0; - bEnableSetupScreen = true; - requestedWidth = 0; - requestedHeight = 0; - nonFullScreenX = -1; - nonFullScreenY = -1; - displayString = ""; - orientation = OF_ORIENTATION_DEFAULT; - bDoubleBuffered = true; // LIA - iconSet = false; - instance = this; - windowId = 0; -} - -//lets you enable alpha blending using a display string like: -// "rgba double samples>=4 depth" ( mac ) -// "rgb double depth alpha samples>=4" ( some pcs ) -//------------------------------------------------------------ - void ofAppGlutWindow::setGlutDisplayString(std::string displayStr){ - displayString = displayStr; - } - - //------------------------------------------------------------ -void ofAppGlutWindow::setDoubleBuffering(bool _bDoubleBuffered){ - bDoubleBuffered = _bDoubleBuffered; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setup(const ofGLWindowSettings & settings){ - - int argc = 1; - char *argv = (char*)"openframeworks"; - char **vptr = &argv; - glutInit(&argc, vptr); - - if( displayString != ""){ - glutInitDisplayString( displayString.c_str() ); - }else{ - if(bDoubleBuffered){ - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA ); - }else{ - glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH | GLUT_ALPHA ); - } - } - - windowMode = settings.windowMode; - bNewScreenMode = true; - - if (windowMode == OF_FULLSCREEN){ - glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT)); - windowId = glutCreateWindow(""); - - requestedWidth = settings.getWidth(); - requestedHeight = settings.getHeight(); - } else if (windowMode != OF_GAME_MODE){ - glutInitWindowSize(settings.getWidth(), settings.getHeight()); - glutCreateWindow(""); - - /* - ofBackground(200,200,200); // default bg color - ofSetColor(0xFFFFFF); // default draw color - // used to be black, but - // black + texture = black - // so maybe grey bg - // and "white" fg color - // as default works the best... - */ - - requestedWidth = glutGet(GLUT_WINDOW_WIDTH); - requestedHeight = glutGet(GLUT_WINDOW_HEIGHT); - } else { - if( displayString != ""){ - glutInitDisplayString( displayString.c_str() ); - }else{ - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA ); - } - - // w x h, 32bit pixel depth, 60Hz refresh rate - char gameStr[64]; - sprintf( gameStr, "%dx%d:%d@%d", settings.getWidth(), settings.getHeight(), 32, 60 ); - - glutGameModeString(gameStr); - - if (!glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)){ - ofLogError("ofAppGlutWindow") << "setupOpenGL(): selected game mode format " << gameStr << " not available"; - } - // start fullscreen game mode - glutEnterGameMode(); - } - windowW = glutGet(GLUT_WINDOW_WIDTH); - windowH = glutGet(GLUT_WINDOW_HEIGHT); - - currentRenderer = std::shared_ptr(new ofGLRenderer(this)); - - -#ifndef TARGET_OPENGLES - glewExperimental = GL_TRUE; - GLenum err = glewInit(); - if (GLEW_OK != err) - { - /* Problem: glewInit failed, something is seriously wrong. */ - ofLogError("ofAppRunner") << "couldn't init GLEW: " << glewGetErrorString(err); - return; - } -#endif - static_cast(currentRenderer.get())->setup(); - setVerticalSync(true); - - - //---------------------- - // setup the callbacks - - glutMouseFunc(mouse_cb); - glutMotionFunc(motion_cb); - glutPassiveMotionFunc(passive_motion_cb); - glutIdleFunc(idle_cb); - glutDisplayFunc(display); - - glutKeyboardFunc(keyboard_cb); - glutKeyboardUpFunc(keyboard_up_cb); - glutSpecialFunc(special_key_cb); - glutSpecialUpFunc(special_key_up_cb); - - glutReshapeFunc(resize_cb); - glutEntryFunc(entry_cb); -#ifdef TARGET_LINUX - glutCloseFunc(exit_cb); -#endif - -#ifdef TARGET_OSX - glutDragEventFunc(dragEvent); -#endif - - nFramesSinceWindowResized = 0; - - #ifdef TARGET_WIN32 - //---------------------- - // this is specific to windows (respond properly to close / destroy) - fixCloseWindowOnWin32(); - #endif - -#ifdef TARGET_LINUX - if(!iconSet){ - ofPixels iconPixels; - #ifdef DEBUG - iconPixels.allocate(ofIconDebug.width,ofIconDebug.height,ofIconDebug.bytes_per_pixel); - GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(),ofIconDebug.rle_pixel_data,iconPixels.getWidth()*iconPixels.getHeight(),ofIconDebug.bytes_per_pixel); - #else - iconPixels.allocate(ofIcon.width,ofIcon.height,ofIcon.bytes_per_pixel); - GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(),ofIcon.rle_pixel_data,iconPixels.getWidth()*iconPixels.getHeight(),ofIcon.bytes_per_pixel); - #endif - setWindowIcon(iconPixels); - } -#endif - if (settings.isPositionSet()) { - setWindowPosition(settings.getPosition().x,settings.getPosition().y); - } - -#ifdef TARGET_OSX - // The osx implementation of glut changes the cwd, this restores it - // to wherever it was when the app was started - ofRestoreWorkingDirectoryToDefault(); -#endif -} - -#ifdef TARGET_LINUX -//------------------------------------------------------------ -void ofAppGlutWindow::setWindowIcon(const std::string & path){ - ofPixels iconPixels; - ofLoadImage(iconPixels,path); - setWindowIcon(iconPixels); -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setWindowIcon(const ofPixels & iconPixels){ - iconSet = true; - Display *m_display = glXGetCurrentDisplay(); - GLXDrawable m_window = glXGetCurrentDrawable(); - iconSet = true; - int length = 2+iconPixels.getWidth()*iconPixels.getHeight(); - unsigned long * buffer = new unsigned long[length]; - buffer[0]=iconPixels.getWidth(); - buffer[1]=iconPixels.getHeight(); - for(size_t i=0;ievents().notifySetup(); - instance->events().notifyUpdate(); - glutMainLoop(); -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setWindowTitle(const std::string & title){ - glutSetWindowTitle(title.c_str()); -} - -//------------------------------------------------------------ -glm::ivec2 ofAppGlutWindow::getWindowSize(){ - return {windowW, windowH}; -} - -//------------------------------------------------------------ -glm::ivec2 ofAppGlutWindow::getWindowPosition(){ - int x = glutGet(GLUT_WINDOW_X); - int y = glutGet(GLUT_WINDOW_Y); - if( orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180 ){ - return {x,y}; - }else{ - return {y,x}; - } -} - -//------------------------------------------------------------ -glm::ivec2 ofAppGlutWindow::getScreenSize(){ - int width = glutGet(GLUT_SCREEN_WIDTH); - int height = glutGet(GLUT_SCREEN_HEIGHT); - if( orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180 ){ - return {width, height}; - }else{ - return {height, width}; - } -} - -//------------------------------------------------------------ -int ofAppGlutWindow::getWidth(){ - if( orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180 ){ - return windowW; - } - return windowH; -} - -//------------------------------------------------------------ -int ofAppGlutWindow::getHeight(){ - if( orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180 ){ - return windowH; - } - return windowW; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setWindowPosition(int x, int y){ - glutPositionWindow(x,y); -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setWindowShape(int w, int h){ - glutReshapeWindow(w, h); - // this is useful, esp if we are in the first frame (setup): - requestedWidth = w; - requestedHeight = h; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::hideCursor(){ - #if defined(TARGET_OSX) && defined(MAC_OS_X_VERSION_10_7) - CGDisplayHideCursor(0); - #else - glutSetCursor(GLUT_CURSOR_NONE); - #endif -} - -//------------------------------------------------------------ -void ofAppGlutWindow::showCursor(){ - #if defined(TARGET_OSX) && defined(MAC_OS_X_VERSION_10_7) - CGDisplayShowCursor(0); - #else - glutSetCursor(GLUT_CURSOR_LEFT_ARROW); - #endif -} - -//------------------------------------------------------------ -void ofAppGlutWindow::toggleFullscreen(){ - if( windowMode == OF_GAME_MODE)return; - - if( windowMode == OF_WINDOW ){ - windowMode = OF_FULLSCREEN; - }else{ - windowMode = OF_WINDOW; - } - - bNewScreenMode = true; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setFullscreen(bool fullscreen){ - if( windowMode == OF_GAME_MODE)return; - - if(fullscreen && windowMode != OF_FULLSCREEN){ - bNewScreenMode = true; - windowMode = OF_FULLSCREEN; - }else if(!fullscreen && windowMode != OF_WINDOW) { - bNewScreenMode = true; - windowMode = OF_WINDOW; - } -} - -//------------------------------------------------------------ -void ofAppGlutWindow::enableSetupScreen(){ - bEnableSetupScreen = true; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::disableSetupScreen(){ - bEnableSetupScreen = false; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::setVerticalSync(bool bSync){ - //---------------------------- - #ifdef TARGET_WIN32 - //---------------------------- - if (bSync) { - if (WGL_EXT_swap_control) { - wglSwapIntervalEXT (1); - } - } else { - if (WGL_EXT_swap_control) { - wglSwapIntervalEXT (0); - } - } - //---------------------------- - #endif - //---------------------------- - - //-------------------------------------- - #ifdef TARGET_OSX - //-------------------------------------- - GLint sync = bSync == true ? 1 : 0; - CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &sync); - //-------------------------------------- - #endif - //-------------------------------------- - - //-------------------------------------- - #ifdef TARGET_LINUX - //-------------------------------------- - void (*swapIntervalExt)(Display *,GLXDrawable, int) = (void (*)(Display *,GLXDrawable, int)) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); - if(swapIntervalExt){ - Display *dpy = glXGetCurrentDisplay(); - GLXDrawable drawable = glXGetCurrentDrawable(); - if (drawable) { - swapIntervalExt(dpy, drawable, bSync ? 1 : 0); - return; - } - } - void (*swapInterval)(int) = (void (*)(int)) glXGetProcAddress((const GLubyte*) "glXSwapIntervalSGI"); - if(!swapInterval) { - swapInterval = (void (*)(int)) glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); - } - if(swapInterval) { - swapInterval(bSync ? 1 : 0); - } - //-------------------------------------- - #endif - //-------------------------------------- -} - -//------------------------------------------------------------ -ofCoreEvents & ofAppGlutWindow::events(){ - return coreEvents; -} - -//------------------------------------------------------------ -std::shared_ptr & ofAppGlutWindow::renderer(){ - return currentRenderer; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::display(void){ - - //-------------------------------- - // when I had "glutFullScreen()" - // in the initOpenGl, I was gettings a "heap" allocation error - // when debugging via visual studio. putting it here, changes that. - // maybe it's voodoo, or I am getting rid of the problem - // by removing something unrelated, but everything seems - // to work if I put fullscreen on the first frame of display. - - if (windowMode != OF_GAME_MODE){ - if ( bNewScreenMode ){ - if( windowMode == OF_FULLSCREEN){ - - //---------------------------------------------------- - // before we go fullscreen, take a snapshot of where we are: - nonFullScreenX = glutGet(GLUT_WINDOW_X); - nonFullScreenY = glutGet(GLUT_WINDOW_Y); - //---------------------------------------------------- - - glutFullScreen(); - - #ifdef TARGET_OSX - [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; - #ifdef MAC_OS_X_VERSION_10_7 //needed for Lion as when the machine reboots the app is not at front level - if( instance->events().getFrameNum() <= 10 ){ //is this long enough? too long? - [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; - } - #endif - #endif - - }else if( windowMode == OF_WINDOW ){ - - glutReshapeWindow(requestedWidth, requestedHeight); - - //---------------------------------------------------- - // if we have recorded the screen posion, put it there - // if not, better to let the system do it (and put it where it wants) - if (instance->events().getFrameNum() > 0){ - glutPositionWindow(nonFullScreenX,nonFullScreenY); - } - //---------------------------------------------------- - - #ifdef TARGET_OSX - [NSApp setPresentationOptions:NSApplicationPresentationDefault]; - #endif - } - bNewScreenMode = false; - } - } - - instance->currentRenderer->startRender(); - - if( bEnableSetupScreen ) instance->currentRenderer->setupScreen(); - - instance->events().notifyDraw(); - - #ifdef TARGET_WIN32 - if (instance->currentRenderer->getBackgroundAuto() == false){ - // on a PC resizing a window with this method of accumulation (essentially single buffering) - // is BAD, so we clear on resize events. - if (nFramesSinceWindowResized < 3){ - instance->currentRenderer->clear(); - } else { - if ( (instance->events().getFrameNum() < 3 || nFramesSinceWindowResized < 3) && bDoubleBuffered) glutSwapBuffers(); - else glFlush(); - } - } else { - if(bDoubleBuffered){ - glutSwapBuffers(); - } else{ - glFlush(); - } - } - #else - if (instance->currentRenderer->getBackgroundAuto() == false){ - // in accum mode resizing a window is BAD, so we clear on resize events. - if (nFramesSinceWindowResized < 3){ - instance->currentRenderer->clear(); - } - } - if(bDoubleBuffered){ - glutSwapBuffers(); - } else{ - glFlush(); - } - #endif - - instance->currentRenderer->finishRender(); - - nFramesSinceWindowResized++; - -} - -//------------------------------------------------------------ -void ofAppGlutWindow::swapBuffers() { - glutSwapBuffers(); -} - -//-------------------------------------------- -void ofAppGlutWindow::startRender() { - renderer()->startRender(); -} - -//-------------------------------------------- -void ofAppGlutWindow::finishRender() { - renderer()->finishRender(); -} - -//------------------------------------------------------------ -static void rotateMouseXY(ofOrientation orientation, int w, int h, int &x, int &y) { - int savedY; - switch(orientation) { - case OF_ORIENTATION_180: - x = w - x; - y = h - y; - break; - - case OF_ORIENTATION_90_RIGHT: - savedY = y; - y = x; - x = w-savedY; - break; - - case OF_ORIENTATION_90_LEFT: - savedY = y; - y = h - x; - x = savedY; - break; - - case OF_ORIENTATION_DEFAULT: - default: - break; - } -} - -//------------------------------------------------------------ -void ofAppGlutWindow::mouse_cb(int button, int state, int x, int y) { - rotateMouseXY(orientation, instance->getWidth(), instance->getHeight(), x, y); - - - switch(button){ - case GLUT_LEFT_BUTTON: - button = OF_MOUSE_BUTTON_LEFT; - break; - case GLUT_RIGHT_BUTTON: - button = OF_MOUSE_BUTTON_RIGHT; - break; - case GLUT_MIDDLE_BUTTON: - button = OF_MOUSE_BUTTON_MIDDLE; - break; - } - - if (instance->events().getFrameNum() > 0){ - if (state == GLUT_DOWN) { - instance->events().notifyMousePressed(x, y, button); - } else if (state == GLUT_UP) { - instance->events().notifyMouseReleased(x, y, button); - } - - buttonInUse = button; - } -} - -//------------------------------------------------------------ -void ofAppGlutWindow::motion_cb(int x, int y) { - rotateMouseXY(orientation, instance->getWidth(), instance->getHeight(), x, y); - - if (instance->events().getFrameNum() > 0){ - instance->events().notifyMouseDragged(x, y, buttonInUse); - } - -} - -//------------------------------------------------------------ -void ofAppGlutWindow::passive_motion_cb(int x, int y) { - rotateMouseXY(orientation, instance->getWidth(), instance->getHeight(), x, y); - - if (instance->events().getFrameNum() > 0){ - instance->events().notifyMouseMoved(x, y); - } -} - -//------------------------------------------------------------ -void ofAppGlutWindow::dragEvent(char ** names, int howManyFiles, int dragX, int dragY){ - - // TODO: we need position info on mac passed through - ofDragInfo info; - info.position.x = dragX; - info.position.y = instance->getHeight()-dragY; - - for (int i = 0; i < howManyFiles; i++){ - std::string temp = std::string(names[i]); - info.files.push_back(temp); - } - - instance->events().notifyDragEvent(info); -} - - -//------------------------------------------------------------ -void ofAppGlutWindow::idle_cb(void) { - instance->events().notifyUpdate(); - - glutPostRedisplay(); -} - - -//------------------------------------------------------------ -void ofAppGlutWindow::keyboard_cb(unsigned char key, int x, int y) { - instance->events().notifyKeyPressed(key); -} - -//------------------------------------------------------------ -void ofAppGlutWindow::keyboard_up_cb(unsigned char key, int x, int y){ - instance->events().notifyKeyReleased(key); -} - -//------------------------------------------------------ -void ofAppGlutWindow::special_key_cb(int key, int x, int y) { - instance->events().notifyKeyPressed(special_key_to_of(key)); -} - -//------------------------------------------------------------ -void ofAppGlutWindow::special_key_up_cb(int key, int x, int y) { - instance->events().notifyKeyReleased(special_key_to_of(key)); -} - -//------------------------------------------------------------ -int ofAppGlutWindow::special_key_to_of(int key) { - switch (key) { - case GLUT_KEY_F1: - return OF_KEY_F1; - - case GLUT_KEY_F2: - return OF_KEY_F2; - - case GLUT_KEY_F3: - return OF_KEY_F3; - - case GLUT_KEY_F4: - return OF_KEY_F4; - - case GLUT_KEY_F5: - return OF_KEY_F5; - - case GLUT_KEY_F6: - return OF_KEY_F6; - - case GLUT_KEY_F7: - return OF_KEY_F7; - - case GLUT_KEY_F8: - return OF_KEY_F8; - - case GLUT_KEY_F9: - return OF_KEY_F9; - - case GLUT_KEY_F10: - return OF_KEY_F10; - - case GLUT_KEY_F11: - return OF_KEY_F11; - - case GLUT_KEY_F12: - return OF_KEY_F12; - - case GLUT_KEY_LEFT: - return OF_KEY_LEFT; - - case GLUT_KEY_UP: - return OF_KEY_UP; - - case GLUT_KEY_RIGHT: - return OF_KEY_RIGHT; - - case GLUT_KEY_DOWN: - return OF_KEY_DOWN; - - case GLUT_KEY_PAGE_UP: - return OF_KEY_PAGE_UP; - - case GLUT_KEY_PAGE_DOWN: - return OF_KEY_PAGE_DOWN; - - case GLUT_KEY_HOME: - return OF_KEY_HOME; - - case GLUT_KEY_END: - return OF_KEY_END; - - case GLUT_KEY_INSERT: - return OF_KEY_INSERT; - - default: - return 0; - } -} - -//------------------------------------------------------------ -void ofAppGlutWindow::resize_cb(int w, int h) { - windowW = w; - windowH = h; - - instance->events().notifyWindowResized(w, h); - - nFramesSinceWindowResized = 0; -} - -//------------------------------------------------------------ -void ofAppGlutWindow::entry_cb(int state) { - if (state == GLUT_ENTERED){ - instance->events().notifyMouseEntered(instance->events().getMouseX(), instance->events().getMouseY()); - }else if (state == GLUT_LEFT){ - instance->events().notifyMouseExited(instance->events().getMouseX(), instance->events().getMouseY()); - } -} - -//------------------------------------------------------------ -void ofAppGlutWindow::exit_cb() { - instance->events().notifyExit(); - instance->events().disable(); -} diff --git a/libs/openFrameworks/app/ofAppGlutWindow.h b/libs/openFrameworks/app/ofAppGlutWindow.h deleted file mode 100644 index f9c1a3b73ce..00000000000 --- a/libs/openFrameworks/app/ofAppGlutWindow.h +++ /dev/null @@ -1,97 +0,0 @@ -#pragma once - -#include "ofAppBaseWindow.h" -#include "ofEvents.h" -#include "ofTypes.h" -// MARK: Target but optional -#include "ofConstants.h" - -template -class ofPixels_; -typedef ofPixels_ ofPixels; -typedef ofPixels_ ofFloatPixels; -typedef ofPixels_ ofShortPixels; -typedef ofPixels & ofPixelsRef; - -class ofBaseApp; -class ofBaseRenderer; - -class ofAppGlutWindow : public ofAppBaseWindow { -public: - - ofAppGlutWindow(); - ~ofAppGlutWindow(){} - - static bool doesLoop(){ return true; } - static bool allowsMultiWindow(){ return false; } - static void loop(); - static bool needsPolling(){ return false; } - static void pollEvents(){ } - - using ofAppBaseWindow::setup; - void setup(const ofWindowSettings & settings); - void update(); - void draw(); - void close(); - - void setDoubleBuffering(bool _bDoubleBuffered); - - //note if you fail to set a compatible string the app will not launch - void setGlutDisplayString(std::string str); - - void hideCursor(); - void showCursor(); - - void setFullscreen(bool fullScreen); - void toggleFullscreen(); - - void setWindowTitle(const std::string & title); - void setWindowPosition(int x, int y); - void setWindowShape(int w, int h); - - glm::ivec2 getWindowPosition(); - glm::ivec2 getWindowSize(); - glm::ivec2 getScreenSize(); - - int getWidth(); - int getHeight(); - - void enableSetupScreen(); - void disableSetupScreen(); - - void setVerticalSync(bool enabled); - void swapBuffers(); - void startRender(); - void finishRender(); - - ofCoreEvents & events(); - std::shared_ptr & renderer(); - -private: - static void display(void); - static void mouse_cb(int button, int state, int x, int y); - static void motion_cb(int x, int y); - static void passive_motion_cb(int x, int y); - static void idle_cb(void); - static void keyboard_cb(unsigned char key, int x, int y); - static void keyboard_up_cb(unsigned char key, int x, int y); - static void special_key_cb(int key, int x, int y); - static void special_key_up_cb(int key, int x, int y); - static int special_key_to_of(int key); - static void resize_cb(int w, int h); - static void entry_cb(int state); - static void exit_cb(); - static void dragEvent(char ** fileNames, int howManyFiles, int dragX, int dragY); - std::string displayString; - - bool iconSet; -#ifdef TARGET_LINUX - void setWindowIcon(const std::string & path); - void setWindowIcon(const ofPixels & iconPixels); -#endif - - ofCoreEvents coreEvents; - std::shared_ptr currentRenderer; - int windowId; -}; - From 907d2868dddfd264bd1762c385608cf6c57075c2 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 16 Jan 2024 13:42:40 -0300 Subject: [PATCH 019/143] up --- libs/openFrameworks/app/ofAppBaseWindow.h | 6 +++--- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index f060863f95a..8264ae0cead 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -56,9 +56,9 @@ class ofAppBaseWindow { virtual void setWindowShape(int w, int h){} virtual void setWindowRect(const ofRectangle & rect){} - virtual glm::ivec2 getWindowPosition() { return glm::vec2(); } - virtual glm::ivec2 getWindowSize() { return glm::vec2(); } - virtual glm::ivec2 getScreenSize() { return glm::vec2(); } + virtual glm::ivec2 getWindowPosition() { return glm::ivec2(); } + virtual glm::ivec2 getWindowSize() { return glm::ivec2(); } + virtual glm::ivec2 getScreenSize() { return glm::ivec2(); } virtual ofRectangle getWindowRect() { return ofRectangle(); } virtual void setOrientation(ofOrientation orientationIn) { orientation = orientationIn; } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index e61c06fcf93..935e77ddfc1 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1489,6 +1489,12 @@ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { + + glm::ivec2 windowSize; + glfwGetWindowSize(windowP_, &windowSize.x, &windowSize.y); +// cout << "resize_cb a " << w << " : " << h << endl; +// cout << "resize_cb b " << windowSize << endl; + ofAppGLFWWindow * instance = setCurrent(windowP_); // Detect if the window is running in a retina mode @@ -1496,20 +1502,21 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { int framebufferW, framebufferH; // <- physical pixel extents glfwGetFramebufferSize(windowP_, &framebufferW, &framebufferH); - int windowW, windowH; // <- screen coordinates, which may be scaled - glfwGetWindowSize(windowP_, &windowW, &windowH); + + + // Find scale factor needed to transform from screen coordinates // to physical pixel coordinates - instance->pixelScreenCoordScale = (float)framebufferW / (float)windowW; + instance->pixelScreenCoordScale = (float)framebufferW / (float)windowSize.x; if (instance->settings.windowMode == OF_WINDOW) { instance->windowW = framebufferW; instance->windowH = framebufferH; } - instance->currentW = windowW; - instance->currentH = windowH; + instance->currentW = windowSize.x; + instance->currentH = windowSize.y; instance->events().notifyWindowResized(framebufferW, framebufferH); instance->nFramesSinceWindowResized = 0; @@ -1525,6 +1532,7 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { //------------------------------------------------------------ void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { + cout << "framebuffer_size_cb " << w << " : " << h << endl; resize_cb(windowP_, w, h); } From 4ad51894b183fc3ee96dbff2be09258ec881988b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 11:41:40 -0300 Subject: [PATCH 020/143] real minimal fullscreen monitor handling --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 72 ++++++++------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 26 ++++++++ libs/openFrameworks/app/ofWindowSettings.h | 10 ++- libs/openFrameworks/events/ofEvents.cpp | 6 ++ libs/openFrameworks/events/ofEvents.h | 3 + libs/openFrameworks/types/ofRectangle.h | 2 +- 6 files changed, 70 insertions(+), 49 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 935e77ddfc1..1297f0d0829 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -655,7 +655,7 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { - cout << "setWindowRect " << rect << endl; +// cout << "setWindowRect " << rect << endl; glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -697,6 +697,7 @@ void ofAppGLFWWindow::disableSetupScreen() { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { +// cout << "setFullScreen " << fullscreen << endl; if (fullscreen) { targetWindowMode = OF_FULLSCREEN; } else { @@ -831,9 +832,11 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { #elif defined(TARGET_OSX) NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); + // This one is to correct if somebody entered fullscreen with green button and is disabling fullscreen if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { if (targetWindowMode == OF_WINDOW) { [cocoaWindow toggleFullScreen:nil]; + settings.windowMode = OF_WINDOW; } else { settings.windowMode = OF_FULLSCREEN; } @@ -850,29 +853,10 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { } if (targetWindowMode == OF_FULLSCREEN) { -// cout << "xx " << &windowP << " xx" << endl; - GLFWmonitor* monitor = glfwGetWindowMonitor(windowP); - if (!monitor) { - monitor = glfwGetPrimaryMonitor(); - } - if (monitor) { - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitor); - glm::ivec2 pos; - glfwGetMonitorPos(monitor, &pos.x, &pos.y); -// cout << "monitor pos " << pos << endl; - - ofRectangle fsRect { (float)pos.x, (float)pos.y, (float)desktopMode->width, (float)desktopMode->height }; - cout << "fsRect " << fsRect << endl; - // FIXME: TODO: Get rectangle for multiple windows. - // if (settings.multiMonitorFullScreen && monitorCount > 1) { - //// fsRect = - // } - setWindowRect(fsRect); - } + setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); } else if (targetWindowMode == OF_WINDOW) { - cout << "OF_WINDOW, windowRect = " << windowRect << endl; setWindowRect(windowRect); setWindowTitle(settings.title); } @@ -1470,8 +1454,12 @@ void ofAppGLFWWindow::char_cb(GLFWwindow * windowP_, uint32_t key) { //------------------------------------------------------------ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ ofAppGLFWWindow * instance = setCurrent(windowP_); - - x *= instance->pixelScreenCoordScale; +// if (instance->targetWindowMode != OF_WINDOW) { +// instance->windowRect.x = x; +// instance->windowRect.y = y; +// } + + x *= instance->pixelScreenCoordScale; y *= instance->pixelScreenCoordScale; instance->events().notifyWindowMoved(x,y); } @@ -1489,35 +1477,26 @@ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { - - glm::ivec2 windowSize; - glfwGetWindowSize(windowP_, &windowSize.x, &windowSize.y); -// cout << "resize_cb a " << w << " : " << h << endl; -// cout << "resize_cb b " << windowSize << endl; - ofAppGLFWWindow * instance = setCurrent(windowP_); - +// if (instance->targetWindowMode == OF_WINDOW) { +// instance->windowRect.width = w; +// instance->windowRect.height = h; +// } // Detect if the window is running in a retina mode - int framebufferW, framebufferH; // <- physical pixel extents - glfwGetFramebufferSize(windowP_, &framebufferW, &framebufferH); - - - - // Find scale factor needed to transform from screen coordinates // to physical pixel coordinates - instance->pixelScreenCoordScale = (float)framebufferW / (float)windowSize.x; +// instance->pixelScreenCoordScale = (float)framebufferW / (float)windowSize.x; - if (instance->settings.windowMode == OF_WINDOW) { - instance->windowW = framebufferW; - instance->windowH = framebufferH; - } +// if (instance->settings.windowMode == OF_WINDOW) { +// instance->windowW = framebufferW; +// instance->windowH = framebufferH; +// } - instance->currentW = windowSize.x; - instance->currentH = windowSize.y; - instance->events().notifyWindowResized(framebufferW, framebufferH); + instance->currentW = w; + instance->currentH = h; + instance->events().notifyWindowResized(w, h); instance->nFramesSinceWindowResized = 0; #if defined(TARGET_OSX) @@ -1532,8 +1511,9 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { //------------------------------------------------------------ void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { - cout << "framebuffer_size_cb " << w << " : " << h << endl; - resize_cb(windowP_, w, h); +// cout << "framebuffer_size_cb " << w << " : " << h << endl; + ofAppGLFWWindow * instance = setCurrent(windowP_); + instance->events().notifyFramebufferResized(w, h); } //-------------------------------------------- diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 893de9c6224..dc7d403814a 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -205,6 +205,9 @@ class ofAppGLFWWindow : public ofAppBaseWindow { }; +using std::cout; +using std::endl; + static struct ofMonitors { public: ofMonitors() {} @@ -215,6 +218,29 @@ static struct ofMonitors { bool changed = true; GLFWmonitor** monitors; bool updateMonitor = true; + + int getWindowMonitorIndex(const ofRectangle & rect) { +// cout << "ini rect : " << rect << endl; + for (unsigned int a=0; aposition = position; this->positionSet = true; @@ -118,11 +123,12 @@ class ofWindowSettings { std::shared_ptr shareContextWith; protected: +// ofRectangle rect { 0, 0, 1024, 768 }; + bool sizeSet { false }; + bool positionSet { false }; int width { 1024 }; int height { 768 }; - bool sizeSet { false }; glm::ivec2 position { 0, 0 }; - bool positionSet { false }; }; typedef ofWindowSettings ofGLWindowSettings; diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index 3ca018c1a77..0518815471d 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -600,6 +600,12 @@ bool ofCoreEvents::notifyWindowResized(int width, int height) { return ofNotifyEvent(windowResized, resizeEventArgs); } +//------------------------------------------ +bool ofCoreEvents::notifyFramebufferResized(int width, int height) { + ofResizeEventArgs resizeEventArgs(width, height); + return ofNotifyEvent(framebufferResized, resizeEventArgs); +} + //------------------------------------------ bool ofCoreEvents::notifyWindowMoved(int x, int y) { ofWindowPosEventArgs windowPosEventArgs(x, y); diff --git a/libs/openFrameworks/events/ofEvents.h b/libs/openFrameworks/events/ofEvents.h index cff8a62dfba..88187d095d3 100644 --- a/libs/openFrameworks/events/ofEvents.h +++ b/libs/openFrameworks/events/ofEvents.h @@ -323,6 +323,7 @@ class ofCoreEvents { ofEvent exit; ofEvent windowResized; + ofEvent framebufferResized; ofEvent windowMoved; ofEvent keyPressed; @@ -396,6 +397,8 @@ class ofCoreEvents { bool notifyExit(); bool notifyWindowResized(int width, int height); + // FIXME: Todo + bool notifyFramebufferResized(int width, int height); bool notifyWindowMoved(int x, int y); bool notifyDragEvent(ofDragInfo info); diff --git a/libs/openFrameworks/types/ofRectangle.h b/libs/openFrameworks/types/ofRectangle.h index 978701590cd..a812551a226 100644 --- a/libs/openFrameworks/types/ofRectangle.h +++ b/libs/openFrameworks/types/ofRectangle.h @@ -798,7 +798,7 @@ class ofRectangle { /// \brief Gets the size of the ofRectangle as glm::vec2. /// \returns The size of the rectangle. - glm::vec2 getSize() const { return glm::vec2 { getWidth(), getHeight() }; } + glm::vec2 getSize() const { return { getWidth(), getHeight() }; } /// \brief Maps a normalized coordinate into this rectangle /// From 8253b25e3023b54bba0ec641ee73f118d8cd6543 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 12:01:54 -0300 Subject: [PATCH 021/143] multimonitor ok --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 40 +++------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 53 ++++++++++++--------- 2 files changed, 38 insertions(+), 55 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 1297f0d0829..20bddf374c2 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -137,7 +137,6 @@ void ofAppGLFWWindow::setStencilBits(int stencil) { //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { - if (windowP) { ofLogError() << "window already setup, probably you are mixing old and new style setup"; ofLogError() << "call only ofCreateWindow(settings) or ofSetupOpenGL(...)"; @@ -152,11 +151,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { return; } - updateMonitorProperties(); - cout << "allScreensSpace " << allMonitors.allScreensSpace << endl; - - - + allMonitors.update(); // ofLogNotice("ofAppGLFWWindow") << "WINDOW MODE IS " << screenMode; glfwDefaultWindowHints(); @@ -441,11 +436,6 @@ shared_ptr & ofAppGLFWWindow::renderer() { //-------------------------------------------- void ofAppGLFWWindow::update() { events().notifyUpdate(); - - if (allMonitors.updateMonitor) { - updateMonitorProperties(); - allMonitors.updateMonitor = false; - } //show the window right before the first draw call. if (bWindowNeedsShowing && windowP) { @@ -853,7 +843,11 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { } if (targetWindowMode == OF_FULLSCREEN) { - setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); + if (settings.multiMonitorFullScreen) { + setWindowRect(allMonitors.getRectForAllMonitors()); + } else { + setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); + } } else if (targetWindowMode == OF_WINDOW) { @@ -1472,7 +1466,7 @@ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { //------------------------------------------------------------ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { - allMonitors.updateMonitor = true; + allMonitors.update(); } //------------------------------------------------------------ @@ -1654,23 +1648,3 @@ HWND ofAppGLFWWindow::getWin32Window() { } #endif - - - -void ofAppGLFWWindow::updateMonitorProperties() { - allMonitors.rects.clear(); - allMonitors.allScreensSpace = { 0,0,0,0 }; // reset ofRectangle; - - int numberOfMonitors; -// GLFWmonitor** monitors = glfwGetMonitors(&numberOfMonitors); - allMonitors.monitors = glfwGetMonitors(&numberOfMonitors); - - for (int i=0; i < numberOfMonitors; i++){ - glm::ivec2 pos; - glfwGetMonitorPos(allMonitors.monitors[i], &pos.x, &pos.y); - const GLFWvidmode * desktopMode = glfwGetVideoMode(allMonitors.monitors[i]); - ofRectangle rect = ofRectangle( pos.x, pos.y, desktopMode->width, desktopMode->height ); - allMonitors.rects.emplace_back(rect); - allMonitors.allScreensSpace = allMonitors.allScreensSpace.getUnion(rect); - } -} diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index dc7d403814a..253fdd2d428 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -199,38 +199,29 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #ifdef TARGET_WIN32 LONG lExStyle, lStyle; #endif // TARGET_WIN32 - - - void updateMonitorProperties(); }; + + + + using std::cout; using std::endl; +// TEMPORARY +#include "GLFW/glfw3.h" + + static struct ofMonitors { public: ofMonitors() {} ~ofMonitors() {} std::vector rects; - ofRectangle allScreensSpace; + ofRectangle allMonitorsRect { 0, 0, 0, 0 }; ofRectangle rectWindow; bool changed = true; GLFWmonitor** monitors; - bool updateMonitor = true; - - int getWindowMonitorIndex(const ofRectangle & rect) { -// cout << "ini rect : " << rect << endl; - for (unsigned int a=0; awidth, desktopMode->height ); + rects.emplace_back(rect); + allMonitorsRect = allMonitorsRect.getUnion(rect); + } + } } allMonitors; // TODO: Remove. - -//static bool updateMonitor = true; //static bool updatePixelScreenCoordScale = true; - - //#endif From fa5b4e1050cadea2fd3fc930b81de47561b6615e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 12:23:11 -0300 Subject: [PATCH 022/143] more cleanup --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 213 +++++++------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 5 +- 2 files changed, 80 insertions(+), 138 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 20bddf374c2..3392e10b7a0 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -446,20 +446,6 @@ void ofAppGLFWWindow::update() { } } -#ifdef TARGET_RASPBERRY_PI - //needed for rpi. as good values don't come into resize_cb when coming out of fullscreen - if (needsResizeCheck && windowP) { - int winW, winH; - glfwGetWindowSize(windowP, &winW, &winH); - - //wait until the window size is the size it was before going fullscreen - //then stop the resize check - if (winW == windowRect.getWidth() && winH == windowRect.getHeight()) { - resize_cb(windowP, currentW, currentH); - needsResizeCheck = false; - } - } -#endif } //-------------------------------------------- @@ -685,6 +671,25 @@ void ofAppGLFWWindow::disableSetupScreen() { bEnableSetupScreen = false; }; +//------------------------------------------------------------ +void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { + if (targetWindowMode == OF_FULLSCREEN) { + // save window shape before going fullscreen + windowRect = getWindowRect(); + + if (settings.multiMonitorFullScreen) { + setWindowRect(allMonitors.getRectForAllMonitors()); + } else { + setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); + } + } + + else if (targetWindowMode == OF_WINDOW) { + setWindowRect(windowRect); + setWindowTitle(settings.title); + } +} + //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // cout << "setFullScreen " << fullscreen << endl; @@ -697,12 +702,68 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { //we only want to change window mode if the requested window is different to the current one. if (targetWindowMode == settings.windowMode) return; +#ifdef TARGET_OSX + NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); + // This one is to correct if somebody entered fullscreen with green button and is disabling fullscreen + if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { + if (targetWindowMode == OF_WINDOW) { + [cocoaWindow toggleFullScreen:nil]; + settings.windowMode = OF_WINDOW; + } else { + settings.windowMode = OF_FULLSCREEN; + } + } + if (targetWindowMode == OF_FULLSCREEN) { - // save window shape before going fullscreen - windowRect = getWindowRect(); + [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; + [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; + [cocoaWindow setHasShadow:NO]; + } else { + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; + [cocoaWindow setHasShadow:YES]; } + + setFSTarget(targetWindowMode); -#ifdef TARGET_LINUX + //---------------------------------------------------- + //make sure the window is getting the mouse/key events + [cocoaWindow makeFirstResponder:cocoaWindow.contentView]; + +#elif defined(TARGET_WIN32) + + HWND hwnd = glfwGetWin32Window(windowP); + + if (targetWindowMode == OF_FULLSCREEN) { + SetWindowLong(hwnd, GWL_EXSTYLE, 0); + SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW); + + // TODO: Here discover windows dimensions + // set window position, shape here. + +// SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); + + } else if (targetWindowMode == OF_WINDOW) { + + DWORD EX_STYLE = WS_EX_OVERLAPPEDWINDOW; + DWORD STYLE = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SIZEBOX; + + ChangeDisplaySettings(0, 0); + SetWindowLong(hwnd, GWL_EXSTYLE, EX_STYLE); + SetWindowLong(hwnd, GWL_STYLE, STYLE); + SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW); + + //not sure why this is - but if we don't do this the window shrinks by 4 pixels in x and y + //should look for a better fix. +// setWindowPosition(windowRect.x - 2, windowRect.y - 2); +// setWindowShape(windowRect.width + 4, windowRect.height + 4); + } + + SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); + + +#elif defined(TARGET_LINUX) #include Window nativeWin = glfwGetX11Window(windowP); @@ -809,127 +870,9 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { XFlush(display); - #ifdef TARGET_RASPBERRY_PI - if (!fullscreen) { - needsResizeCheck = true; - } - #endif - // setWindowShape(windowW, windowH); - -#elif defined(TARGET_OSX) - - NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); - // This one is to correct if somebody entered fullscreen with green button and is disabling fullscreen - if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { - if (targetWindowMode == OF_WINDOW) { - [cocoaWindow toggleFullScreen:nil]; - settings.windowMode = OF_WINDOW; - } else { - settings.windowMode = OF_FULLSCREEN; - } - } - - if (targetWindowMode == OF_FULLSCREEN) { - [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; - [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; - [cocoaWindow setHasShadow:NO]; - } else { - [NSApp setPresentationOptions:NSApplicationPresentationDefault]; - [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; - [cocoaWindow setHasShadow:YES]; - } - - if (targetWindowMode == OF_FULLSCREEN) { - if (settings.multiMonitorFullScreen) { - setWindowRect(allMonitors.getRectForAllMonitors()); - } else { - setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); - } - } - - else if (targetWindowMode == OF_WINDOW) { - setWindowRect(windowRect); - setWindowTitle(settings.title); - } - - //---------------------------------------------------- - //make sure the window is getting the mouse/key events - [cocoaWindow makeFirstResponder:cocoaWindow.contentView]; - -#elif defined(TARGET_WIN32) - if (targetWindowMode == OF_FULLSCREEN) { - - //---------------------------------------------------- - HWND hwnd = glfwGetWin32Window(windowP); - - SetWindowLong(hwnd, GWL_EXSTYLE, 0); - SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW); - - float fullscreenW = getScreenSize().x; - float fullscreenH = getScreenSize().y; - - int xpos = 0; - int ypos = 0; - - if (settings.multiMonitorFullScreen) { - - int minX = 0; - int maxX = 0; - int minY = 0; - int maxY = 0; - int monitorCount; - GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); - int tempXPos = 0; - int tempYPos = 0; - //lets find the total width of all the monitors - //and we'll make the window height the height of the largest monitor. - for (int i = 0; i < monitorCount; i++) { - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitors[i]); - glfwGetMonitorPos(monitors[i], &tempXPos, &tempYPos); - minX = std::min(tempXPos, minX); - minY = std::min(tempYPos, minY); - maxX = std::max(maxX, tempXPos + desktopMode->width); - maxY = std::max(maxY, tempYPos + desktopMode->height); - - xpos = std::min(xpos, tempXPos); - ypos = std::min(ypos, tempYPos); - } - - fullscreenW = maxX - minX; - fullscreenH = maxY - minY; - } else { - - int monitorCount; - GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); - int currentMonitor = getCurrentMonitor(); - glfwGetMonitorPos(monitors[currentMonitor], &xpos, &ypos); - } - - SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); - currentW = fullscreenW; - currentH = fullscreenH; - - } else if (targetWindowMode == OF_WINDOW) { - - HWND hwnd = glfwGetWin32Window(windowP); - - DWORD EX_STYLE = WS_EX_OVERLAPPEDWINDOW; - DWORD STYLE = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SIZEBOX; - - ChangeDisplaySettings(0, 0); - SetWindowLong(hwnd, GWL_EXSTYLE, EX_STYLE); - SetWindowLong(hwnd, GWL_STYLE, STYLE); - SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW); - - //not sure why this is - but if we don't do this the window shrinks by 4 pixels in x and y - //should look for a better fix. - setWindowPosition(windowRect.x - 2, windowRect.y - 2); - setWindowShape(windowRect.width + 4, windowRect.height + 4); - } #endif settings.windowMode = targetWindowMode; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 253fdd2d428..7d910894158 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -184,9 +184,6 @@ class ofAppGLFWWindow : public ofAppBaseWindow { int nFramesSinceWindowResized; bool bWindowNeedsShowing; -#ifdef TARGET_RASPBERRY_PI - bool needsResizeCheck = false; /// Just for RPI at this point -#endif GLFWwindow * windowP; @@ -199,6 +196,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #ifdef TARGET_WIN32 LONG lExStyle, lStyle; #endif // TARGET_WIN32 + + void setFSTarget(ofWindowMode targetWindowMode); }; From 81a4da492e2d6478c8ae9905a5e44eb3225a73d8 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 12:58:39 -0300 Subject: [PATCH 023/143] setup simplification --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 80 +++++++++++---------- libs/openFrameworks/app/ofAppGLFWWindow.h | 7 +- libs/openFrameworks/app/ofAppNoWindow.cpp | 2 +- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 3392e10b7a0..ce5a2b539ad 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -55,10 +55,7 @@ ofAppGLFWWindow::ofAppGLFWWindow() nFramesSinceWindowResized = 0; iconSet = false; windowP = nullptr; - windowW = 0; - windowH = 0; - currentW = 0; - currentH = 0; + glfwSetErrorCallback(error_cb); } @@ -205,6 +202,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { sharedContext = (GLFWwindow *)settings.shareContextWith->getWindowContext(); } + + if (settings.windowMode == OF_GAME_MODE) { int count; GLFWmonitor ** monitors = glfwGetMonitors(&count); @@ -213,26 +212,48 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } settings.monitor = ofClamp(settings.monitor, 0, count - 1); if (settings.isSizeSet()) { - currentW = settings.getWidth(); - currentH = settings.getHeight(); + windowRect.width = settings.getWidth(); + windowRect.height = settings.getHeight(); } else { auto mode = glfwGetVideoMode(monitors[settings.monitor]); - currentW = mode->width; - currentH = mode->height; + windowRect.width = mode->width; + windowRect.height = mode->height; } if (count > settings.monitor) { - windowP = glfwCreateWindow(currentW, currentH, settings.title.c_str(), monitors[settings.monitor], sharedContext); + // MARK: - WINDOW + windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitors[settings.monitor], sharedContext); } else { ofLogError("ofAppGLFWWindow") << "couldn't find any monitors"; return; } } else { - windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), nullptr, sharedContext); + + // TODO: move up, outside windowmode + // HACK: asdf + windowRect.width = settings.getWidth(); + windowRect.height = settings.getHeight(); + GLFWmonitor *monitor = nullptr; + + if (settings.windowMode == OF_FULLSCREEN) { + int monitorIndex = 0; + // Check to see if desired monitor is connected. + if (allMonitors.rects.size() >= settings.monitor) { + int monitorIndex = settings.monitor; + } else { + ofLogError("ofAppGLFWWindow") << "requested game mode monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); + } + windowRect = allMonitors.rects[monitorIndex]; + monitor = allMonitors.monitors[monitorIndex]; + } + // MARK: - WINDOW + windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); + if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; } - + +#ifdef WREMBLES if (settings.windowMode == OF_FULLSCREEN) { int count = 0; auto monitors = glfwGetMonitors(&count); @@ -292,6 +313,10 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } glfwGetWindowSize(windowP, ¤tW, ¤tH); } + +#endif //WREMBLES + + #ifdef TARGET_LINUX if (!iconSet) { ofPixels iconPixels; @@ -315,8 +340,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwSetWindowUserPointer(windowP, this); - windowW = settings.getWidth(); - windowH = settings.getHeight(); +// windowW = settings.getWidth(); +// windowH = settings.getHeight(); glfwMakeContextCurrent(windowP); @@ -324,20 +349,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwGetFramebufferSize(windowP, &framebufferW, &framebufferH); glfwGetWindowSize(windowP, &tmpWindowW, &tmpWindowH); - //this lets us detect if the window is running in a retina mode - if (framebufferW != tmpWindowW) { - pixelScreenCoordScale = (float)framebufferW / (float)tmpWindowW; - if (pixelScreenCoordScale < 1) { - pixelScreenCoordScale = 1; - } - if (targetWindowMode == OF_WINDOW) { - auto position = getWindowPosition(); - - setWindowShape(windowW, windowH); - setWindowPosition(position.x, position.y); - } - } #ifndef TARGET_OPENGLES static bool inited = false; @@ -608,20 +620,12 @@ glm::ivec2 ofAppGLFWWindow::getScreenSize() { //------------------------------------------------------------ int ofAppGLFWWindow::getWidth() { - if (orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180) { - return currentW * pixelScreenCoordScale; - } else { - return currentH * pixelScreenCoordScale; - } + return windowRect.width; } //------------------------------------------------------------ int ofAppGLFWWindow::getHeight() { - if (orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180) { - return currentH * pixelScreenCoordScale; - } else { - return currentW * pixelScreenCoordScale; - } + return windowRect.height; } //------------------------------------------------------------ @@ -1431,8 +1435,8 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { // instance->windowH = framebufferH; // } - instance->currentW = w; - instance->currentH = h; +// instance->currentW = w; +// instance->currentH = h; instance->events().notifyWindowResized(w, h); instance->nFramesSinceWindowResized = 0; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 7d910894158..b0d6760eb13 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -172,8 +172,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { ofWindowMode targetWindowMode; bool bEnableSetupScreen; - int windowW, windowH; /// Physical framebuffer pixels extents - int currentW, currentH; /// Extents of the window client area, which may be scaled by pixelsScreenCoordScale to map to physical framebuffer pixels. + // FIXME remove float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH). ofRectangle windowRect { 20, 20, 1024, 768 }; @@ -218,8 +217,8 @@ static struct ofMonitors { ~ofMonitors() {} std::vector rects; ofRectangle allMonitorsRect { 0, 0, 0, 0 }; - ofRectangle rectWindow; - bool changed = true; +// ofRectangle rectWindow; +// bool changed = true; GLFWmonitor** monitors; ofRectangle getRectMonitorForScreenRect(const ofRectangle & rect) { diff --git a/libs/openFrameworks/app/ofAppNoWindow.cpp b/libs/openFrameworks/app/ofAppNoWindow.cpp index 4cfa8c80a55..fe3bc84b383 100644 --- a/libs/openFrameworks/app/ofAppNoWindow.cpp +++ b/libs/openFrameworks/app/ofAppNoWindow.cpp @@ -291,7 +291,7 @@ glm::ivec2 ofAppNoWindow::getWindowSize(){ //---------------------------------------------------------- glm::ivec2 ofAppNoWindow::getScreenSize(){ - return {width, height}; + return { width, height }; } From 14a4e392716c47c545842061626675a7bdf8957e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 14:07:55 -0300 Subject: [PATCH 024/143] simplify setup --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 188 ++++++-------------- 1 file changed, 53 insertions(+), 135 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index ce5a2b539ad..69f757c7592 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -140,7 +140,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError() << "calling window->setup() after ofCreateWindow() is not necessary and won't do anything"; return; } - + settings = _settings; if (!glfwInit()) { @@ -202,121 +202,44 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { sharedContext = (GLFWwindow *)settings.shareContextWith->getWindowContext(); } - - + + + // TODO: move up, outside windowmode + // HACK: asdf + windowRect.width = settings.getWidth(); + windowRect.height = settings.getHeight(); + GLFWmonitor *monitor = nullptr; + if (settings.windowMode == OF_GAME_MODE) { - int count; - GLFWmonitor ** monitors = glfwGetMonitors(&count); - if (settings.monitor >= count) { - ofLogError("ofAppGLFWWindow") << "requested game mode monitor is: " << settings.monitor << " monitor count is: " << count; - } - settings.monitor = ofClamp(settings.monitor, 0, count - 1); - if (settings.isSizeSet()) { - windowRect.width = settings.getWidth(); - windowRect.height = settings.getHeight(); - } else { - auto mode = glfwGetVideoMode(monitors[settings.monitor]); - windowRect.width = mode->width; - windowRect.height = mode->height; - } - if (count > settings.monitor) { - // MARK: - WINDOW - windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitors[settings.monitor], sharedContext); + int monitorIndex = 0; + // Check to see if desired monitor is connected. + if (allMonitors.rects.size() >= settings.monitor) { + int monitorIndex = settings.monitor; } else { - ofLogError("ofAppGLFWWindow") << "couldn't find any monitors"; - return; + ofLogError("ofAppGLFWWindow") << "requested game mode monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); } - } else { - - // TODO: move up, outside windowmode - // HACK: asdf - windowRect.width = settings.getWidth(); - windowRect.height = settings.getHeight(); - GLFWmonitor *monitor = nullptr; - - if (settings.windowMode == OF_FULLSCREEN) { - int monitorIndex = 0; - // Check to see if desired monitor is connected. - if (allMonitors.rects.size() >= settings.monitor) { - int monitorIndex = settings.monitor; - } else { - ofLogError("ofAppGLFWWindow") << "requested game mode monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); - } - windowRect = allMonitors.rects[monitorIndex]; - monitor = allMonitors.monitors[monitorIndex]; - } - // MARK: - WINDOW - windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); + windowRect = allMonitors.rects[monitorIndex]; + monitor = allMonitors.monitors[monitorIndex]; + } + + cout << "GLFW Will create" << endl; + // MARK: - WINDOW + windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); + cout << "GLFW created" << endl; + + if (!windowP) { + ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; + return; + } + + if (settings.windowMode == OF_FULLSCREEN) { + setFullscreen(true); + } + + // MARK: - + + if (settings.windowMode != OF_GAME_MODE) { - if (!windowP) { - ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; - return; - } - -#ifdef WREMBLES - if (settings.windowMode == OF_FULLSCREEN) { - int count = 0; - auto monitors = glfwGetMonitors(&count); - if (settings.monitor >= count) { - ofLogError("ofAppGLFWWindow") << "requested fullscreen monitor is: " << settings.monitor << " monitor count is: " << count; - } - settings.monitor = ofClamp(settings.monitor, 0, count - 1); - - auto mode = glfwGetVideoMode(monitors[settings.monitor]); - currentW = mode->width; - currentH = mode->height; - if (!settings.isPositionSet()) { - if (count > 0) { - int x = 0, y = 0; - glfwGetMonitorPos(monitors[settings.monitor], &x, &y); - settings.setPosition(glm::vec2(x, y)); - setWindowPosition(settings.getPosition().x, settings.getPosition().y); - auto mode = glfwGetVideoMode(monitors[settings.monitor]); -#ifdef TARGET_OSX - //for OS X we need to set this first as the window size affects the window positon - settings.setSize(mode->width, mode->height); -#endif - setWindowPosition(settings.getPosition().x, settings.getPosition().y); - currentW = mode->width; - currentH = mode->height; - } - } else { - setWindowPosition(settings.getPosition().x, settings.getPosition().y); -#ifdef TARGET_OSX - auto size = getScreenSize(); - settings.setSize(size.x, size.y); -#endif - currentW = settings.getWidth(); - currentH = settings.getHeight(); - for (int i = 0; i < count; i++) { - int x = 0, y = 0; - glfwGetMonitorPos(monitors[i], &x, &y); - auto mode = glfwGetVideoMode(monitors[i]); - int w = mode->width; - int h = mode->height; - ofRectangle rect(x - 1, y - 1, w + 1, h + 1); - if (rect.inside(settings.getPosition())) { - currentW = mode->width; - currentH = mode->height; - break; - } - } - } - targetWindowMode = settings.windowMode; - settings.windowMode = OF_WINDOW; - if (settings.maximized) { - glfwMaximizeWindow(windowP); - } - } else { - if (settings.isPositionSet()) { - setWindowPosition(settings.getPosition().x, settings.getPosition().y); - } - glfwGetWindowSize(windowP, ¤tW, ¤tH); - } - -#endif //WREMBLES - - #ifdef TARGET_LINUX if (!iconSet) { ofPixels iconPixels; @@ -333,23 +256,18 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { if (settings.iconified) { iconify(true); } + + if (settings.maximized) { + glfwMaximizeWindow(windowP); + } } //don't try and show a window if its been requsted to be hidden bWindowNeedsShowing = settings.visible; glfwSetWindowUserPointer(windowP, this); - -// windowW = settings.getWidth(); -// windowH = settings.getHeight(); - glfwMakeContextCurrent(windowP); - int framebufferW, framebufferH, tmpWindowW, tmpWindowH; - glfwGetFramebufferSize(windowP, &framebufferW, &framebufferH); - glfwGetWindowSize(windowP, &tmpWindowW, &tmpWindowH); - - #ifndef TARGET_OPENGLES static bool inited = false; @@ -384,7 +302,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwSetKeyCallback(windowP, keyboard_cb); glfwSetCharCallback(windowP, char_cb); glfwSetWindowSizeCallback(windowP, resize_cb); - glfwSetWindowPosCallback(windowP,position_cb); + glfwSetWindowPosCallback(windowP,position_cb); glfwSetFramebufferSizeCallback(windowP, framebuffer_size_cb); glfwSetWindowCloseCallback(windowP, exit_cb); glfwSetScrollCallback(windowP, scroll_cb); @@ -448,7 +366,7 @@ shared_ptr & ofAppGLFWWindow::renderer() { //-------------------------------------------- void ofAppGLFWWindow::update() { events().notifyUpdate(); - + //show the window right before the first draw call. if (bWindowNeedsShowing && windowP) { glfwShowWindow(windowP); @@ -546,9 +464,9 @@ void ofAppGLFWWindow::setWindowTitle(const std::string & title) { //------------------------------------------------------------ int ofAppGLFWWindow::getPixelScreenCoordScale() { - + // TODO: - // discover which monitor this window + // discover which monitor this window return pixelScreenCoordScale; } @@ -687,7 +605,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); } } - + else if (targetWindowMode == OF_WINDOW) { setWindowRect(windowRect); setWindowTitle(settings.title); @@ -705,7 +623,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { //we only want to change window mode if the requested window is different to the current one. if (targetWindowMode == settings.windowMode) return; - + #ifdef TARGET_OSX NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); // This one is to correct if somebody entered fullscreen with green button and is disabling fullscreen @@ -727,13 +645,13 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; [cocoaWindow setHasShadow:YES]; } - + setFSTarget(targetWindowMode); //---------------------------------------------------- //make sure the window is getting the mouse/key events [cocoaWindow makeFirstResponder:cocoaWindow.contentView]; - + #elif defined(TARGET_WIN32) HWND hwnd = glfwGetWin32Window(windowP); @@ -745,7 +663,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // TODO: Here discover windows dimensions // set window position, shape here. - + // SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); } else if (targetWindowMode == OF_WINDOW) { @@ -763,10 +681,10 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // setWindowPosition(windowRect.x - 2, windowRect.y - 2); // setWindowShape(windowRect.width + 4, windowRect.height + 4); } - + SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); - + #elif defined(TARGET_LINUX) #include @@ -1394,15 +1312,15 @@ void ofAppGLFWWindow::char_cb(GLFWwindow * windowP_, uint32_t key) { //------------------------------------------------------------ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ - ofAppGLFWWindow * instance = setCurrent(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); // if (instance->targetWindowMode != OF_WINDOW) { // instance->windowRect.x = x; // instance->windowRect.y = y; // } x *= instance->pixelScreenCoordScale; - y *= instance->pixelScreenCoordScale; - instance->events().notifyWindowMoved(x,y); + y *= instance->pixelScreenCoordScale; + instance->events().notifyWindowMoved(x,y); } //------------------------------------------------------------ From 9e9d64c2ef497f5cd9d1ff5da94288716419386d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 14:43:53 -0300 Subject: [PATCH 025/143] more cleanup --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 60 ++++++--------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 6 +-- 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 69f757c7592..cecea2a1a3e 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -206,6 +206,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { // TODO: move up, outside windowmode // HACK: asdf + windowRect.setPosition(settings.getPosition().x, settings.getPosition().y); windowRect.width = settings.getWidth(); windowRect.height = settings.getHeight(); GLFWmonitor *monitor = nullptr; @@ -224,9 +225,12 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { cout << "GLFW Will create" << endl; // MARK: - WINDOW + cout << "windowRect " << windowRect << endl; + windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); cout << "GLFW created" << endl; + setWindowRect(windowRect); if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; @@ -493,47 +497,10 @@ glm::ivec2 ofAppGLFWWindow::getWindowPosition() { return pos; } -//------------------------------------------------------------ -int ofAppGLFWWindow::getCurrentMonitor() { - int numberOfMonitors; - GLFWmonitor ** monitors = glfwGetMonitors(&numberOfMonitors); - - int xW; - int yW; - glfwGetWindowPos(windowP, &xW, &yW); - - for (int iC = 0; iC < numberOfMonitors; iC++) { - int xM; - int yM; - glfwGetMonitorPos(monitors[iC], &xM, &yM); - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitors[iC]); - ofRectangle monitorRect(xM, yM, desktopMode->width, desktopMode->height); - bool bPointMatch = xW >= monitorRect.getMinX() && yW >= monitorRect.getMinY() && xW < monitorRect.getMaxX() && yW < monitorRect.getMaxY(); - // if (monitorRect.inside(xW, yW)){ - if (bPointMatch) { - return iC; - break; - } - } - return 0; -} - //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getScreenSize() { - int count; - GLFWmonitor ** monitors = glfwGetMonitors(&count); - if (count > 0) { - int currentMonitor = getCurrentMonitor(); - const GLFWvidmode * desktopMode = glfwGetVideoMode(monitors[currentMonitor]); - if (desktopMode) { - if (orientation == OF_ORIENTATION_DEFAULT || orientation == OF_ORIENTATION_180) { - return { desktopMode->width * pixelScreenCoordScale, desktopMode->height * pixelScreenCoordScale }; - } else { - return { desktopMode->height * pixelScreenCoordScale, desktopMode->width * pixelScreenCoordScale }; - } - } - } - return glm::vec2(); + // FIXME: is this correct? if screen = monitor and screensize is actual monitor from the window it is. + return allMonitors.getRectMonitorForScreenRect(windowRect).getSize(); } //------------------------------------------------------------ @@ -745,15 +712,21 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { xev.xclient.data.l[4] = 1; XSendEvent(display, RootWindow(display, DefaultScreen(display)), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); - currentW = maxx - minx; - currentH = maxy - minx; + + // FIXME: review + windowRect.width = maxx - minx; + windowRect.height = maxy - minx; +// currentW = maxx - minx; +// currentH = maxy - minx; } else { auto monitor = glfwGetWindowMonitor(windowP); if (monitor) { auto videoMode = glfwGetVideoMode(monitor); if (videoMode) { - currentW = videoMode->width; - currentH = videoMode->height; + windowRect.width = videoMode->width; + windowRect.height = videoMode->height; +// currentW = videoMode->width; +// currentH = videoMode->height; } } } @@ -1331,6 +1304,7 @@ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { //------------------------------------------------------------ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { + cout << "monitor_cb!" << endl; allMonitors.update(); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index b0d6760eb13..ab3694c7aa6 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -183,11 +183,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { int nFramesSinceWindowResized; bool bWindowNeedsShowing; - GLFWwindow * windowP; - - int getCurrentMonitor(); - ofBaseApp * ofAppPtr; bool iconSet; @@ -223,7 +219,7 @@ static struct ofMonitors { ofRectangle getRectMonitorForScreenRect(const ofRectangle & rect) { for (unsigned int a=0; a Date: Wed, 17 Jan 2024 15:22:00 -0300 Subject: [PATCH 026/143] more --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 54 ++++++++++++++------- libs/openFrameworks/app/ofAppRunner.cpp | 9 +++- libs/openFrameworks/app/ofAppRunner.h | 5 +- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index cecea2a1a3e..b70afb93041 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -211,34 +211,37 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { windowRect.height = settings.getHeight(); GLFWmonitor *monitor = nullptr; + int monitorIndex = 0; + // Check to see if desired monitor is connected. + if (allMonitors.rects.size() > settings.monitor) { + monitorIndex = settings.monitor; + } else { + ofLogError("ofAppGLFWWindow") << "requested monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); + } + if (settings.windowMode == OF_GAME_MODE) { - int monitorIndex = 0; - // Check to see if desired monitor is connected. - if (allMonitors.rects.size() >= settings.monitor) { - int monitorIndex = settings.monitor; - } else { - ofLogError("ofAppGLFWWindow") << "requested game mode monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); - } windowRect = allMonitors.rects[monitorIndex]; monitor = allMonitors.monitors[monitorIndex]; } + else if (settings.windowMode == OF_WINDOW) { + cout << "rects size " << allMonitors.rects.size() << endl; + cout << "window mode monitorindex = " << monitorIndex << endl; + cout << "settings.monitor = " << settings.monitor << endl; + windowRect.x += allMonitors.rects[monitorIndex].x; + windowRect.y += allMonitors.rects[monitorIndex].y; + } - cout << "GLFW Will create" << endl; + cout << "GLFW Will create windowRect " << windowRect << endl; // MARK: - WINDOW - cout << "windowRect " << windowRect << endl; - windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); - cout << "GLFW created" << endl; setWindowRect(windowRect); if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; } + cout << "GLFW window created OK" << endl; - if (settings.windowMode == OF_FULLSCREEN) { - setFullscreen(true); - } // MARK: - @@ -272,7 +275,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwSetWindowUserPointer(windowP, this); glfwMakeContextCurrent(windowP); - +// windowMode = settings.windowMode; + #ifndef TARGET_OPENGLES static bool inited = false; if (!inited) { @@ -327,6 +331,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { XNFocusWindow, getX11Window(), NULL); #endif + + cout << "GLFW end setup" << endl; } #ifdef TARGET_LINUX @@ -373,11 +379,24 @@ void ofAppGLFWWindow::update() { //show the window right before the first draw call. if (bWindowNeedsShowing && windowP) { + + NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); + [cocoaWindow setLevel:NSScreenSaverWindowLevel + 1]; + [cocoaWindow orderFrontRegardless]; + + cout << "FIRST" << endl; glfwShowWindow(windowP); bWindowNeedsShowing = false; - if (targetWindowMode == OF_FULLSCREEN) { + + if (settings.windowMode == OF_FULLSCREEN) { setFullscreen(true); + } else { + setFullscreen(false); } + cout << "AFTER FIRST" << endl; +// if (targetWindowMode == OF_FULLSCREEN) { +// setFullscreen(true); +// } } } @@ -565,6 +584,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { if (targetWindowMode == OF_FULLSCREEN) { // save window shape before going fullscreen windowRect = getWindowRect(); + cout << "saving window rect " << windowRect << endl; if (settings.multiMonitorFullScreen) { setWindowRect(allMonitors.getRectForAllMonitors()); @@ -581,7 +601,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { -// cout << "setFullScreen " << fullscreen << endl; + cout << "setFullScreen " << fullscreen << endl; if (fullscreen) { targetWindowMode = OF_FULLSCREEN; } else { diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 72d4299c47a..d111a687253 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -392,12 +392,17 @@ int ofGetWindowPositionY(){ //-------------------------------------- int ofGetScreenWidth(){ - return (int)mainLoop()->getCurrentWindow()->getScreenSize().x; + return mainLoop()->getCurrentWindow()->getScreenSize().x; } //-------------------------------------- int ofGetScreenHeight(){ - return (int)mainLoop()->getCurrentWindow()->getScreenSize().y; + return mainLoop()->getCurrentWindow()->getScreenSize().y; +} + +//-------------------------------------- +glm::ivec2 ofGetScreenSize() { + return mainLoop()->getCurrentWindow()->getScreenSize(); } //-------------------------------------------------- diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 4f573dab8de..24178427192 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -76,10 +76,11 @@ int ofGetWindowPositionX(); int ofGetWindowPositionY(); int ofGetScreenWidth(); int ofGetScreenHeight(); +glm::ivec2 ofGetScreenSize(); int ofGetWindowMode(); -int ofGetWidth(); // ofGetWidth is correct for orientation +int ofGetWidth(); int ofGetHeight(); -int ofGetWindowWidth(); // ofGetWindowWidth is correct for actual window coordinates - so doesn't change with orientation. +int ofGetWindowWidth(); int ofGetWindowHeight(); std::string ofGetClipboardString(); From 6f5abfeb0f7d285a930ffeb1cd5597005e062089 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 15:52:26 -0300 Subject: [PATCH 027/143] advancing --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 38 ++++++++++----------- libs/openFrameworks/app/ofAppGLFWWindow.h | 2 +- libs/openFrameworks/app/ofWindowSettings.h | 8 +++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index b70afb93041..9ee9923b2d0 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -381,19 +381,23 @@ void ofAppGLFWWindow::update() { if (bWindowNeedsShowing && windowP) { NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); - [cocoaWindow setLevel:NSScreenSaverWindowLevel + 1]; +// [cocoaWindow setLevel:NSScreenSaverWindowLevel + 1]; [cocoaWindow orderFrontRegardless]; cout << "FIRST" << endl; glfwShowWindow(windowP); bWindowNeedsShowing = false; + cout << "FS" << endl; + if (settings.windowMode == OF_FULLSCREEN) { + // Meant to trigger fullscreen forced + settings.windowMode = OF_WINDOWMODE_UNDEFINED; setFullscreen(true); } else { setFullscreen(false); } - cout << "AFTER FIRST" << endl; + cout << "AFTER" << endl; // if (targetWindowMode == OF_FULLSCREEN) { // setFullscreen(true); // } @@ -518,7 +522,8 @@ glm::ivec2 ofAppGLFWWindow::getWindowPosition() { //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getScreenSize() { - // FIXME: is this correct? if screen = monitor and screensize is actual monitor from the window it is. + // FIXME: if screen = monitor and screensize is actual monitor from the window it is correct. + windowRect = getWindowRect(); return allMonitors.getRectMonitorForScreenRect(windowRect).getSize(); } @@ -539,8 +544,7 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { -// cout << "setWindowRect " << rect << endl; - + cout << "setWindowRect " << rect << endl; glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -1303,19 +1307,6 @@ void ofAppGLFWWindow::char_cb(GLFWwindow * windowP_, uint32_t key) { instance->events().charEvent.notify(key); } -//------------------------------------------------------------ -void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ - ofAppGLFWWindow * instance = setCurrent(windowP_); -// if (instance->targetWindowMode != OF_WINDOW) { -// instance->windowRect.x = x; -// instance->windowRect.y = y; -// } - - x *= instance->pixelScreenCoordScale; - y *= instance->pixelScreenCoordScale; - instance->events().notifyWindowMoved(x,y); -} - //------------------------------------------------------------ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { ofAppGLFWWindow * instance = setCurrent(windowP_); @@ -1328,10 +1319,19 @@ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { allMonitors.update(); } +//------------------------------------------------------------ +void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ + ofAppGLFWWindow * instance = setCurrent(windowP_); +// if (instance->settings.windowMode == OF_WINDOW) { +// instance->windowRect.x = x; +// instance->windowRect.y = y; +// } + instance->events().notifyWindowMoved(x, y); +} //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { ofAppGLFWWindow * instance = setCurrent(windowP_); -// if (instance->targetWindowMode == OF_WINDOW) { +// if (instance->settings.windowMode == OF_WINDOW) { // instance->windowRect.width = w; // instance->windowRect.height = h; // } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index ab3694c7aa6..7858cdd86f5 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -149,8 +149,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { static void entry_cb(GLFWwindow* windowP_, int entered); static void keyboard_cb(GLFWwindow* windowP_, int key, int scancode, int action, int mods); static void char_cb(GLFWwindow* windowP_, uint32_t key); - static void resize_cb(GLFWwindow* windowP_, int w, int h); static void position_cb(GLFWwindow* windowP_, int x, int y); + static void resize_cb(GLFWwindow* windowP_, int w, int h); static void framebuffer_size_cb(GLFWwindow* windowP_, int w, int h); static void exit_cb(GLFWwindow * windowP_); static void scroll_cb(GLFWwindow * windowP_, double x, double y); diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index c5b1df1d646..b1133f30c06 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -14,7 +14,9 @@ enum ofWindowMode{ /// \brief A fullscreen application window. OF_FULLSCREEN = 1, /// \brief A fullscreen application window with a custom width and height. - OF_GAME_MODE = 2 + OF_GAME_MODE = 2, + + OF_WINDOWMODE_UNDEFINED = 3 }; @@ -121,9 +123,9 @@ class ofWindowSettings { int monitor = 0; bool multiMonitorFullScreen = false; std::shared_ptr shareContextWith; - + std::vector fullscreenDisplays; + protected: -// ofRectangle rect { 0, 0, 1024, 768 }; bool sizeSet { false }; bool positionSet { false }; int width { 1024 }; From 0d4b19fb8a10e980cd6607cf69b316469c011d8e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 15:54:04 -0300 Subject: [PATCH 028/143] fix ifdef osx --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 9ee9923b2d0..52cb7771bb5 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -380,9 +380,12 @@ void ofAppGLFWWindow::update() { //show the window right before the first draw call. if (bWindowNeedsShowing && windowP) { + // not working. +#ifdef TARGET_OSX NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); // [cocoaWindow setLevel:NSScreenSaverWindowLevel + 1]; [cocoaWindow orderFrontRegardless]; +#endif cout << "FIRST" << endl; glfwShowWindow(windowP); From 7f6cf0e4c6a27f3040fd9db6e716788f516c4f1e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 16:26:12 -0300 Subject: [PATCH 029/143] update img tests --- tests/io/loadImage/src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/io/loadImage/src/main.cpp b/tests/io/loadImage/src/main.cpp index 914effb017b..3abc0f21a56 100644 --- a/tests/io/loadImage/src/main.cpp +++ b/tests/io/loadImage/src/main.cpp @@ -9,7 +9,10 @@ class ofApp: public ofxUnitTestsApp{ ofxTest(img.load("indispensable.jpg"), "load from fs"); ofxTest(img.load(ofToDataPath("indispensable.jpg", true)), "load from fs"); ofxTest(img.load("http://openframeworks.cc/about/0.jpg"), "load from http"); - ofxTest(img.load("https://forum.openframeworks.cc/user_avatar/forum.openframeworks.cc/arturo/45/3965_1.png"), "load from https"); + // https://avatars.githubusercontent.com/u/58289?v=4 + // https://avatars.githubusercontent.com/u/144000?v=4 + // ofxTest(img.load("https://forum.openframeworks.cc/user_avatar/forum.openframeworks.cc/arturo/45/3965_1.png"), "load from https"); + ofxTest(img.load("https://avatars.githubusercontent.com/u/58289?v=4"), "load from https"); } }; From 2f4cc853fffd43e32b8ed17d8064cdc75e77353f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 17:03:31 -0300 Subject: [PATCH 030/143] fix vector --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 63 ++++++++------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 39 ++++++++++++- tests/io/loadImage/src/main.cpp | 7 ++- 3 files changed, 65 insertions(+), 44 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 52cb7771bb5..10607f0603c 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -224,14 +224,14 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { monitor = allMonitors.monitors[monitorIndex]; } else if (settings.windowMode == OF_WINDOW) { - cout << "rects size " << allMonitors.rects.size() << endl; - cout << "window mode monitorindex = " << monitorIndex << endl; - cout << "settings.monitor = " << settings.monitor << endl; +// cout << "rects size " << allMonitors.rects.size() << endl; +// cout << "window mode monitorindex = " << monitorIndex << endl; +// cout << "settings.monitor = " << settings.monitor << endl; windowRect.x += allMonitors.rects[monitorIndex].x; windowRect.y += allMonitors.rects[monitorIndex].y; } - cout << "GLFW Will create windowRect " << windowRect << endl; +// cout << "GLFW Will create windowRect " << windowRect << endl; // MARK: - WINDOW windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); @@ -240,7 +240,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; } - cout << "GLFW window created OK" << endl; +// cout << "GLFW window created OK" << endl; // MARK: - @@ -332,7 +332,15 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { NULL); #endif - cout << "GLFW end setup" << endl; +// cout << "GLFW end setup" << endl; +// cout << "GLFW TEST " << allMonitors.getRectFromMonitors() << endl; +// allMonitors.getRectFromMonitors({ 0, 1 }); +// allMonitors.getRectFromMonitors({ 0, 2 }); +// allMonitors.getRectFromMonitors({ 0, 1, 2 }); +// allMonitors.getRectFromMonitors({ 0, 3 }); +// allMonitors.getRectFromMonitors({ 1, 2 }); +// allMonitors.getRectFromMonitors({ 1, 3 }); +// allMonitors.getRectFromMonitors({ 2, 3 }); } #ifdef TARGET_LINUX @@ -547,7 +555,7 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { - cout << "setWindowRect " << rect << endl; +// cout << "setWindowRect " << rect << endl; glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -558,7 +566,7 @@ void ofAppGLFWWindow::setWindowPosition(int x, int y) { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowShape(int w, int h) { - cout << "setWindowShape " << w << " : " << h << endl; +// cout << "setWindowShape " << w << " : " << h << endl; glfwSetWindowSize(windowP, w, h); } @@ -591,7 +599,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { if (targetWindowMode == OF_FULLSCREEN) { // save window shape before going fullscreen windowRect = getWindowRect(); - cout << "saving window rect " << windowRect << endl; +// cout << "saving window rect " << windowRect << endl; if (settings.multiMonitorFullScreen) { setWindowRect(allMonitors.getRectForAllMonitors()); @@ -608,7 +616,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { - cout << "setFullScreen " << fullscreen << endl; +// cout << "setFullScreen " << fullscreen << endl; if (fullscreen) { targetWindowMode = OF_FULLSCREEN; } else { @@ -620,21 +628,18 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { #ifdef TARGET_OSX NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); - // This one is to correct if somebody entered fullscreen with green button and is disabling fullscreen - if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { - if (targetWindowMode == OF_WINDOW) { - [cocoaWindow toggleFullScreen:nil]; - settings.windowMode = OF_WINDOW; - } else { - settings.windowMode = OF_FULLSCREEN; - } - } if (targetWindowMode == OF_FULLSCREEN) { [NSApp setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; [cocoaWindow setHasShadow:NO]; } else { + + // to recover correctly from a green button fullscreen + if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { + [cocoaWindow toggleFullScreen:nil]; + } + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; [cocoaWindow setHasShadow:YES]; @@ -793,8 +798,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { XFlush(display); // setWindowShape(windowW, windowH); - - #endif settings.windowMode = targetWindowMode; @@ -1334,24 +1337,6 @@ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { ofAppGLFWWindow * instance = setCurrent(windowP_); -// if (instance->settings.windowMode == OF_WINDOW) { -// instance->windowRect.width = w; -// instance->windowRect.height = h; -// } - // Detect if the window is running in a retina mode - - - // Find scale factor needed to transform from screen coordinates - // to physical pixel coordinates -// instance->pixelScreenCoordScale = (float)framebufferW / (float)windowSize.x; - -// if (instance->settings.windowMode == OF_WINDOW) { -// instance->windowW = framebufferW; -// instance->windowH = framebufferH; -// } - -// instance->currentW = w; -// instance->currentH = h; instance->events().notifyWindowResized(w, h); instance->nFramesSinceWindowResized = 0; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 7858cdd86f5..91d25399e5f 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -175,7 +175,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { // FIXME remove float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH). - ofRectangle windowRect { 20, 20, 1024, 768 }; + ofRectangle windowRect { 20, 20, 800, 600 }; int buttonInUse; bool buttonPressed; @@ -205,7 +205,9 @@ using std::endl; // TEMPORARY #include "GLFW/glfw3.h" - +// TEMP oftostring +#include "ofUtils.h" +#include static struct ofMonitors { public: @@ -249,6 +251,39 @@ static struct ofMonitors { } } + std::vector rectTests { + { 0, 0, 400, 200 }, + { 400, 0, 400, 200 }, + { 800, 0, 400, 200 }, + { 1200, 0, 400, 200 }, + }; + + ofRectangle getRectFromMonitors(const std::vector monitors) { + bool first = true; + ofRectangle r; + std::string str { "" }; + for (auto & i : monitors) { + str += ofToString(i) + " "; + if (i < rectTests.size()) { + if (first) { + first = false; + r = rectTests[i]; + } else { + r = r.getUnion(rectTests[i]); + } + } + } + cout << "getRectFromMonitors " << str << " :: " << r << endl; + return r; + } + + ofRectangle getRectFromMonitorsX() { + ofRectangle r; + ofRectangle r2 { 30, 30, 30, 30 }; + r = r.getUnion(r2); + return r; + } + } allMonitors; // TODO: Remove. diff --git a/tests/io/loadImage/src/main.cpp b/tests/io/loadImage/src/main.cpp index 3abc0f21a56..f30244aabdc 100644 --- a/tests/io/loadImage/src/main.cpp +++ b/tests/io/loadImage/src/main.cpp @@ -9,10 +9,11 @@ class ofApp: public ofxUnitTestsApp{ ofxTest(img.load("indispensable.jpg"), "load from fs"); ofxTest(img.load(ofToDataPath("indispensable.jpg", true)), "load from fs"); ofxTest(img.load("http://openframeworks.cc/about/0.jpg"), "load from http"); - // https://avatars.githubusercontent.com/u/58289?v=4 - // https://avatars.githubusercontent.com/u/144000?v=4 + // https://avatars.githubusercontent.com/u/48240?v=4 //ar + // https://avatars.githubusercontent.com/u/144000?v=4 //th + // https://avatars.githubusercontent.com/u/58289?v=4 //dm // ofxTest(img.load("https://forum.openframeworks.cc/user_avatar/forum.openframeworks.cc/arturo/45/3965_1.png"), "load from https"); - ofxTest(img.load("https://avatars.githubusercontent.com/u/58289?v=4"), "load from https"); + ofxTest(img.load("https://avatars.githubusercontent.com/u/48240?v=4"), "load from https"); } }; From fd7197f1467b8c2b2317765c00144402f6bc6c19 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 17:07:08 -0300 Subject: [PATCH 031/143] vector fix --- libs/openFrameworks/app/ofWindowSettings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index b1133f30c06..36bd96d4584 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -6,6 +6,7 @@ class ofAppBaseWindow; #include "glm/vec2.hpp" #include #include +#include /// \brief Used to represent the available windowing modes for the application. enum ofWindowMode{ From 18a74962ba0a204fb504fa2e526795d332053bdf Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 17:12:53 -0300 Subject: [PATCH 032/143] emscripten ivec2 fix --- addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp | 12 ++++++------ addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index db973562405..92f0b340438 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -483,25 +483,25 @@ void ofxAppEmscriptenWindow::setWindowShape(int w, int h){ } //------------------------------------------------------------ -glm::vec2 ofxAppEmscriptenWindow::getWindowPosition(){ - return glm::vec2(0,0); +glm::ivec2 ofxAppEmscriptenWindow::getWindowPosition(){ + return glm::ivec2(0,0); } //------------------------------------------------------------ -glm::vec2 ofxAppEmscriptenWindow::getWindowSize(){ +glm::ivec2 ofxAppEmscriptenWindow::getWindowSize(){ if(mCurrentWindowMode == OF_GAME_MODE) { double twidth, theight; emscripten_get_element_css_size("canvas", &twidth, &theight); - return glm::vec2((int)twidth,(int)theight); + return glm::ivec2((int)twidth,(int)theight); } int width; int height; emscripten_get_canvas_element_size("canvas", &width, &height); - return glm::vec2(width,height); + return glm::ivec2(width,height); } //------------------------------------------------------------ -glm::vec2 ofxAppEmscriptenWindow::getScreenSize(){ +glm::ivec2 ofxAppEmscriptenWindow::getScreenSize(){ return getWindowSize(); } diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h index 10d8934a23b..813ad3faab2 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.h @@ -36,9 +36,9 @@ class ofxAppEmscriptenWindow: public ofAppBaseWindow { // void setWindowPosition(int x, int y); void setWindowShape(int w, int h); - glm::vec2 getWindowPosition(); - glm::vec2 getWindowSize(); - glm::vec2 getScreenSize(); + glm::ivec2 getWindowPosition(); + glm::ivec2 getWindowSize(); + glm::ivec2 getScreenSize(); ofOrientation getOrientation(); From 86f4879995ad4eabe9d2a426d550f067775e28f0 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 17:23:41 -0300 Subject: [PATCH 033/143] try to fix ios --- addons/ofxiOS/src/app/ofAppiOSWindow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.h b/addons/ofxiOS/src/app/ofAppiOSWindow.h index 934bbcaa457..4b4d5bc5e33 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.h +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.h @@ -35,7 +35,7 @@ #include "ofxiOSConstants.h" #include "ofEvents.h" -class ofiOSWindowSettings: public ofGLESWindowSettings{ +class ofiOSWindowSettings: public ofWindowSettings{ public: ofiOSWindowSettings() :enableRetina(true) @@ -110,7 +110,7 @@ class ofiOSWindowSettings: public ofGLESWindowSettings{ } } - ofiOSWindowSettings(const ofGLESWindowSettings & settings) + ofiOSWindowSettings(const ofWindowSettings & settings) :ofGLESWindowSettings(settings) ,enableRetina(true) ,retinaScale(0) From d0a267222b4bc80a466cb6011a911e1a2dc0c74d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 17 Jan 2024 20:32:19 -0300 Subject: [PATCH 034/143] more --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 10607f0603c..0127c18ee26 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -397,6 +397,11 @@ void ofAppGLFWWindow::update() { cout << "FIRST" << endl; glfwShowWindow(windowP); + + + glm::vec2 contentScale; + glfwGetWindowContentScale(windowP, &contentScale.x, &contentScale.y); + cout << "glfwGetWindowContentScale " << contentScale << endl; bWindowNeedsShowing = false; cout << "FS" << endl; From 3ae86ca23d9663d61294da12db24898fb103d23a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 18 Jan 2024 00:59:32 -0300 Subject: [PATCH 035/143] more changes --- libs/openFrameworks/app/ofAppBaseWindow.h | 10 ------- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 5 ++-- libs/openFrameworks/app/ofAppGLFWWindow.h | 2 -- .../gl/ofGLProgrammableRenderer.cpp | 8 ++++++ .../gl/ofGLProgrammableRenderer.h | 2 ++ .../graphics/ofGraphicsBaseTypes.h | 5 ++++ libs/openFrameworks/utils/ofMatrixStack.cpp | 26 ++++++++++++++++--- libs/openFrameworks/utils/ofMatrixStack.h | 1 + 8 files changed, 42 insertions(+), 17 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 8264ae0cead..0a0b2d8ed87 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -3,7 +3,6 @@ #include "ofWindowSettings.h" // MARK: Target #include "ofConstants.h" -//class ofRectangle; #include "ofRectangle.h" class ofBaseApp; @@ -28,21 +27,12 @@ class ofAppBaseWindow { // virtual ~ofAppBaseWindow(){} ~ofAppBaseWindow(){} -// virtual void setup(const ofWindowSettings & settings); - virtual void setup(const ofWindowSettings & settings)=0; virtual void update()=0; virtual void draw()=0; virtual std::shared_ptr & renderer() = 0; virtual ofCoreEvents & events() = 0; -// virtual void setup(const ofWindowSettings & settings) {}; -// virtual void update() {}; -// virtual void draw() {}; -// virtual std::shared_ptr & renderer() =0; -// virtual ofCoreEvents & events() =0; - - virtual bool getWindowShouldClose(){ return false; } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 0127c18ee26..2f6d6609618 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -234,7 +234,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { // cout << "GLFW Will create windowRect " << windowRect << endl; // MARK: - WINDOW windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); - + cout << windowRect << endl; setWindowRect(windowRect); if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; @@ -430,6 +430,7 @@ void ofAppGLFWWindow::pollEvents() { void ofAppGLFWWindow::draw() { currentRenderer->startRender(); if (bEnableSetupScreen) { +// cout << "ow currentRenderer->setupScreen()" << endl; currentRenderer->setupScreen(); } @@ -560,7 +561,7 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { -// cout << "setWindowRect " << rect << endl; + cout << "setWindowRect " << rect << endl; glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 91d25399e5f..246e766a357 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -286,6 +286,4 @@ static struct ofMonitors { } allMonitors; -// TODO: Remove. -//static bool updatePixelScreenCoordScale = true; //#endif diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp index 07690fcbfe7..f2cf237a088 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp @@ -1597,6 +1597,14 @@ void ofGLProgrammableRenderer::setDefaultUniforms() { //---------------------------------------------------------- void ofGLProgrammableRenderer::beginDefaultShader() { + // piece of code to avoid begin multiple times the same shader +// std::cout << "2 " << std::endl; +// if (ofGetFrameNum() == beginDefaultShaderFrame) { +// return; +// } +// beginDefaultShaderFrame = ofGetFrameNum(); +// +// std::cout << "ofGLProgrammableRenderer::beginDefaultShader() " << ofGetFrameNum() << std::endl; if (usingCustomShader && !currentMaterial && !currentShadow) return; if (currentShadow && bCustomShadowShader) return; diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.h b/libs/openFrameworks/gl/ofGLProgrammableRenderer.h index 1a6b7c1e066..1b456b02610 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.h +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.h @@ -334,4 +334,6 @@ class ofGLProgrammableRenderer: public ofBaseGLRenderer{ std::deque framebufferIdStack; ///< keeps track of currently bound framebuffers GLuint defaultFramebufferId; ///< default GL_FRAMEBUFFER_BINDING, windowing frameworks might want to set this to their MSAA framebuffer, defaults to 0 GLuint currentFramebufferId; ///< the framebuffer id currently bound to the GL_FRAMEBUFFER target + + uint64_t beginDefaultShaderFrame; }; diff --git a/libs/openFrameworks/graphics/ofGraphicsBaseTypes.h b/libs/openFrameworks/graphics/ofGraphicsBaseTypes.h index b3db5b33ece..4252c8d239b 100644 --- a/libs/openFrameworks/graphics/ofGraphicsBaseTypes.h +++ b/libs/openFrameworks/graphics/ofGraphicsBaseTypes.h @@ -189,6 +189,11 @@ class ofBaseDraws { /// /// \return the width. virtual float getWidth() const = 0; + + // TODO: Implement correctly for texture, videos, etc. + virtual glm::vec2 getSize() { + return { getWidth(), getHeight() }; + } /// \brief Set the anchor point the item is drawn around as a percentage. /// diff --git a/libs/openFrameworks/utils/ofMatrixStack.cpp b/libs/openFrameworks/utils/ofMatrixStack.cpp index 43b2eaf0f59..6f779746c3a 100644 --- a/libs/openFrameworks/utils/ofMatrixStack.cpp +++ b/libs/openFrameworks/utils/ofMatrixStack.cpp @@ -18,6 +18,10 @@ using std::swap; using std::make_pair; using std::pair; +// TEMPORARY +using std::cout; +using std::endl; + ofMatrixStack::ofMatrixStack(const ofAppBaseWindow * window) :vFlipped(true) ,orientation(OF_ORIENTATION_DEFAULT) @@ -133,6 +137,17 @@ int ofMatrixStack::getRenderSurfaceHeight() const{ } } +glm::ivec2 ofMatrixStack::getRenderSurfaceSize() const { + if (currentRenderSurface) { + return currentRenderSurface->getSize(); + } else if (currentWindow) { + // FIXME: FramebufferSize + return currentWindow->getWindowSize(); + } else { + return {}; + } +} + ofMatrixMode ofMatrixStack::getCurrentMatrixMode() const{ return currentMatrixMode; } @@ -152,14 +167,19 @@ void ofMatrixStack::viewport(float x, float y, float width, float height, bool v swap(x,y); } + auto xy = getRenderSurfaceSize(); + if(width < 0 || height < 0){ - width = getRenderSurfaceWidth(); - height = getRenderSurfaceHeight(); + width = xy.x; + height = xy.y; +// width = getRenderSurfaceWidth(); +// height = getRenderSurfaceHeight(); vflip = isVFlipped(); } if (vflip){ - y = getRenderSurfaceHeight() - (y + height); +// y = getRenderSurfaceHeight() - (y + height); + y = xy.y - (y + height); } currentViewport.set(x,y,width,height); diff --git a/libs/openFrameworks/utils/ofMatrixStack.h b/libs/openFrameworks/utils/ofMatrixStack.h index 013486e1225..b9fa08a960b 100644 --- a/libs/openFrameworks/utils/ofMatrixStack.h +++ b/libs/openFrameworks/utils/ofMatrixStack.h @@ -107,6 +107,7 @@ class ofMatrixStack { int getRenderSurfaceWidth() const; int getRenderSurfaceHeight() const; + glm::ivec2 getRenderSurfaceSize() const; bool doesHWOrientation() const; inline void updatedRelatedMatrices(); From 2b23530ba30ed9a3f0989d66db92b69d18ccefd6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 18 Jan 2024 13:53:36 -0300 Subject: [PATCH 036/143] crazy changes --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 +- libs/openFrameworks/app/ofAppGLFWWindow.h | 2 ++ libs/openFrameworks/utils/ofTimer.h | 35 ++++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 2f6d6609618..92ef7128d02 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -303,7 +303,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { static_cast(currentRenderer.get())->setup(); } - setVerticalSync(true); +// setVerticalSync(true); glfwSetMouseButtonCallback(windowP, mouse_cb); glfwSetCursorPosCallback(windowP, motion_cb); glfwSetCursorEnterCallback(windowP, entry_cb); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 246e766a357..9bf578efb27 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -21,6 +21,8 @@ class ofPixels_; typedef ofPixels_ ofPixels; +typedef ofWindowSettings ofGLFWWindowSettings; + class ofAppGLFWWindow : public ofAppBaseWindow { public: ofAppGLFWWindow(); diff --git a/libs/openFrameworks/utils/ofTimer.h b/libs/openFrameworks/utils/ofTimer.h index a9492f2c91a..a3e2e6f5a10 100644 --- a/libs/openFrameworks/utils/ofTimer.h +++ b/libs/openFrameworks/utils/ofTimer.h @@ -1,6 +1,39 @@ #pragma once #include "ofUtils.h" +#include +#include +#include +#include + +using namespace std::chrono; +using namespace std::chrono_literals; + +class ofTimerFps { +public: + ofTimerFps(){ + reset(); + }; + + using space = std::chrono::duration; + space interval; + time_point wakeTime; + + // FIXME: double? float? + void setPerSecond(int fps) { + interval = duration_cast(1s) / fps; + } + + void reset() { + wakeTime = steady_clock::now(); + } + + void waitNext(){ + std::this_thread::sleep_until(wakeTime); + wakeTime += interval; + } +}; + class ofTimer { public: @@ -16,8 +49,8 @@ class ofTimer { /// The timer will begin calculating the events beginning the moment /// the function is called. /// \param nanoseconds The number of nanoseconds between events. + void setPeriodicEvent(std::chrono::nanoseconds t); void setPeriodicEvent(uint64_t nanoseconds); - /// \brief Sleep this thread until the next periodic event. void waitNext(); private: From 07ac43c82e008ca50b910c89716dc4c9929b8058 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 19 Jan 2024 12:33:00 -0300 Subject: [PATCH 037/143] updates --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 ++ libs/openFrameworks/events/ofEvents.cpp | 6 ++++-- libs/openFrameworks/events/ofEvents.h | 2 +- libs/openFrameworks/utils/ofTimer.h | 11 ++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 92ef7128d02..ba333dc6c98 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -423,6 +423,7 @@ void ofAppGLFWWindow::update() { //-------------------------------------------- void ofAppGLFWWindow::pollEvents() { +// cout << "pollEvents " << ofGetFrameNum() << endl; glfwPollEvents(); } @@ -465,6 +466,7 @@ void ofAppGLFWWindow::draw() { } if (settings.doubleBuffering) { glfwSwapBuffers(windowP); +// std::cout << "swap buffers " << ofGetFrameNum() << std::endl; } else { glFlush(); } diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index 0518815471d..d46e3b955e8 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -211,8 +211,9 @@ void ofCoreEvents::setFrameRate(int _targetRate) { } else { bFrameRateSet = true; targetRate = _targetRate; - uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate; - timer.setPeriodicEvent(nanosPerFrame); +// uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate; +// timer.setPeriodicEvent(nanosPerFrame); + timer.setFps(targetRate); } } @@ -301,6 +302,7 @@ bool ofCoreEvents::notifyDraw() { auto attended = ofNotifyEvent(draw, voidEventArgs); if (bFrameRateSet) { +// std::cout << "timer wait " << ofGetFrameNum() << std::endl; timer.waitNext(); } diff --git a/libs/openFrameworks/events/ofEvents.h b/libs/openFrameworks/events/ofEvents.h index 88187d095d3..f7fd5d47b54 100644 --- a/libs/openFrameworks/events/ofEvents.h +++ b/libs/openFrameworks/events/ofEvents.h @@ -406,7 +406,7 @@ class ofCoreEvents { private: float targetRate; bool bFrameRateSet; - ofTimer timer; + ofTimerFps timer; ofFpsCounter fps; int currentMouseX, currentMouseY; diff --git a/libs/openFrameworks/utils/ofTimer.h b/libs/openFrameworks/utils/ofTimer.h index a3e2e6f5a10..7b5de50a0d3 100644 --- a/libs/openFrameworks/utils/ofTimer.h +++ b/libs/openFrameworks/utils/ofTimer.h @@ -15,12 +15,14 @@ class ofTimerFps { reset(); }; - using space = std::chrono::duration; +// using space = std::chrono::duration; + using space = std::chrono::duration; space interval; time_point wakeTime; - + time_point lastWakeTime; + // FIXME: double? float? - void setPerSecond(int fps) { + void setFps(int fps) { interval = duration_cast(1s) / fps; } @@ -30,6 +32,9 @@ class ofTimerFps { void waitNext(){ std::this_thread::sleep_until(wakeTime); + std::cout << "ellapsed:" << duration_cast(steady_clock::now() - lastWakeTime).count() << std::endl; + std::cout << "will sleep:" << duration_cast(wakeTime - steady_clock::now()).count() << std::endl; + lastWakeTime = wakeTime; wakeTime += interval; } }; From d7ed5ffea81b0f7f3423483da23cca504443c020 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 22 Jan 2024 20:56:23 -0300 Subject: [PATCH 038/143] yess wkkrnnnggg --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 58 +++++++++++++++++---- libs/openFrameworks/app/ofAppGLFWWindow.h | 1 + libs/openFrameworks/app/ofWindowSettings.h | 1 + libs/openFrameworks/events/ofEvents.cpp | 6 +-- libs/openFrameworks/events/ofEvents.h | 3 +- libs/openFrameworks/utils/ofTimer.h | 4 +- 6 files changed, 58 insertions(+), 15 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index ba333dc6c98..31ec3467585 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -134,6 +134,10 @@ void ofAppGLFWWindow::setStencilBits(int stencil) { //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { + + + + if (windowP) { ofLogError() << "window already setup, probably you are mixing old and new style setup"; ofLogError() << "call only ofCreateWindow(settings) or ofSetupOpenGL(...)"; @@ -142,6 +146,20 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } settings = _settings; + +// if (_settings.windowMode == OF_WINDOW) { +// cout << "_settings.windowMode OF_WINDOW" << endl; +// } else if (_settings.windowMode == OF_FULLSCREEN) { +// cout << "_settings.windowMode OF_FULLSCREEN" << endl; +// } +// +// +// if (settings.windowMode == OF_WINDOW) { +// cout << "settings.windowMode OF_WINDOW" << endl; +// } else if (settings.windowMode == OF_FULLSCREEN) { +// cout << "settings.windowMode OF_FULLSCREEN" << endl; +// } + if (!glfwInit()) { ofLogError("ofAppGLFWWindow") << "couldn't init GLFW"; @@ -209,8 +227,10 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { windowRect.setPosition(settings.getPosition().x, settings.getPosition().y); windowRect.width = settings.getWidth(); windowRect.height = settings.getHeight(); + GLFWmonitor *monitor = nullptr; + // FIXME: maybe use as a global variable for the window? int monitorIndex = 0; // Check to see if desired monitor is connected. if (allMonitors.rects.size() > settings.monitor) { @@ -223,19 +243,34 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { windowRect = allMonitors.rects[monitorIndex]; monitor = allMonitors.monitors[monitorIndex]; } - else if (settings.windowMode == OF_WINDOW) { + else if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { // cout << "rects size " << allMonitors.rects.size() << endl; // cout << "window mode monitorindex = " << monitorIndex << endl; // cout << "settings.monitor = " << settings.monitor << endl; + + cout << settings.windowName << " windowRect before " << windowRect << endl; windowRect.x += allMonitors.rects[monitorIndex].x; windowRect.y += allMonitors.rects[monitorIndex].y; + // OK, this is just so isPositionSet is ok in next few lines. + // FIXME: there is a problem here, position will be zeroed if setposition is called before window creation. + { + settings.setPosition({windowRect.x, windowRect.y}); + } + cout << settings.windowName << " windowRect after " << windowRect << endl; } // cout << "GLFW Will create windowRect " << windowRect << endl; // MARK: - WINDOW windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); - cout << windowRect << endl; - setWindowRect(windowRect); + + cout << "GLFW windowRect " << windowRect << " : " << settings.windowName << endl; + + if (settings.isPositionSet()) { + setWindowRect(windowRect); + } else { + setWindowShape(windowRect.width, windowRect.height); + } + if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; @@ -405,7 +440,6 @@ void ofAppGLFWWindow::update() { bWindowNeedsShowing = false; cout << "FS" << endl; - if (settings.windowMode == OF_FULLSCREEN) { // Meant to trigger fullscreen forced settings.windowMode = OF_WINDOWMODE_UNDEFINED; @@ -563,7 +597,8 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { - cout << "setWindowRect " << rect << endl; + cout << settings.windowName << " setWindowRect " << rect << endl; + glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -1349,11 +1384,14 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { instance->nFramesSinceWindowResized = 0; #if defined(TARGET_OSX) - NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP_); - if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { - instance->settings.windowMode = OF_FULLSCREEN; - } else { - instance->settings.windowMode = OF_WINDOW; + if (!instance->bWindowNeedsShowing) { +// FIXME - only after first update + NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP_); + if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { + instance->settings.windowMode = OF_FULLSCREEN; + } else { + instance->settings.windowMode = OF_WINDOW; + } } #endif } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 9bf578efb27..b9d00531f84 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -195,6 +195,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #endif // TARGET_WIN32 void setFSTarget(ofWindowMode targetWindowMode); + }; diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index 36bd96d4584..6700c41895b 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -47,6 +47,7 @@ class ofWindowSettings { virtual ~ofWindowSettings(){}; std::string title; + std::string windowName { "main" }; ofWindowMode windowMode = OF_WINDOW; // void setRect(const ofRectangle & rect) { diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index d46e3b955e8..52ffcd44830 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -211,9 +211,9 @@ void ofCoreEvents::setFrameRate(int _targetRate) { } else { bFrameRateSet = true; targetRate = _targetRate; -// uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate; -// timer.setPeriodicEvent(nanosPerFrame); - timer.setFps(targetRate); + uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate; + timer.setPeriodicEvent(nanosPerFrame); +// timer.setFps(targetRate); } } diff --git a/libs/openFrameworks/events/ofEvents.h b/libs/openFrameworks/events/ofEvents.h index f7fd5d47b54..98d3b50f0cb 100644 --- a/libs/openFrameworks/events/ofEvents.h +++ b/libs/openFrameworks/events/ofEvents.h @@ -406,7 +406,8 @@ class ofCoreEvents { private: float targetRate; bool bFrameRateSet; - ofTimerFps timer; +// ofTimerFps timer; + ofTimer timer; ofFpsCounter fps; int currentMouseX, currentMouseY; diff --git a/libs/openFrameworks/utils/ofTimer.h b/libs/openFrameworks/utils/ofTimer.h index 7b5de50a0d3..0ed610b8fa5 100644 --- a/libs/openFrameworks/utils/ofTimer.h +++ b/libs/openFrameworks/utils/ofTimer.h @@ -31,9 +31,11 @@ class ofTimerFps { } void waitNext(){ - std::this_thread::sleep_until(wakeTime); + std::cout << "interval:" << duration_cast(wakeTime - lastWakeTime).count() << std::endl; std::cout << "ellapsed:" << duration_cast(steady_clock::now() - lastWakeTime).count() << std::endl; std::cout << "will sleep:" << duration_cast(wakeTime - steady_clock::now()).count() << std::endl; + std::cout << "----" << std::endl; + std::this_thread::sleep_until(wakeTime); lastWakeTime = wakeTime; wakeTime += interval; } From a454746d2d90aba4705d86f755e03f105c6fe481 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 23 Jan 2024 12:49:23 -0300 Subject: [PATCH 039/143] update fs code for windows --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 72 ++++++++++----------- libs/openFrameworks/app/ofAppGLFWWindow.h | 1 + 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 31ec3467585..1b9ba7e683c 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -222,11 +222,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { - // TODO: move up, outside windowmode - // HACK: asdf - windowRect.setPosition(settings.getPosition().x, settings.getPosition().y); - windowRect.width = settings.getWidth(); - windowRect.height = settings.getHeight(); GLFWmonitor *monitor = nullptr; @@ -239,35 +234,48 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError("ofAppGLFWWindow") << "requested monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); } - if (settings.windowMode == OF_GAME_MODE) { + + if (settings.windowMode == OF_GAME_MODE) + { windowRect = allMonitors.rects[monitorIndex]; monitor = allMonitors.monitors[monitorIndex]; } - else if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { + +// cout << "GLFW Will create windowRect " << windowRect << endl; + // MARK: - WINDOW + + glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); + windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); + windowRect = getWindowRect(); +// windowRect = + if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { // cout << "rects size " << allMonitors.rects.size() << endl; // cout << "window mode monitorindex = " << monitorIndex << endl; // cout << "settings.monitor = " << settings.monitor << endl; - cout << settings.windowName << " windowRect before " << windowRect << endl; - windowRect.x += allMonitors.rects[monitorIndex].x; - windowRect.y += allMonitors.rects[monitorIndex].y; +// cout << settings.windowName << " windowRect before " << windowRect << endl; + if (monitorIndex > 0) { + windowRect.x += allMonitors.rects[monitorIndex].x; + windowRect.y += allMonitors.rects[monitorIndex].y; + setWindowRect(windowRect); + } // OK, this is just so isPositionSet is ok in next few lines. // FIXME: there is a problem here, position will be zeroed if setposition is called before window creation. - { - settings.setPosition({windowRect.x, windowRect.y}); - } - cout << settings.windowName << " windowRect after " << windowRect << endl; +// { +// settings.setPosition({windowRect.x, windowRect.y}); +// } +// cout << settings.windowName << " windowRect after " << windowRect << endl; } -// cout << "GLFW Will create windowRect " << windowRect << endl; - // MARK: - WINDOW - windowP = glfwCreateWindow(windowRect.width, windowRect.height, settings.title.c_str(), monitor, sharedContext); + cout << "GLFW windowRect " << windowRect << " : " << settings.windowName << endl; if (settings.isPositionSet()) { + cout << "GLFW isPosition set true : " << settings.windowName << endl; setWindowRect(windowRect); } else { + cout << "GLFW isPosition set false : " << settings.windowName << endl; setWindowShape(windowRect.width, windowRect.height); } @@ -419,10 +427,8 @@ shared_ptr & ofAppGLFWWindow::renderer() { //-------------------------------------------- void ofAppGLFWWindow::update() { events().notifyUpdate(); - //show the window right before the first draw call. if (bWindowNeedsShowing && windowP) { - // not working. #ifdef TARGET_OSX NSWindow * cocoaWindow = glfwGetCocoaWindow(windowP); @@ -430,16 +436,8 @@ void ofAppGLFWWindow::update() { [cocoaWindow orderFrontRegardless]; #endif - cout << "FIRST" << endl; - glfwShowWindow(windowP); - - - glm::vec2 contentScale; - glfwGetWindowContentScale(windowP, &contentScale.x, &contentScale.y); - cout << "glfwGetWindowContentScale " << contentScale << endl; bWindowNeedsShowing = false; - cout << "FS" << endl; if (settings.windowMode == OF_FULLSCREEN) { // Meant to trigger fullscreen forced settings.windowMode = OF_WINDOWMODE_UNDEFINED; @@ -447,12 +445,9 @@ void ofAppGLFWWindow::update() { } else { setFullscreen(false); } - cout << "AFTER" << endl; -// if (targetWindowMode == OF_FULLSCREEN) { -// setFullscreen(true); -// } - } + glfwShowWindow(windowP); + } } //-------------------------------------------- @@ -645,10 +640,11 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { // cout << "saving window rect " << windowRect << endl; if (settings.multiMonitorFullScreen) { - setWindowRect(allMonitors.getRectForAllMonitors()); + windowRectFS = allMonitors.getRectForAllMonitors(); } else { - setWindowRect(allMonitors.getRectMonitorForScreenRect(windowRect)); + windowRectFS = allMonitors.getRectMonitorForScreenRect(windowRect); } + setWindowRect(windowRectFS); } else if (targetWindowMode == OF_WINDOW) { @@ -677,7 +673,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; [cocoaWindow setHasShadow:NO]; } else { - // to recover correctly from a green button fullscreen if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { [cocoaWindow toggleFullScreen:nil]; @@ -687,7 +682,6 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; [cocoaWindow setHasShadow:YES]; } - setFSTarget(targetWindowMode); //---------------------------------------------------- @@ -698,6 +692,8 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { HWND hwnd = glfwGetWin32Window(windowP); + setFSTarget(targetWindowMode); + if (targetWindowMode == OF_FULLSCREEN) { SetWindowLong(hwnd, GWL_EXSTYLE, 0); SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); @@ -724,7 +720,8 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // setWindowShape(windowRect.width + 4, windowRect.height + 4); } - SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); +// SetWindowPos(hwnd, HWND_TOPMOST, xpos, ypos, fullscreenW, fullscreenH, SWP_SHOWWINDOW); + SetWindowPos(hwnd, HWND_TOPMOST, windowRectFS.x, windowRectFS.y, windowRectFS.width, windowRectFS.height, SWP_SHOWWINDOW); #elif defined(TARGET_LINUX) @@ -858,6 +855,7 @@ void ofAppGLFWWindow::toggleFullscreen() { } //------------------------------------------------------------ +// FIXME: this can be up on base class. it is not GLFW exclusive static void rotateMouseXY(ofOrientation orientation, int w, int h, double & x, double & y) { int savedY; switch (orientation) { diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index b9d00531f84..0f4b031fa0d 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -178,6 +178,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH). ofRectangle windowRect { 20, 20, 800, 600 }; + ofRectangle windowRectFS { 0, 0, 1920, 1080 }; int buttonInUse; bool buttonPressed; From db5a9fd0d7d99a60988efacbb3a6fe0eaec45625 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 23 Jan 2024 13:51:54 -0300 Subject: [PATCH 040/143] egl --- libs/openFrameworks/app/ofAppEGLWindow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index 819246203a7..46347d5f6a7 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -51,7 +51,7 @@ struct ofAppEGLWindowSettings: public ofGLESWindowSettings { ofAppEGLWindowSettings(const ofGLESWindowSettings & settings); }; -class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { +class ofAppEGLWindow : public ofAppBaseWindow, public ofThread { public: /// ofAppEGLWindow::Settings is currently deprecated in favor of @@ -67,7 +67,7 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { static bool needsPolling(){ return true; } static void pollEvents(); - using ofAppBaseGLESWindow::setup; +// using ofAppBaseWindow::setup; void setup(const ofAppEGLWindowSettings & settings); void setup(const ofGLESWindowSettings & settings); From 6fbcf17f30cab62060253700918366d32e79fdf1 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 23 Jan 2024 23:08:26 -0300 Subject: [PATCH 041/143] try ios --- addons/ofxiOS/src/app/ofAppiOSWindow.h | 66 +++++++++++++------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.h b/addons/ofxiOS/src/app/ofAppiOSWindow.h index 4b4d5bc5e33..87bbd597ce3 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.h +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.h @@ -110,39 +110,39 @@ class ofiOSWindowSettings: public ofWindowSettings{ } } - ofiOSWindowSettings(const ofWindowSettings & settings) - :ofGLESWindowSettings(settings) - ,enableRetina(true) - ,retinaScale(0) - ,enableDepth(false) - ,enableAntiAliasing(false) - ,numOfAntiAliasingSamples(0) - ,enableHardwareOrientation(false) - ,enableHardwareOrientationAnimation(false) - ,enableSetupScreen(true) - ,windowControllerType(ofxiOSWindowControllerType::CORE_ANIMATION) - ,colorType(ofxiOSRendererColorFormat::RGBA8888) - ,depthType(ofxiOSRendererDepthFormat::DEPTH_NONE) - ,stencilType(ofxiOSRendererStencilFormat::STENCIL_NONE) - ,enableMultiTouch(false){ - const ofiOSWindowSettings * iosSettings = dynamic_cast(&settings); - if(iosSettings){ - enableRetina = iosSettings->enableRetina; - retinaScale = iosSettings->retinaScale; - enableDepth = iosSettings->enableDepth; - enableAntiAliasing = iosSettings->enableAntiAliasing; - numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples; - enableHardwareOrientation = iosSettings->enableHardwareOrientation; - enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation; - enableSetupScreen = iosSettings->enableSetupScreen; - setupOrientation = iosSettings->setupOrientation; - windowControllerType = iosSettings->windowControllerType; - colorType = iosSettings->colorType; - depthType = iosSettings->depthType; - stencilType = iosSettings->stencilType; - enableMultiTouch = iosSettings->enableMultiTouch; - } - } + // ofiOSWindowSettings(const ofWindowSettings & settings) + // :ofGLESWindowSettings(settings) + // ,enableRetina(true) + // ,retinaScale(0) + // ,enableDepth(false) + // ,enableAntiAliasing(false) + // ,numOfAntiAliasingSamples(0) + // ,enableHardwareOrientation(false) + // ,enableHardwareOrientationAnimation(false) + // ,enableSetupScreen(true) + // ,windowControllerType(ofxiOSWindowControllerType::CORE_ANIMATION) + // ,colorType(ofxiOSRendererColorFormat::RGBA8888) + // ,depthType(ofxiOSRendererDepthFormat::DEPTH_NONE) + // ,stencilType(ofxiOSRendererStencilFormat::STENCIL_NONE) + // ,enableMultiTouch(false){ + // const ofiOSWindowSettings * iosSettings = dynamic_cast(&settings); + // if(iosSettings){ + // enableRetina = iosSettings->enableRetina; + // retinaScale = iosSettings->retinaScale; + // enableDepth = iosSettings->enableDepth; + // enableAntiAliasing = iosSettings->enableAntiAliasing; + // numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples; + // enableHardwareOrientation = iosSettings->enableHardwareOrientation; + // enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation; + // enableSetupScreen = iosSettings->enableSetupScreen; + // setupOrientation = iosSettings->setupOrientation; + // windowControllerType = iosSettings->windowControllerType; + // colorType = iosSettings->colorType; + // depthType = iosSettings->depthType; + // stencilType = iosSettings->stencilType; + // enableMultiTouch = iosSettings->enableMultiTouch; + // } + // } virtual ~ofiOSWindowSettings(){}; From e2049d2def7a130cf856cc402f84d409c298ba7d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 23 Jan 2024 23:12:06 -0300 Subject: [PATCH 042/143] egl fix? --- libs/openFrameworks/app/ofAppEGLWindow.cpp | 2 +- libs/openFrameworks/app/ofAppEGLWindow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppEGLWindow.cpp b/libs/openFrameworks/app/ofAppEGLWindow.cpp index f4dcfd232eb..573e8b42ea7 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.cpp +++ b/libs/openFrameworks/app/ofAppEGLWindow.cpp @@ -917,7 +917,7 @@ void ofAppEGLWindow::destroyNativeEvents() { } //------------------------------------------------------------ -void ofAppEGLWindow::setWindowRect(const ofRectangle& requestedWindowRect) { +void ofAppEGLWindow::setWindowRect(const ofRectangle & requestedWindowRect) { if(!isWindowInited) { ofLogError("ofAppEGLWindow") << "setWindowRect(): window not inited"; return; diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index 46347d5f6a7..96e7162f529 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -127,7 +127,7 @@ class ofAppEGLWindow : public ofAppBaseWindow, public ofThread { protected: - void setWindowRect(const ofRectangle & requestedWindowRect); +// void setWindowRect(const ofRectangle & requestedWindowRect); ofRectangle getScreenRect(); From 6b5b16902a9d33a170fd4dd86d06f7bd2b9dcd3b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 23 Jan 2024 23:17:47 -0300 Subject: [PATCH 043/143] ios --- addons/ofxiOS/src/app/ofAppiOSWindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.h b/addons/ofxiOS/src/app/ofAppiOSWindow.h index 87bbd597ce3..ca1c3c5ec73 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.h +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.h @@ -164,7 +164,7 @@ class ofiOSWindowSettings: public ofWindowSettings{ }; -class ofAppiOSWindow : public ofAppBaseGLESWindow { +class ofAppiOSWindow : public ofAppBaseWindow { public: static ofAppiOSWindow * getInstance(); From 72ec1cc59e3cee5ec0712abf0562093f7e439bfb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 00:18:35 -0300 Subject: [PATCH 044/143] linux arm 6l --- libs/openFrameworks/app/ofMainLoop.cpp | 8 ++++---- libs/openFrameworks/gl/ofGLUtils.h | 1 - libs/openFrameworks/gl/ofTexture.h | 1 - libs/openFrameworks/graphics/ofImage.h | 2 +- libs/openFrameworks/video/ofDirectShowPlayer.h | 1 - 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 7b871d49773..b74ba38f589 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -19,8 +19,8 @@ #include "ofAppAndroidWindow.h" #include "ofxAndroidUtils.h" #include "ofxAndroidApp.h" -#elif defined(TARGET_RASPBERRY_PI) - #include "ofAppEGLWindow.h" +//#elif defined(TARGET_RASPBERRY_PI) +// #include "ofAppEGLWindow.h" #elif defined(TARGET_EMSCRIPTEN) #include "ofxAppEmscriptenWindow.h" #else @@ -49,8 +49,8 @@ std::shared_ptr ofMainLoop::createWindow(const ofWindowSettings std::shared_ptr window = std::make_shared(); #elif (defined(TARGET_RASPBERRY_PI) && defined(TARGET_GLFW_WINDOW)) std::shared_ptr window = std::make_shared(); - #elif defined(TARGET_RASPBERRY_PI) - std::shared_ptr window = std::make_shared(); +// #elif defined(TARGET_RASPBERRY_PI) +// std::shared_ptr window = std::make_shared(); #elif defined(TARGET_EMSCRIPTEN) std::shared_ptr window = std::make_shared(); #elif defined(TARGET_OPENGLES) diff --git a/libs/openFrameworks/gl/ofGLUtils.h b/libs/openFrameworks/gl/ofGLUtils.h index 5b4aa5ba85d..a9882649c6f 100644 --- a/libs/openFrameworks/gl/ofGLUtils.h +++ b/libs/openFrameworks/gl/ofGLUtils.h @@ -18,7 +18,6 @@ class ofTexture; template class ofPixels_; - typedef ofPixels_ ofPixels; typedef ofPixels_ ofFloatPixels; typedef ofPixels_ ofShortPixels; diff --git a/libs/openFrameworks/gl/ofTexture.h b/libs/openFrameworks/gl/ofTexture.h index 85200e5b70b..6bb1ba0c072 100644 --- a/libs/openFrameworks/gl/ofTexture.h +++ b/libs/openFrameworks/gl/ofTexture.h @@ -9,7 +9,6 @@ class ofRectangle; template class ofPixels_; - typedef ofPixels_ ofPixels; typedef ofPixels_ ofShortPixels; typedef ofPixels_ ofFloatPixels; diff --git a/libs/openFrameworks/graphics/ofImage.h b/libs/openFrameworks/graphics/ofImage.h index 44eb8642ff4..7a98e0c1568 100644 --- a/libs/openFrameworks/graphics/ofImage.h +++ b/libs/openFrameworks/graphics/ofImage.h @@ -651,7 +651,7 @@ class ofImage_ : public ofBaseImage_{ void resizePixels(ofPixels_ &pix, int newWidth, int newHeight); void unloadTexture(); - ofPixels_ pixels; + ofPixels_ pixels; bool bUseTexture; ofTexture tex; diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.h b/libs/openFrameworks/video/ofDirectShowPlayer.h index 427d14ba0d5..c404fd11948 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.h +++ b/libs/openFrameworks/video/ofDirectShowPlayer.h @@ -8,7 +8,6 @@ template class ofPixels_; - typedef ofPixels_ ofPixels; class DirectShowVideo; From 26536b85296181f34137332ea302762e1c106864 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 00:51:14 -0300 Subject: [PATCH 045/143] settings.fullscreenDisplays = { 0, 1, 2 } --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 7 ++++++- libs/openFrameworks/app/ofAppGLFWWindow.h | 18 +++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 1b9ba7e683c..d74671e7821 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -376,7 +376,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { #endif // cout << "GLFW end setup" << endl; -// cout << "GLFW TEST " << allMonitors.getRectFromMonitors() << endl; +// cout << "GLFW TEST allMonitors.getRectFromMonitors()" << endl; // allMonitors.getRectFromMonitors({ 0, 1 }); // allMonitors.getRectFromMonitors({ 0, 2 }); // allMonitors.getRectFromMonitors({ 0, 1, 2 }); @@ -644,6 +644,11 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { } else { windowRectFS = allMonitors.getRectMonitorForScreenRect(windowRect); } + + // + if (settings.fullscreenDisplays.size()) { + windowRectFS = allMonitors.getRectFromMonitors(settings.fullscreenDisplays); + } setWindowRect(windowRectFS); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 0f4b031fa0d..52ba0ce5d3d 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -255,12 +255,12 @@ static struct ofMonitors { } } - std::vector rectTests { - { 0, 0, 400, 200 }, - { 400, 0, 400, 200 }, - { 800, 0, 400, 200 }, - { 1200, 0, 400, 200 }, - }; +// std::vector rectTests { +// { 0, 0, 400, 200 }, +// { 400, 0, 400, 200 }, +// { 800, 0, 400, 200 }, +// { 1200, 0, 400, 200 }, +// }; ofRectangle getRectFromMonitors(const std::vector monitors) { bool first = true; @@ -268,12 +268,12 @@ static struct ofMonitors { std::string str { "" }; for (auto & i : monitors) { str += ofToString(i) + " "; - if (i < rectTests.size()) { + if (i < rects.size()) { if (first) { first = false; - r = rectTests[i]; + r = rects[i]; } else { - r = r.getUnion(rectTests[i]); + r = r.getUnion(rects[i]); } } } From e29e7714e840902760ab44d59efe4db81990d86a Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 01:12:36 -0300 Subject: [PATCH 046/143] more --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 18 ++++-------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 9 +-------- libs/openFrameworks/app/ofAppRunner.cpp | 2 ++ 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index d74671e7821..0a42fc5fd11 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -269,13 +269,13 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { - cout << "GLFW windowRect " << windowRect << " : " << settings.windowName << endl; +// cout << "GLFW windowRect " << windowRect << " : " << settings.windowName << endl; if (settings.isPositionSet()) { - cout << "GLFW isPosition set true : " << settings.windowName << endl; +// cout << "GLFW isPosition set true : " << settings.windowName << endl; setWindowRect(windowRect); } else { - cout << "GLFW isPosition set false : " << settings.windowName << endl; +// cout << "GLFW isPosition set false : " << settings.windowName << endl; setWindowShape(windowRect.width, windowRect.height); } @@ -374,16 +374,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { XNFocusWindow, getX11Window(), NULL); #endif - -// cout << "GLFW end setup" << endl; -// cout << "GLFW TEST allMonitors.getRectFromMonitors()" << endl; -// allMonitors.getRectFromMonitors({ 0, 1 }); -// allMonitors.getRectFromMonitors({ 0, 2 }); -// allMonitors.getRectFromMonitors({ 0, 1, 2 }); -// allMonitors.getRectFromMonitors({ 0, 3 }); -// allMonitors.getRectFromMonitors({ 1, 2 }); -// allMonitors.getRectFromMonitors({ 1, 3 }); -// allMonitors.getRectFromMonitors({ 2, 3 }); + } #ifdef TARGET_LINUX @@ -593,7 +584,6 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { cout << settings.windowName << " setWindowRect " << rect << endl; - glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 52ba0ce5d3d..c58c2adf2fc 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -255,13 +255,6 @@ static struct ofMonitors { } } -// std::vector rectTests { -// { 0, 0, 400, 200 }, -// { 400, 0, 400, 200 }, -// { 800, 0, 400, 200 }, -// { 1200, 0, 400, 200 }, -// }; - ofRectangle getRectFromMonitors(const std::vector monitors) { bool first = true; ofRectangle r; @@ -277,7 +270,7 @@ static struct ofMonitors { } } } - cout << "getRectFromMonitors " << str << " :: " << r << endl; +// cout << "getRectFromMonitors " << str << " :: " << r << endl; return r; } diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index d111a687253..36a36d56b3a 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -107,6 +107,8 @@ void ofInit(){ if(initialized()) return; initialized() = true; exiting() = false; + + std::cout << "ofInit() " << std::endl; #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) // manage own exit From c13616d7a26115b4d961889b0d20fd39f6866d07 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 01:37:05 -0300 Subject: [PATCH 047/143] make shared initializers --- libs/openFrameworks/app/ofMainLoop.cpp | 20 ++++++++++---------- libs/openFrameworks/gl/ofMaterial.cpp | 4 ++-- libs/openFrameworks/utils/ofXml.cpp | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index b74ba38f589..6320088a236 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -41,22 +41,22 @@ ofMainLoop::~ofMainLoop() { std::shared_ptr ofMainLoop::createWindow(const ofWindowSettings & settings){ #ifdef TARGET_NODISPLAY - shared_ptr window = std::make_shared(); + shared_ptr window { std::make_shared() }; #else - #if defined(TARGET_OF_IOS) - std::shared_ptr window = std::make_shared(); - #elif defined(TARGET_ANDROID) - std::shared_ptr window = std::make_shared(); +#if defined(TARGET_OF_IOS) + std::shared_ptr window { std::make_shared() }; +#elif defined(TARGET_ANDROID) + std::shared_ptr window { std::make_shared() }; #elif (defined(TARGET_RASPBERRY_PI) && defined(TARGET_GLFW_WINDOW)) - std::shared_ptr window = std::make_shared(); + std::shared_ptr window { std::make_shared() }; // #elif defined(TARGET_RASPBERRY_PI) -// std::shared_ptr window = std::make_shared(); +// std::shared_ptr window { std::make_shared() }; #elif defined(TARGET_EMSCRIPTEN) - std::shared_ptr window = std::make_shared(); + std::shared_ptr window { std::make_shared() }; #elif defined(TARGET_OPENGLES) - std::shared_ptr window = std::make_shared(); + std::shared_ptr window { std::make_shared() }; #else - std::shared_ptr window = std::make_shared(); + std::shared_ptr window { std::make_shared() }; #endif #endif addWindow(window); diff --git a/libs/openFrameworks/gl/ofMaterial.cpp b/libs/openFrameworks/gl/ofMaterial.cpp index 3af75f99612..b3cd631c153 100644 --- a/libs/openFrameworks/gl/ofMaterial.cpp +++ b/libs/openFrameworks/gl/ofMaterial.cpp @@ -285,7 +285,7 @@ bool ofMaterial::loadTexture( const ofMaterialTextureType& aMaterialTextureType, bool bWasUsingArb = ofGetUsingArbTex(); bTex2d ? ofDisableArbTex() : ofEnableArbTex(); - auto tex = std::make_shared(); + auto tex { std::make_shared() }; bool bLoadOk = ofLoadImage(*tex, apath, mirrorY ); if( bLoadOk ) { @@ -805,7 +805,7 @@ const ofShader& ofMaterial::getShadowDepthShader( const ofShadow& ashadow, ofGLP auto shadowShader = mDepthShaders[&renderer]->shaders.find(shadowShaderId); if(shadowShader == mDepthShaders[&renderer]->shaders.end() || !mDepthShaders[&renderer]->shaders[shadowShaderId] ) { - auto nDepthShader = std::make_shared(); + auto nDepthShader { std::make_shared() }; auto customUniforms = data.customUniforms; for( auto & custom : mCustomUniforms ){ diff --git a/libs/openFrameworks/utils/ofXml.cpp b/libs/openFrameworks/utils/ofXml.cpp index fa6b32c290a..678a9b88291 100644 --- a/libs/openFrameworks/utils/ofXml.cpp +++ b/libs/openFrameworks/utils/ofXml.cpp @@ -16,7 +16,7 @@ ofXml::ofXml(std::shared_ptr doc, const pugi::xml_node & xml } bool ofXml::load(const of::filesystem::path & file){ - auto auxDoc = std::make_shared(); + auto auxDoc { std::make_shared() }; auto res = auxDoc->load_file(ofToDataPathFS(file).c_str()); if( res ){ doc = auxDoc; @@ -33,7 +33,7 @@ bool ofXml::load(const ofBuffer & buffer){ } bool ofXml::parse(const std::string & xmlStr){ - auto auxDoc = std::make_shared(); + auto auxDoc { std::make_shared() }; #if ( defined(PUGIXML_VERSION) && PUGIXML_VERSION >= 150 ) if(auxDoc->load_string(xmlStr.c_str())){ #else From 4e257c51acecd08d250064c6895eb59b58308fd5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 14:41:47 -0300 Subject: [PATCH 048/143] cleanup --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 22 +--------------- libs/openFrameworks/app/ofAppGLFWWindow.h | 29 +++++++-------------- 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 0a42fc5fd11..c5cc68419c2 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -38,10 +38,8 @@ using std::vector; using std::cout; using std::endl; - //------------------------------------------------------- -ofAppGLFWWindow::ofAppGLFWWindow() - : coreEvents(new ofCoreEvents) { +ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ bEnableSetupScreen = true; buttonInUse = 0; buttonPressed = false; @@ -134,10 +132,6 @@ void ofAppGLFWWindow::setStencilBits(int stencil) { //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { - - - - if (windowP) { ofLogError() << "window already setup, probably you are mixing old and new style setup"; ofLogError() << "call only ofCreateWindow(settings) or ofSetupOpenGL(...)"; @@ -147,20 +141,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { settings = _settings; -// if (_settings.windowMode == OF_WINDOW) { -// cout << "_settings.windowMode OF_WINDOW" << endl; -// } else if (_settings.windowMode == OF_FULLSCREEN) { -// cout << "_settings.windowMode OF_FULLSCREEN" << endl; -// } -// -// -// if (settings.windowMode == OF_WINDOW) { -// cout << "settings.windowMode OF_WINDOW" << endl; -// } else if (settings.windowMode == OF_FULLSCREEN) { -// cout << "settings.windowMode OF_FULLSCREEN" << endl; -// } - - if (!glfwInit()) { ofLogError("ofAppGLFWWindow") << "couldn't init GLFW"; return; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index c58c2adf2fc..3531a279055 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -1,15 +1,14 @@ #pragma once #include "ofAppBaseWindow.h" -// MARK: Optimize to Pointer #include "ofRectangle.h" // MARK: Target #include "ofConstants.h" -#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) -typedef struct _XIM * XIM; -typedef struct _XIC * XIC; -#endif +//#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) +//typedef struct _XIM * XIM; +//typedef struct _XIC * XIC; +//#endif class ofBaseApp; struct GLFWwindow; @@ -20,7 +19,6 @@ template class ofPixels_; typedef ofPixels_ ofPixels; - typedef ofWindowSettings ofGLFWWindowSettings; class ofAppGLFWWindow : public ofAppBaseWindow { @@ -174,11 +172,13 @@ class ofAppGLFWWindow : public ofAppBaseWindow { ofWindowMode targetWindowMode; bool bEnableSetupScreen; + // FIXME remove float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH). ofRectangle windowRect { 20, 20, 800, 600 }; ofRectangle windowRectFS { 0, 0, 1920, 1080 }; + void setFSTarget(ofWindowMode targetWindowMode); int buttonInUse; bool buttonPressed; @@ -191,22 +191,15 @@ class ofAppGLFWWindow : public ofAppBaseWindow { bool iconSet; -#ifdef TARGET_WIN32 - LONG lExStyle, lStyle; -#endif // TARGET_WIN32 +//#ifdef TARGET_WIN32 +// LONG lExStyle, lStyle; +//#endif // TARGET_WIN32 - void setFSTarget(ofWindowMode targetWindowMode); }; - - - -using std::cout; -using std::endl; - // TEMPORARY #include "GLFW/glfw3.h" // TEMP oftostring @@ -219,8 +212,6 @@ static struct ofMonitors { ~ofMonitors() {} std::vector rects; ofRectangle allMonitorsRect { 0, 0, 0, 0 }; -// ofRectangle rectWindow; -// bool changed = true; GLFWmonitor** monitors; ofRectangle getRectMonitorForScreenRect(const ofRectangle & rect) { @@ -240,7 +231,7 @@ static struct ofMonitors { void update() { rects.clear(); - allMonitorsRect = { 0, 0, 0, 0 }; // reset ofRectangle; + allMonitorsRect = { 0, 0, 0, 0 }; int numberOfMonitors; monitors = glfwGetMonitors(&numberOfMonitors); From 7a61ff6911f197bb5fc9fd62c384ffdd46b82ec0 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 14:50:32 -0300 Subject: [PATCH 049/143] xim xic --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 61 ++++++++++----------- libs/openFrameworks/app/ofAppGLFWWindow.h | 43 ++++++++------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index c5cc68419c2..1cca4ee21c1 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -93,43 +93,11 @@ void ofAppGLFWWindow::close() { } } -//------------------------------------------------------------ -void ofAppGLFWWindow::setNumSamples(int _samples) { - settings.numSamples = _samples; -} - //------------------------------------------------------------ void ofAppGLFWWindow::setMultiDisplayFullscreen(bool bMultiFullscreen) { settings.multiMonitorFullScreen = bMultiFullscreen; } -//------------------------------------------------------------ -void ofAppGLFWWindow::setDoubleBuffering(bool doubleBuff) { - settings.doubleBuffering = doubleBuff; -} - -//------------------------------------------------------------ -void ofAppGLFWWindow::setColorBits(int r, int g, int b) { - settings.redBits = r; - settings.greenBits = g; - settings.blueBits = b; -} - -//------------------------------------------------------------ -void ofAppGLFWWindow::setAlphaBits(int a) { - settings.alphaBits = a; -} - -//------------------------------------------------------------ -void ofAppGLFWWindow::setDepthBits(int depth) { - settings.depthBits = depth; -} - -//------------------------------------------------------------ -void ofAppGLFWWindow::setStencilBits(int stencil) { - settings.stencilBits = stencil; -} - //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { if (windowP) { @@ -1514,3 +1482,32 @@ HWND ofAppGLFWWindow::getWin32Window() { } #endif + + +// DEPRECATED - REMOVE + +void ofAppGLFWWindow::setNumSamples(int _samples) { + settings.numSamples = _samples; +} + +void ofAppGLFWWindow::setDoubleBuffering(bool doubleBuff) { + settings.doubleBuffering = doubleBuff; +} + +void ofAppGLFWWindow::setColorBits(int r, int g, int b) { + settings.redBits = r; + settings.greenBits = g; + settings.blueBits = b; +} + +void ofAppGLFWWindow::setAlphaBits(int a) { + settings.alphaBits = a; +} + +void ofAppGLFWWindow::setDepthBits(int depth) { + settings.depthBits = depth; +} + +void ofAppGLFWWindow::setStencilBits(int stencil) { + settings.stencilBits = stencil; +} diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 3531a279055..efb8a7d99f4 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -5,11 +5,6 @@ // MARK: Target #include "ofConstants.h" -//#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) -//typedef struct _XIM * XIM; -//typedef struct _XIC * XIC; -//#endif - class ofBaseApp; struct GLFWwindow; struct GLFWmonitor; @@ -96,22 +91,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { bool isWindowResizeable(); void iconify(bool bIconify); - // window settings, this functions can only be called from main before calling ofSetupOpenGL - // TODO: remove specialized version of ofSetupOpenGL when these go away - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setNumSamples(int samples); - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setDoubleBuffering(bool doubleBuff); - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setColorBits(int r, int g, int b); - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setAlphaBits(int a); - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setDepthBits(int depth); - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setStencilBits(int stencil); - [[deprecated("use ofGLFWWindowSettings to create the window")]] - void setMultiDisplayFullscreen(bool bMultiFullscreen); //note this just enables the mode, you have to toggle fullscreen to activate it. + #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) Display * getX11Display(); @@ -162,6 +142,9 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void close(); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) + typedef struct _XIM * XIM; + typedef struct _XIC * XIC; + XIM xim; XIC xic; #endif @@ -196,6 +179,24 @@ class ofAppGLFWWindow : public ofAppBaseWindow { //#endif // TARGET_WIN32 + + // window settings, this functions can only be called from main before calling ofSetupOpenGL + // TODO: remove specialized version of ofSetupOpenGL when these go away + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setNumSamples(int samples); + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setDoubleBuffering(bool doubleBuff); + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setColorBits(int r, int g, int b); + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setAlphaBits(int a); + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setDepthBits(int depth); + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setStencilBits(int stencil); + [[deprecated("use ofGLFWWindowSettings to create the window")]] + void setMultiDisplayFullscreen(bool bMultiFullscreen); //note this just enables the mode, you have to toggle fullscreen to activate it. + }; From 697c02b39f6a25268a7ceeea9220fb2417eb4e75 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 15:57:32 -0300 Subject: [PATCH 050/143] xic xim --- libs/openFrameworks/app/ofAppGLFWWindow.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index efb8a7d99f4..8adb21d25a6 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -94,6 +94,9 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) + typedef struct _XIM * XIM; + typedef struct _XIC * XIC; + Display * getX11Display(); Window getX11Window(); XIC getX11XIC(); @@ -142,8 +145,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void close(); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) - typedef struct _XIM * XIM; - typedef struct _XIC * XIC; + XIM xim; XIC xic; From 560a6e3b72369afe779e8cba3a81811f0dae4b7e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 16:17:22 -0300 Subject: [PATCH 051/143] remove comments --- addons/ofxiOS/src/app/ofAppiOSWindow.h | 34 -------------------------- 1 file changed, 34 deletions(-) diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.h b/addons/ofxiOS/src/app/ofAppiOSWindow.h index ca1c3c5ec73..b0e00f477fc 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.h +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.h @@ -110,40 +110,6 @@ class ofiOSWindowSettings: public ofWindowSettings{ } } - // ofiOSWindowSettings(const ofWindowSettings & settings) - // :ofGLESWindowSettings(settings) - // ,enableRetina(true) - // ,retinaScale(0) - // ,enableDepth(false) - // ,enableAntiAliasing(false) - // ,numOfAntiAliasingSamples(0) - // ,enableHardwareOrientation(false) - // ,enableHardwareOrientationAnimation(false) - // ,enableSetupScreen(true) - // ,windowControllerType(ofxiOSWindowControllerType::CORE_ANIMATION) - // ,colorType(ofxiOSRendererColorFormat::RGBA8888) - // ,depthType(ofxiOSRendererDepthFormat::DEPTH_NONE) - // ,stencilType(ofxiOSRendererStencilFormat::STENCIL_NONE) - // ,enableMultiTouch(false){ - // const ofiOSWindowSettings * iosSettings = dynamic_cast(&settings); - // if(iosSettings){ - // enableRetina = iosSettings->enableRetina; - // retinaScale = iosSettings->retinaScale; - // enableDepth = iosSettings->enableDepth; - // enableAntiAliasing = iosSettings->enableAntiAliasing; - // numOfAntiAliasingSamples = iosSettings->numOfAntiAliasingSamples; - // enableHardwareOrientation = iosSettings->enableHardwareOrientation; - // enableHardwareOrientationAnimation = iosSettings->enableHardwareOrientationAnimation; - // enableSetupScreen = iosSettings->enableSetupScreen; - // setupOrientation = iosSettings->setupOrientation; - // windowControllerType = iosSettings->windowControllerType; - // colorType = iosSettings->colorType; - // depthType = iosSettings->depthType; - // stencilType = iosSettings->stencilType; - // enableMultiTouch = iosSettings->enableMultiTouch; - // } - // } - virtual ~ofiOSWindowSettings(){}; bool enableRetina; From ec98cae59700d84e7d140c9a2d1047c2d40566dc Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 24 Jan 2024 16:19:45 -0300 Subject: [PATCH 052/143] glfw3native.h --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 1cca4ee21c1..61e79c109e2 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1,5 +1,4 @@ #include "ofAppGLFWWindow.h" - #include "ofGLProgrammableRenderer.h" #include "ofGLRenderer.h" @@ -15,7 +14,7 @@ #else #define GLFW_EXPOSE_NATIVE_EGL #endif - #include "GLFW/glfw3native.h" +// #include "GLFW/glfw3native.h" #include #include #include @@ -25,13 +24,16 @@ #include #define GLFW_EXPOSE_NATIVE_COCOA #define GLFW_EXPOSE_NATIVE_NSGL - #include "GLFW/glfw3native.h" +// #include "GLFW/glfw3native.h" #elif defined(TARGET_WIN32) #define GLFW_EXPOSE_NATIVE_WIN32 #define GLFW_EXPOSE_NATIVE_WGL - #include +// #include #endif +#include "GLFW/glfw3native.h" + + using std::numeric_limits; using std::shared_ptr; using std::vector; From c38d70f0af5dfc61cec34ff69348d2c9e18e0b63 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 25 Jan 2024 16:19:17 -0300 Subject: [PATCH 053/143] all updates goodies cherry picked --- libs/openFrameworks/app/ofAppBaseWindow.h | 1 + libs/openFrameworks/app/ofAppGLFWWindow.cpp | 133 +++++++++----------- libs/openFrameworks/app/ofAppGLFWWindow.h | 26 +--- libs/openFrameworks/app/ofMainLoop.cpp | 7 +- libs/openFrameworks/types/ofRectangle.cpp | 5 + libs/openFrameworks/types/ofRectangle.h | 1 + libs/openFrameworks/utils/ofMatrixStack.cpp | 22 ++-- 7 files changed, 83 insertions(+), 112 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 0a0b2d8ed87..448e64a9a83 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -48,6 +48,7 @@ class ofAppBaseWindow { virtual glm::ivec2 getWindowPosition() { return glm::ivec2(); } virtual glm::ivec2 getWindowSize() { return glm::ivec2(); } + virtual glm::ivec2 getFramebufferSize() { return glm::ivec2(); } virtual glm::ivec2 getScreenSize() { return glm::ivec2(); } virtual ofRectangle getWindowRect() { return ofRectangle(); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 61e79c109e2..86d74007647 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -51,8 +51,7 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ ofAppPtr = nullptr; - pixelScreenCoordScale = 1; - nFramesSinceWindowResized = 0; +// nFramesSinceWindowResized = 0; iconSet = false; windowP = nullptr; @@ -95,11 +94,6 @@ void ofAppGLFWWindow::close() { } } -//------------------------------------------------------------ -void ofAppGLFWWindow::setMultiDisplayFullscreen(bool bMultiFullscreen) { - settings.multiMonitorFullScreen = bMultiFullscreen; -} - //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { if (windowP) { @@ -129,6 +123,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwWindowHint(GLFW_STEREO, settings.stereo); glfwWindowHint(GLFW_VISIBLE, GL_FALSE); glfwWindowHint(GLFW_MAXIMIZED, settings.maximized); + // FIXME: Review this. #ifndef TARGET_OSX glfwWindowHint(GLFW_AUX_BUFFERS, settings.doubleBuffering ? 1 : 0); #else @@ -170,9 +165,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { sharedContext = (GLFWwindow *)settings.shareContextWith->getWindowContext(); } - - - GLFWmonitor *monitor = nullptr; // FIXME: maybe use as a global variable for the window? @@ -184,48 +176,29 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError("ofAppGLFWWindow") << "requested monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); } - if (settings.windowMode == OF_GAME_MODE) { windowRect = allMonitors.rects[monitorIndex]; monitor = allMonitors.monitors[monitorIndex]; } -// cout << "GLFW Will create windowRect " << windowRect << endl; // MARK: - WINDOW glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); windowRect = getWindowRect(); -// windowRect = + if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { -// cout << "rects size " << allMonitors.rects.size() << endl; -// cout << "window mode monitorindex = " << monitorIndex << endl; -// cout << "settings.monitor = " << settings.monitor << endl; - -// cout << settings.windowName << " windowRect before " << windowRect << endl; if (monitorIndex > 0) { windowRect.x += allMonitors.rects[monitorIndex].x; windowRect.y += allMonitors.rects[monitorIndex].y; setWindowRect(windowRect); } - // OK, this is just so isPositionSet is ok in next few lines. - // FIXME: there is a problem here, position will be zeroed if setposition is called before window creation. -// { -// settings.setPosition({windowRect.x, windowRect.y}); -// } -// cout << settings.windowName << " windowRect after " << windowRect << endl; } - - -// cout << "GLFW windowRect " << windowRect << " : " << settings.windowName << endl; - if (settings.isPositionSet()) { -// cout << "GLFW isPosition set true : " << settings.windowName << endl; setWindowRect(windowRect); } else { -// cout << "GLFW isPosition set false : " << settings.windowName << endl; setWindowShape(windowRect.width, windowRect.height); } @@ -233,7 +206,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; return; } -// cout << "GLFW window created OK" << endl; // MARK: - @@ -253,10 +225,13 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { setWindowIcon(iconPixels); } #endif + + //FIXME: check if it works with hint GLFW_AUTO_ICONIFY if (settings.iconified) { iconify(true); } + //FIXME: check if it works with hint GLFW_MAXIMIZED if (settings.maximized) { glfwMaximizeWindow(windowP); } @@ -401,50 +376,49 @@ void ofAppGLFWWindow::pollEvents() { void ofAppGLFWWindow::draw() { currentRenderer->startRender(); if (bEnableSetupScreen) { -// cout << "ow currentRenderer->setupScreen()" << endl; currentRenderer->setupScreen(); } events().notifyDraw(); -#ifdef TARGET_WIN32 - if (currentRenderer->getBackgroundAuto() == false) { - // on a PC resizing a window with this method of accumulation (essentially single buffering) - // is BAD, so we clear on resize events. - if (nFramesSinceWindowResized < 3) { - currentRenderer->clear(); - } else { - if ((events().getFrameNum() < 3 || nFramesSinceWindowResized < 3) && settings.doubleBuffering) { - glfwSwapBuffers(windowP); - } else { - glFlush(); - } - } - } else { - if (settings.doubleBuffering) { - glfwSwapBuffers(windowP); - } else { - glFlush(); - } - } -#else - if (currentRenderer->getBackgroundAuto() == false) { - // in accum mode resizing a window is BAD, so we clear on resize events. - if (nFramesSinceWindowResized < 3) { - currentRenderer->clear(); - } - } +//#ifdef TARGET_WIN32 +// if (currentRenderer->getBackgroundAuto() == false) { +// // on a PC resizing a window with this method of accumulation (essentially single buffering) +// // is BAD, so we clear on resize events. +// if (nFramesSinceWindowResized < 3) { +// currentRenderer->clear(); +// } +// +// else { +// if ((events().getFrameNum() < 3 || nFramesSinceWindowResized < 3) && settings.doubleBuffering) { +// glfwSwapBuffers(windowP); +// } else { +// glFlush(); +// } +// } +// } else { +// if (settings.doubleBuffering) { +// glfwSwapBuffers(windowP); +// } else { +// glFlush(); +// } +// } +//#else +// +// +//#endif + if (settings.doubleBuffering) { glfwSwapBuffers(windowP); -// std::cout << "swap buffers " << ofGetFrameNum() << std::endl; + // std::cout << "swap buffers " << ofGetFrameNum() << std::endl; } else { glFlush(); } -#endif - + + currentRenderer->finishRender(); - nFramesSinceWindowResized++; +// nFramesSinceWindowResized++; } //-------------------------------------------- @@ -480,10 +454,10 @@ void ofAppGLFWWindow::setWindowTitle(const std::string & title) { //------------------------------------------------------------ int ofAppGLFWWindow::getPixelScreenCoordScale() { - - // TODO: - // discover which monitor this window - return pixelScreenCoordScale; + // FIXME: cache? + glm::vec2 contentScale; + glfwGetWindowContentScale(windowP, &contentScale.x, &contentScale.y); + return contentScale.x; } //------------------------------------------------------------ @@ -502,6 +476,14 @@ glm::ivec2 ofAppGLFWWindow::getWindowSize() { return size; } +//------------------------------------------------------------ +glm::ivec2 ofAppGLFWWindow::getFramebufferSize() { + // FIXME: cache size and handle in framebuffer_size_cb + glm::ivec2 size; + glfwGetFramebufferSize(windowP, &size.x, &size.y); + return size; +} + //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getWindowPosition() { glm::ivec2 pos; @@ -511,7 +493,7 @@ glm::ivec2 ofAppGLFWWindow::getWindowPosition() { //------------------------------------------------------------ glm::ivec2 ofAppGLFWWindow::getScreenSize() { - // FIXME: if screen = monitor and screensize is actual monitor from the window it is correct. + // it will return the monitor/screen size where the windows sit. windowRect = getWindowRect(); return allMonitors.getRectMonitorForScreenRect(windowRect).getSize(); } @@ -676,6 +658,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { Display * display = glfwGetX11Display(); if (targetWindowMode == OF_FULLSCREEN) { + // FIXME: Remove legacy code here int monitorCount; GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); @@ -1053,8 +1036,8 @@ void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) { } ofMouseEventArgs args(action, - x * instance->pixelScreenCoordScale, - y * instance->pixelScreenCoordScale, + x, + y, instance->buttonInUse, instance->events().getModifiers()); instance->events().notifyMouseEvent(args); @@ -1307,7 +1290,7 @@ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { //------------------------------------------------------------ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { - cout << "monitor_cb!" << endl; +// cout << "monitor_cb!" << endl; allMonitors.update(); } @@ -1324,7 +1307,7 @@ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { ofAppGLFWWindow * instance = setCurrent(windowP_); instance->events().notifyWindowResized(w, h); - instance->nFramesSinceWindowResized = 0; +// instance->nFramesSinceWindowResized = 0; #if defined(TARGET_OSX) if (!instance->bWindowNeedsShowing) { @@ -1343,6 +1326,8 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { // cout << "framebuffer_size_cb " << w << " : " << h << endl; ofAppGLFWWindow * instance = setCurrent(windowP_); + + instance->currentRenderer->clear(); instance->events().notifyFramebufferResized(w, h); } @@ -1513,3 +1498,7 @@ void ofAppGLFWWindow::setDepthBits(int depth) { void ofAppGLFWWindow::setStencilBits(int stencil) { settings.stencilBits = stencil; } + +void ofAppGLFWWindow::setMultiDisplayFullscreen(bool bMultiFullscreen) { + settings.multiMonitorFullScreen = bMultiFullscreen; +} diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 8adb21d25a6..df547bfe0b7 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -57,6 +57,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { glm::ivec2 getScreenSize(); glm::ivec2 getWindowSize(); + glm::ivec2 getFramebufferSize(); glm::ivec2 getWindowPosition(); ofRectangle getWindowRect(); @@ -91,8 +92,6 @@ class ofAppGLFWWindow : public ofAppBaseWindow { bool isWindowResizeable(); void iconify(bool bIconify); - - #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) typedef struct _XIM * XIM; typedef struct _XIC * XIC; @@ -145,8 +144,6 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void close(); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) - - XIM xim; XIC xic; #endif @@ -157,9 +154,6 @@ class ofAppGLFWWindow : public ofAppBaseWindow { ofWindowMode targetWindowMode; bool bEnableSetupScreen; - - // FIXME remove - float pixelScreenCoordScale; /// Scale factor from virtual operating-system defined client area extents (as seen in currentW, currentH) to physical framebuffer pixel coordinates (as seen in windowW, windowH). ofRectangle windowRect { 20, 20, 800, 600 }; ofRectangle windowRectFS { 0, 0, 1920, 1080 }; @@ -168,18 +162,13 @@ class ofAppGLFWWindow : public ofAppBaseWindow { int buttonInUse; bool buttonPressed; - int nFramesSinceWindowResized; +// int nFramesSinceWindowResized; bool bWindowNeedsShowing; GLFWwindow * windowP; ofBaseApp * ofAppPtr; bool iconSet; - -//#ifdef TARGET_WIN32 -// LONG lExStyle, lStyle; -//#endif // TARGET_WIN32 - // window settings, this functions can only be called from main before calling ofSetupOpenGL @@ -228,7 +217,6 @@ static struct ofMonitors { } ofRectangle getRectForAllMonitors() { -// cout << "getRectForAllMonitors " << allMonitorsRect << endl; return allMonitorsRect; } @@ -264,17 +252,7 @@ static struct ofMonitors { } } } -// cout << "getRectFromMonitors " << str << " :: " << r << endl; - return r; - } - - ofRectangle getRectFromMonitorsX() { - ofRectangle r; - ofRectangle r2 { 30, 30, 30, 30 }; - r = r.getUnion(r2); return r; } - } allMonitors; -//#endif diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 6320088a236..fa5206e78ef 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -27,12 +27,7 @@ #include "ofAppGLFWWindow.h" #endif -ofMainLoop::ofMainLoop() -:bShouldClose(false) -,status(0) -,allowMultiWindow(true) -,escapeQuits(true){ - +ofMainLoop::ofMainLoop() : bShouldClose(false), status(0), allowMultiWindow(true), escapeQuits(true) { } ofMainLoop::~ofMainLoop() { diff --git a/libs/openFrameworks/types/ofRectangle.cpp b/libs/openFrameworks/types/ofRectangle.cpp index 2ec09264b51..a6f9a53e65d 100644 --- a/libs/openFrameworks/types/ofRectangle.cpp +++ b/libs/openFrameworks/types/ofRectangle.cpp @@ -18,6 +18,11 @@ ofRectangle::ofRectangle(float px, float py, float w, float h) : x(position.x), set(px,py,w,h); } +//---------------------------------------------------------- +ofRectangle::ofRectangle(int px, int py, int w, int h) : x(position.x), y(position.y) { + set(px,py,w,h); +} + //---------------------------------------------------------- ofRectangle::ofRectangle(const glm::vec3& p, float w, float h) : x(position.x), y(position.y) { set(p,w,h); diff --git a/libs/openFrameworks/types/ofRectangle.h b/libs/openFrameworks/types/ofRectangle.h index ad8a1587ccd..7b7a8aca1b5 100644 --- a/libs/openFrameworks/types/ofRectangle.h +++ b/libs/openFrameworks/types/ofRectangle.h @@ -105,6 +105,7 @@ class ofRectangle { /// \param w The width of the rectangle. /// \param h The height of the rectangle. ofRectangle(float px, float py, float w, float h); + ofRectangle(int px, int py, int w, int h); /// \brief Construct a rectangle from a point and dimensions. /// diff --git a/libs/openFrameworks/utils/ofMatrixStack.cpp b/libs/openFrameworks/utils/ofMatrixStack.cpp index 230d9b0b303..f84054a018a 100644 --- a/libs/openFrameworks/utils/ofMatrixStack.cpp +++ b/libs/openFrameworks/utils/ofMatrixStack.cpp @@ -122,7 +122,7 @@ int ofMatrixStack::getRenderSurfaceWidth() const{ if(currentRenderSurface){ return currentRenderSurface->getWidth(); }else if(currentWindow){ - return currentWindow->getWindowSize().x; + return currentWindow->getFramebufferSize().x; }else{ return 0; } @@ -132,7 +132,7 @@ int ofMatrixStack::getRenderSurfaceHeight() const{ if(currentRenderSurface){ return currentRenderSurface->getHeight(); }else if(currentWindow){ - return currentWindow->getWindowSize().y; + return currentWindow->getFramebufferSize().y; }else{ return 0; } @@ -143,7 +143,9 @@ glm::ivec2 ofMatrixStack::getRenderSurfaceSize() const { return currentRenderSurface->getSize(); } else if (currentWindow) { // FIXME: FramebufferSize - return currentWindow->getWindowSize(); + // return currentWindow->getWindowSize(); + return currentWindow->getFramebufferSize(); + } else { return {}; } @@ -203,13 +205,13 @@ ofRectangle ofMatrixStack::getNativeViewport() const{ return currentViewport; } -ofRectangle ofMatrixStack::getFullSurfaceViewport() const{ - if(currentRenderSurface){ - return ofRectangle(0,0,currentRenderSurface->getWidth(),currentRenderSurface->getHeight()); - }else if(currentWindow){ - return ofRectangle(0,0,currentWindow->getWidth(),currentWindow->getHeight()); - }else{ - return ofRectangle(); +ofRectangle ofMatrixStack::getFullSurfaceViewport() const { + if (currentRenderSurface) { + return { 0.0f, 0.0f, currentRenderSurface->getWidth(),currentRenderSurface->getHeight() }; + } else if (currentWindow) { + return { 0, 0, currentWindow->getWidth(), currentWindow->getHeight() }; + } else { + return {}; //ofRectangle(); } } From 55734e8eb2db92e119af1f763c59e5b88975304f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 25 Jan 2024 16:28:05 -0300 Subject: [PATCH 054/143] ofxCvContourFinder.h setAnchorPoint fix --- addons/ofxOpenCv/src/ofxCvContourFinder.cpp | 9 +-- addons/ofxOpenCv/src/ofxCvContourFinder.h | 69 ++++++++++----------- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/addons/ofxOpenCv/src/ofxCvContourFinder.cpp b/addons/ofxOpenCv/src/ofxCvContourFinder.cpp index 986e0eb785c..4386ed4c0b7 100644 --- a/addons/ofxOpenCv/src/ofxCvContourFinder.cpp +++ b/addons/ofxOpenCv/src/ofxCvContourFinder.cpp @@ -1,21 +1,14 @@ #include "ofxCvContourFinder.h" - - //-------------------------------------------------------------------------------- static bool sort_carea_compare( const CvSeq* a, const CvSeq* b) { - // use opencv to calc size, then sort based on size float areaa = cvContourArea(a, CV_WHOLE_SEQ); float areab = cvContourArea(b, CV_WHOLE_SEQ); - return (areaa > areab); } - - - //-------------------------------------------------------------------------------- ofxCvContourFinder::ofxCvContourFinder() { _width = 0; @@ -218,7 +211,7 @@ void ofxCvContourFinder::setAnchorPercent( float xPct, float yPct ){ } //-------------------------------------------------------------------------------- -void ofxCvContourFinder::setAnchorPoint( int x, int y ){ +void ofxCvContourFinder::setAnchorPoint( float x, float y ){ anchor.x = x; anchor.y = y; bAnchorIsPct = false; diff --git a/addons/ofxOpenCv/src/ofxCvContourFinder.h b/addons/ofxOpenCv/src/ofxCvContourFinder.h index 58a65f2194b..3c8852824d5 100644 --- a/addons/ofxOpenCv/src/ofxCvContourFinder.h +++ b/addons/ofxOpenCv/src/ofxCvContourFinder.h @@ -16,52 +16,51 @@ #include class ofxCvContourFinder : public ofBaseDraws { +public: - public: - - std::vector blobs; - int nBlobs; // DEPRECATED: use blobs.size() instead - + std::vector blobs; + int nBlobs; // DEPRECATED: use blobs.size() instead + - ofxCvContourFinder(); - virtual ~ofxCvContourFinder(); - + ofxCvContourFinder(); + virtual ~ofxCvContourFinder(); + virtual float getWidth() const { return _width; }; //set after first findContours call virtual float getHeight() const { return _height; }; //set after first findContours call - - virtual int findContours( ofxCvGrayscaleImage& input, - int minArea, int maxArea, - int nConsidered, bool bFindHoles, - bool bUseApproximation = true); - // approximation = don't do points for all points - // of the contour, if the contour runs - // along a straight line, for example... + + virtual int findContours( ofxCvGrayscaleImage& input, + int minArea, int maxArea, + int nConsidered, bool bFindHoles, + bool bUseApproximation = true); + // approximation = don't do points for all points + // of the contour, if the contour runs + // along a straight line, for example... - virtual void draw() const { draw(0,0, _width, _height); }; - virtual void draw( float x, float y ) const { draw(x,y, _width, _height); }; - virtual void draw( float x, float y, float w, float h ) const; - virtual void draw(const glm::vec2 & point) const; - virtual void draw(const ofRectangle & rect) const; + virtual void draw() const { draw(0,0, _width, _height); }; + virtual void draw( float x, float y ) const { draw(x,y, _width, _height); }; + virtual void draw( float x, float y, float w, float h ) const; + virtual void draw(const glm::vec2 & point) const; + virtual void draw(const ofRectangle & rect) const; virtual void setAnchorPercent(float xPct, float yPct); - virtual void setAnchorPoint(int x, int y); + virtual void setAnchorPoint(float x, float y); virtual void resetAnchor(); - //virtual ofxCvBlob getBlob(int num); + //virtual ofxCvBlob getBlob(int num); - protected: + protected: - int _width; - int _height; - ofxCvGrayscaleImage inputCopy; - CvMemStorage* contour_storage; - CvMemStorage* storage; - CvMoments* myMoments; - std::vector cvSeqBlobs; //these will become blobs - - ofPoint anchor; - bool bAnchorIsPct; + int _width; + int _height; + ofxCvGrayscaleImage inputCopy; + CvMemStorage* contour_storage; + CvMemStorage* storage; + CvMoments* myMoments; + std::vector cvSeqBlobs; //these will become blobs + + ofPoint anchor; + bool bAnchorIsPct; - virtual void reset(); + virtual void reset(); }; From cd62823702402b5af33c869e1d2e097409eccce6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 25 Jan 2024 16:42:20 -0300 Subject: [PATCH 055/143] comment out ofRectangle using int parameters --- libs/openFrameworks/types/ofRectangle.cpp | 8 ++++---- libs/openFrameworks/types/ofRectangle.h | 3 ++- libs/openFrameworks/utils/ofMatrixStack.cpp | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/types/ofRectangle.cpp b/libs/openFrameworks/types/ofRectangle.cpp index a6f9a53e65d..a64b5c1e1fe 100644 --- a/libs/openFrameworks/types/ofRectangle.cpp +++ b/libs/openFrameworks/types/ofRectangle.cpp @@ -18,10 +18,10 @@ ofRectangle::ofRectangle(float px, float py, float w, float h) : x(position.x), set(px,py,w,h); } -//---------------------------------------------------------- -ofRectangle::ofRectangle(int px, int py, int w, int h) : x(position.x), y(position.y) { - set(px,py,w,h); -} +// //---------------------------------------------------------- +// ofRectangle::ofRectangle(int px, int py, int w, int h) : x(position.x), y(position.y) { +// set(px,py,w,h); +// } //---------------------------------------------------------- ofRectangle::ofRectangle(const glm::vec3& p, float w, float h) : x(position.x), y(position.y) { diff --git a/libs/openFrameworks/types/ofRectangle.h b/libs/openFrameworks/types/ofRectangle.h index 7b7a8aca1b5..f94f0558b8a 100644 --- a/libs/openFrameworks/types/ofRectangle.h +++ b/libs/openFrameworks/types/ofRectangle.h @@ -105,7 +105,8 @@ class ofRectangle { /// \param w The width of the rectangle. /// \param h The height of the rectangle. ofRectangle(float px, float py, float w, float h); - ofRectangle(int px, int py, int w, int h); + + // ofRectangle(int px, int py, int w, int h); /// \brief Construct a rectangle from a point and dimensions. /// diff --git a/libs/openFrameworks/utils/ofMatrixStack.cpp b/libs/openFrameworks/utils/ofMatrixStack.cpp index f84054a018a..4eebd5f5575 100644 --- a/libs/openFrameworks/utils/ofMatrixStack.cpp +++ b/libs/openFrameworks/utils/ofMatrixStack.cpp @@ -209,7 +209,8 @@ ofRectangle ofMatrixStack::getFullSurfaceViewport() const { if (currentRenderSurface) { return { 0.0f, 0.0f, currentRenderSurface->getWidth(),currentRenderSurface->getHeight() }; } else if (currentWindow) { - return { 0, 0, currentWindow->getWidth(), currentWindow->getHeight() }; + // FIXME: ofRectangle accepting int as parameter. + return { 0, 0, (float)currentWindow->getWidth(), (float)currentWindow->getHeight() }; } else { return {}; //ofRectangle(); } From d6d749a600dda72ddb16645cacdc2d84e108796e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 25 Jan 2024 17:23:58 -0300 Subject: [PATCH 056/143] windowsapps removal --- libs/openFrameworks/app/ofAppRunner.cpp | 3 +- libs/openFrameworks/app/ofMainLoop.cpp | 181 +++++++++++++-------- libs/openFrameworks/app/ofMainLoop.h | 12 +- libs/openFrameworks/app/ofWindowSettings.h | 1 + 4 files changed, 127 insertions(+), 70 deletions(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 36a36d56b3a..95466396428 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -108,8 +108,7 @@ void ofInit(){ initialized() = true; exiting() = false; - std::cout << "ofInit() " << std::endl; - +// std::cout << "ofInit() " << std::endl; #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) // manage own exit #else diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index fa5206e78ef..996d014ca17 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -60,7 +60,8 @@ std::shared_ptr ofMainLoop::createWindow(const ofWindowSettings } void ofMainLoop::run(const std::shared_ptr & window, std::shared_ptr && app){ - windowsApps[window] = app; + mainApp = app; +// windowsApps[window] = app; if(app){ ofAddListener(window->events().setup,app.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP); ofAddListener(window->events().update,app.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP); @@ -107,14 +108,18 @@ void ofMainLoop::run(const std::shared_ptr & window, std::share } void ofMainLoop::run(std::shared_ptr && app){ - if(!windowsApps.empty()){ - run(windowsApps.begin()->first, std::move(app)); +// if(!windowsApps.empty()){ +// run(windowsApps.begin()->first, std::move(app)); +// } + if(!windows.empty()){ + run(windows[0], std::move(app)); } } int ofMainLoop::loop(){ if(!windowLoop){ - while(!bShouldClose && !windowsApps.empty()){ +// while(!bShouldClose && !windowsApps.empty()){ + while(!bShouldClose && !windows.empty()){ loopOnce(); pollEvents(); } @@ -126,19 +131,47 @@ int ofMainLoop::loop(){ void ofMainLoop::loopOnce(){ if(bShouldClose) return; - for(auto i = windowsApps.begin(); !windowsApps.empty() && i != windowsApps.end();){ - if(i->first->getWindowShouldClose()){ - const auto & window = i->first; - window->close(); - windowsApps.erase(i++); ///< i now points at the window after the one which was just erased - }else{ - currentWindow = i->first; - i->first->makeCurrent(); - i->first->update(); - i->first->draw(); - i++; ///< continue to next window + +// std::cout << "ofMainLoop::loopOnce()" << std::endl; + auto i = windows.begin(); + for ( ; i != windows.end(); ) { + if (i->get()->getWindowShouldClose()) { + i = windows.erase(i); + } else { + currentWindow = (*i); + i->get()->makeCurrent(); + i->get()->update(); + i->get()->draw(); + ++i; } } + +// for(auto i = windows.begin(); !windows.empty() && i != windows.end();){ +// if(i->get()->getWindowShouldClose()){ +//// const auto & window = i->first; +// i->get()->close(); +// windows.erase(i++); +// } else { +// currentWindow = i; +// i->makeCurrent(); +// i->update(); +// i->draw(); +// i++; ///< continue to next window +// } +// } +// for(auto i = windowsApps.begin(); !windowsApps.empty() && i != windowsApps.end();){ +// if(i->first->getWindowShouldClose()){ +// const auto & window = i->first; +// window->close(); +// windowsApps.erase(i++); ///< i now points at the window after the one which was just erased +// }else{ +// currentWindow = i->first; +// i->first->makeCurrent(); +// i->first->update(); +// i->first->draw(); +// i++; ///< continue to next window +// } +// } loopEvent.notify(this); } @@ -151,55 +184,59 @@ void ofMainLoop::pollEvents(){ void ofMainLoop::exit(){ exitEvent.notify(this); - for(auto i: windowsApps){ - std::shared_ptr window = i.first; - std::shared_ptr app = i.second; + for (auto window : windows) { +// for(auto i: windowsApps){ +// std::shared_ptr window = i.first; +// std::shared_ptr app = i.second; +// if(app == nullptr) { +// continue; +// } if(window == nullptr) { continue; } - if(app == nullptr) { - continue; - } + ofEventArgs args; ofNotifyEvent(window->events().exit, args, this); - ofRemoveListener(window->events().setup,app.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().update,app.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().draw,app.get(),&ofBaseApp::draw,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().exit,app.get(),&ofBaseApp::exit,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().keyPressed,app.get(),&ofBaseApp::keyPressed,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().keyReleased,app.get(),&ofBaseApp::keyReleased,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mouseMoved,app.get(),&ofBaseApp::mouseMoved,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mouseDragged,app.get(),&ofBaseApp::mouseDragged,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mousePressed,app.get(),&ofBaseApp::mousePressed,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mouseReleased,app.get(),&ofBaseApp::mouseReleased,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mouseScrolled,app.get(),&ofBaseApp::mouseScrolled,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mouseEntered,app.get(),&ofBaseApp::mouseEntered,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().mouseExited,app.get(),&ofBaseApp::mouseExited,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().windowResized,app.get(),&ofBaseApp::windowResized,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().messageEvent,app.get(),&ofBaseApp::messageReceived,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().fileDragEvent,app.get(),&ofBaseApp::dragged,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().touchCancelled,app.get(),&ofBaseApp::touchCancelled,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().touchDoubleTap,app.get(),&ofBaseApp::touchDoubleTap,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().touchDown,app.get(),&ofBaseApp::touchDown,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().touchMoved,app.get(),&ofBaseApp::touchMoved,OF_EVENT_ORDER_APP); - ofRemoveListener(window->events().touchUp,app.get(),&ofBaseApp::touchUp,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().setup,app.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().update,app.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().draw,app.get(),&ofBaseApp::draw,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().exit,app.get(),&ofBaseApp::exit,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().keyPressed,app.get(),&ofBaseApp::keyPressed,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().keyReleased,app.get(),&ofBaseApp::keyReleased,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mouseMoved,app.get(),&ofBaseApp::mouseMoved,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mouseDragged,app.get(),&ofBaseApp::mouseDragged,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mousePressed,app.get(),&ofBaseApp::mousePressed,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mouseReleased,app.get(),&ofBaseApp::mouseReleased,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mouseScrolled,app.get(),&ofBaseApp::mouseScrolled,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mouseEntered,app.get(),&ofBaseApp::mouseEntered,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().mouseExited,app.get(),&ofBaseApp::mouseExited,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().windowResized,app.get(),&ofBaseApp::windowResized,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().messageEvent,app.get(),&ofBaseApp::messageReceived,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().fileDragEvent,app.get(),&ofBaseApp::dragged,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().touchCancelled,app.get(),&ofBaseApp::touchCancelled,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().touchDoubleTap,app.get(),&ofBaseApp::touchDoubleTap,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().touchDown,app.get(),&ofBaseApp::touchDown,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().touchMoved,app.get(),&ofBaseApp::touchMoved,OF_EVENT_ORDER_APP); +// ofRemoveListener(window->events().touchUp,app.get(),&ofBaseApp::touchUp,OF_EVENT_ORDER_APP); #ifdef TARGET_ANDROID - auto androidApp = dynamic_cast(app.get()); - if(androidApp){ - ofRemoveListener(ofxAndroidEvents().okPressed,androidApp,&ofxAndroidApp::okPressed,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().cancelPressed,androidApp,&ofxAndroidApp::cancelPressed,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().backPressed,androidApp,&ofxAndroidApp::backPressed,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().networkConnected,androidApp,&ofxAndroidApp::networkConnectedEvent,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().pause,androidApp,&ofxAndroidApp::pause,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().resume,androidApp,&ofxAndroidApp::resume,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().unloadGL,androidApp,&ofxAndroidApp::unloadGL,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().reloadGL,androidApp,&ofxAndroidApp::reloadGL,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().swipe,androidApp,&ofxAndroidApp::swipe,OF_EVENT_ORDER_APP); - ofRemoveListener(ofxAndroidEvents().deviceOrientationChanged,androidApp,&ofxAndroidApp::deviceOrientationChangedEvent,OF_EVENT_ORDER_APP); - } + + // FIXME: how will this work with Android? +// auto androidApp = dynamic_cast(app.get()); +// if(androidApp){ +// ofRemoveListener(ofxAndroidEvents().okPressed,androidApp,&ofxAndroidApp::okPressed,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().cancelPressed,androidApp,&ofxAndroidApp::cancelPressed,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().backPressed,androidApp,&ofxAndroidApp::backPressed,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().networkConnected,androidApp,&ofxAndroidApp::networkConnectedEvent,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().pause,androidApp,&ofxAndroidApp::pause,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().resume,androidApp,&ofxAndroidApp::resume,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().unloadGL,androidApp,&ofxAndroidApp::unloadGL,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().reloadGL,androidApp,&ofxAndroidApp::reloadGL,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().swipe,androidApp,&ofxAndroidApp::swipe,OF_EVENT_ORDER_APP); +// ofRemoveListener(ofxAndroidEvents().deviceOrientationChanged,androidApp,&ofxAndroidApp::deviceOrientationChangedEvent,OF_EVENT_ORDER_APP); +// } #endif } @@ -207,10 +244,13 @@ void ofMainLoop::exit(){ // reset applications then windows // so events are present until the // end of the application - for(auto & window_app: windowsApps){ - window_app.second.reset(); - } - windowsApps.clear(); +// for(auto & window_app: windowsApps){ +// window_app.second.reset(); +// } +// windowsApps.clear(); + + mainApp.reset(); + windows.clear(); } std::shared_ptr ofMainLoop::getCurrentWindow(){ @@ -225,21 +265,32 @@ void ofMainLoop::setCurrentWindow(ofAppBaseWindow * window){ if(currentWindow.lock().get() == window){ return; } - for(auto i: windowsApps){ - if(i.first.get() == window){ - currentWindow = i.first; + + for (const auto & w : windows) { + if (w.get() == window) { + currentWindow = w; break; } } +// for(auto i: windowsApps){ +// if(i.first.get() == window){ +// currentWindow = i.first; +// break; +// } +// } } std::shared_ptr ofMainLoop::getCurrentApp(){ - return windowsApps[currentWindow.lock()]; +// return windowsApps[currentWindow.lock()]; + return mainApp; } void ofMainLoop::shouldClose(int _status){ - for(auto i: windowsApps){ - i.first->setWindowShouldClose(); +// for(auto i: windowsApps){ +// i.first->setWindowShouldClose(); +// } + for(auto w : windows){ + w->setWindowShouldClose(); } bShouldClose = true; status = _status; diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index 923a889033c..bf23b505c82 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -24,9 +24,11 @@ class ofMainLoop { windowPollEvents = Window::pollEvents; } if(!allowMultiWindow){ - windowsApps.clear(); + windows.clear(); +// windowsApps.clear(); } - windowsApps[window] = std::shared_ptr(); + windows.emplace_back(window); +// windowsApps[window] = std::shared_ptr(); currentWindow = window; ofAddListener(window->events().keyPressed,this,&ofMainLoop::keyPressed); } @@ -53,7 +55,11 @@ class ofMainLoop { std::thread::id thread_id { std::this_thread::get_id() }; void keyPressed(ofKeyEventArgs & key); - std::unordered_map, std::shared_ptr > windowsApps; +// std::unordered_map, std::shared_ptr > windowsApps; + + std::vector > windows; + std::shared_ptr mainApp; + bool bShouldClose; std::weak_ptr currentWindow; int status; diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index 56e8b69c55c..289f6a000e5 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -127,6 +127,7 @@ class ofWindowSettings { bool multiMonitorFullScreen = false; std::shared_ptr shareContextWith; std::vector fullscreenDisplays; + bool showInSelectedMonitor = false; protected: bool sizeSet { false }; From a86b14f34a58e3fb4091c5c1562e1b95af77ea73 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 26 Jan 2024 10:27:21 -0300 Subject: [PATCH 057/143] resolve conflict --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 45 +++------------------ tests/io/loadImage/src/main.cpp | 6 +-- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 86d74007647..482728b97b6 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -14,7 +14,6 @@ #else #define GLFW_EXPOSE_NATIVE_EGL #endif -// #include "GLFW/glfw3native.h" #include #include #include @@ -24,16 +23,13 @@ #include #define GLFW_EXPOSE_NATIVE_COCOA #define GLFW_EXPOSE_NATIVE_NSGL -// #include "GLFW/glfw3native.h" #elif defined(TARGET_WIN32) #define GLFW_EXPOSE_NATIVE_WIN32 #define GLFW_EXPOSE_NATIVE_WGL -// #include #endif #include "GLFW/glfw3native.h" - using std::numeric_limits; using std::shared_ptr; using std::vector; @@ -51,11 +47,9 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ ofAppPtr = nullptr; -// nFramesSinceWindowResized = 0; iconSet = false; windowP = nullptr; - glfwSetErrorCallback(error_cb); } @@ -65,7 +59,6 @@ ofAppGLFWWindow::~ofAppGLFWWindow() { void ofAppGLFWWindow::close() { if (windowP) { - glfwSetMouseButtonCallback( windowP, nullptr ); glfwSetCursorPosCallback( windowP, nullptr ); glfwSetCursorEnterCallback( windowP, nullptr ); @@ -186,6 +179,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); + + // saves window rectangle just created. windowRect = getWindowRect(); if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { @@ -197,6 +192,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } if (settings.isPositionSet()) { + windowRect.x = settings.getPosition().x; + windowRect.y = settings.getPosition().y; setWindowRect(windowRect); } else { setWindowShape(windowRect.width, windowRect.height); @@ -215,6 +212,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { #ifdef TARGET_LINUX if (!iconSet) { ofPixels iconPixels; + // FIXME: we can have this define in ofIcon.h instead #ifdef DEBUG iconPixels.allocate(ofIconDebug.width, ofIconDebug.height, ofIconDebug.bytes_per_pixel); GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(), ofIconDebug.rle_pixel_data, iconPixels.getWidth() * iconPixels.getHeight(), ofIconDebug.bytes_per_pixel); @@ -368,7 +366,6 @@ void ofAppGLFWWindow::update() { //-------------------------------------------- void ofAppGLFWWindow::pollEvents() { -// cout << "pollEvents " << ofGetFrameNum() << endl; glfwPollEvents(); } @@ -381,33 +378,6 @@ void ofAppGLFWWindow::draw() { events().notifyDraw(); -//#ifdef TARGET_WIN32 -// if (currentRenderer->getBackgroundAuto() == false) { -// // on a PC resizing a window with this method of accumulation (essentially single buffering) -// // is BAD, so we clear on resize events. -// if (nFramesSinceWindowResized < 3) { -// currentRenderer->clear(); -// } -// -// else { -// if ((events().getFrameNum() < 3 || nFramesSinceWindowResized < 3) && settings.doubleBuffering) { -// glfwSwapBuffers(windowP); -// } else { -// glFlush(); -// } -// } -// } else { -// if (settings.doubleBuffering) { -// glfwSwapBuffers(windowP); -// } else { -// glFlush(); -// } -// } -//#else -// -// -//#endif - if (settings.doubleBuffering) { glfwSwapBuffers(windowP); // std::cout << "swap buffers " << ofGetFrameNum() << std::endl; @@ -415,10 +385,7 @@ void ofAppGLFWWindow::draw() { glFlush(); } - currentRenderer->finishRender(); - -// nFramesSinceWindowResized++; } //-------------------------------------------- @@ -515,7 +482,7 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { - cout << settings.windowName << " setWindowRect " << rect << endl; +// cout << settings.windowName << " setWindowRect " << rect << endl; glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } diff --git a/tests/io/loadImage/src/main.cpp b/tests/io/loadImage/src/main.cpp index f30244aabdc..914effb017b 100644 --- a/tests/io/loadImage/src/main.cpp +++ b/tests/io/loadImage/src/main.cpp @@ -9,11 +9,7 @@ class ofApp: public ofxUnitTestsApp{ ofxTest(img.load("indispensable.jpg"), "load from fs"); ofxTest(img.load(ofToDataPath("indispensable.jpg", true)), "load from fs"); ofxTest(img.load("http://openframeworks.cc/about/0.jpg"), "load from http"); - // https://avatars.githubusercontent.com/u/48240?v=4 //ar - // https://avatars.githubusercontent.com/u/144000?v=4 //th - // https://avatars.githubusercontent.com/u/58289?v=4 //dm - // ofxTest(img.load("https://forum.openframeworks.cc/user_avatar/forum.openframeworks.cc/arturo/45/3965_1.png"), "load from https"); - ofxTest(img.load("https://avatars.githubusercontent.com/u/48240?v=4"), "load from https"); + ofxTest(img.load("https://forum.openframeworks.cc/user_avatar/forum.openframeworks.cc/arturo/45/3965_1.png"), "load from https"); } }; From 0b257b3209cb09e5f9e2869c346743fb25e58dae Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 26 Jan 2024 12:02:44 -0300 Subject: [PATCH 058/143] monitor callback fix --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 482728b97b6..d8a3d690c5e 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -70,7 +70,6 @@ void ofAppGLFWWindow::close() { glfwSetScrollCallback( windowP, nullptr ); glfwSetDropCallback( windowP, nullptr ); glfwSetWindowRefreshCallback(windowP, nullptr); - glfwSetMonitorCallback(monitor_cb); //hide the window before we destroy it stops a flicker on OS X on exit. glfwHideWindow(windowP); @@ -89,6 +88,7 @@ void ofAppGLFWWindow::close() { //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { + cout << "yes recompile OK" << endl; if (windowP) { ofLogError() << "window already setup, probably you are mixing old and new style setup"; ofLogError() << "call only ofCreateWindow(settings) or ofSetupOpenGL(...)"; @@ -270,6 +270,8 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } // setVerticalSync(true); + glfwSetMonitorCallback( monitor_cb ); + glfwSetMouseButtonCallback(windowP, mouse_cb); glfwSetCursorPosCallback(windowP, motion_cb); glfwSetCursorEnterCallback(windowP, entry_cb); @@ -1257,7 +1259,7 @@ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { //------------------------------------------------------------ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { -// cout << "monitor_cb!" << endl; + cout << "monitor_cb!" << endl; allMonitors.update(); } From c8fc8c04ca3b05acd5bcc51700c46b393fe35a35 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 27 Jan 2024 21:10:46 -0300 Subject: [PATCH 059/143] fix monitor --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 60 ++++++++++++++----- libs/openFrameworks/app/ofMainLoop.h | 3 + libs/openFrameworks/app/ofWindowSettings.h | 3 +- .../project.pbxproj | 4 ++ 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index d8a3d690c5e..f74d7739393 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -88,7 +88,7 @@ void ofAppGLFWWindow::close() { //------------------------------------------------------------ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { - cout << "yes recompile OK" << endl; +// cout << "yes recompile OK" << endl; if (windowP) { ofLogError() << "window already setup, probably you are mixing old and new style setup"; ofLogError() << "call only ofCreateWindow(settings) or ofSetupOpenGL(...)"; @@ -103,8 +103,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { return; } - allMonitors.update(); - // ofLogNotice("ofAppGLFWWindow") << "WINDOW MODE IS " << screenMode; glfwDefaultWindowHints(); glfwWindowHint(GLFW_RED_BITS, settings.redBits); @@ -158,6 +156,10 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { sharedContext = (GLFWwindow *)settings.shareContextWith->getWindowContext(); } + allMonitors.update(); + // ofLogNotice("ofAppGLFWWindow") << "WINDOW MODE IS " << screenMode; + + GLFWmonitor *monitor = nullptr; // FIXME: maybe use as a global variable for the window? @@ -175,29 +177,46 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { monitor = allMonitors.monitors[monitorIndex]; } + // MARK: - WINDOW - - glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); +// glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); // saves window rectangle just created. windowRect = getWindowRect(); + + cout << "------------------------------" << endl; + cout << "allMonitors.rects.size() " << allMonitors.rects.size() << endl; + cout << "settings.monitor " << settings.monitor << endl; + cout << "monitor window = " << monitorIndex << endl; + if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { + if (settings.isPositionSet()) { + windowRect.x = settings.getPosition().x; + windowRect.y = settings.getPosition().y; + } + if (monitorIndex > 0) { + cout << "before windowRect : " << windowRect << endl; windowRect.x += allMonitors.rects[monitorIndex].x; windowRect.y += allMonitors.rects[monitorIndex].y; + // now it will trigger isPositionSet() as true + settings.setPosition({ windowRect.x, windowRect.y }); + cout << "new windowRect : " << windowRect << endl; +// setWindowRect(windowRect); + + } + + if (settings.isPositionSet()) { + // windowRect.x = settings.getPosition().x; + // windowRect.y = settings.getPosition().y; setWindowRect(windowRect); + } else { + setWindowShape(windowRect.width, windowRect.height); } } - if (settings.isPositionSet()) { - windowRect.x = settings.getPosition().x; - windowRect.y = settings.getPosition().y; - setWindowRect(windowRect); - } else { - setWindowShape(windowRect.width, windowRect.height); - } if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; @@ -363,6 +382,7 @@ void ofAppGLFWWindow::update() { } glfwShowWindow(windowP); + cout << "after show window rect " << getWindowRect() << endl; } } @@ -781,8 +801,8 @@ static void rotateMouseXY(ofOrientation orientation, int w, int h, double & x, d //------------------------------------------------------------ ofAppGLFWWindow * ofAppGLFWWindow::setCurrent(GLFWwindow * windowP) { - ofAppGLFWWindow * instance = static_cast(glfwGetWindowUserPointer(windowP)); - shared_ptr mainLoop = ofGetMainLoop(); + auto instance = static_cast(glfwGetWindowUserPointer(windowP)); + auto mainLoop = ofGetMainLoop(); if (mainLoop) { mainLoop->setCurrentWindow(instance); } @@ -1261,6 +1281,18 @@ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { cout << "monitor_cb!" << endl; allMonitors.update(); + + for (auto & w : ofGetMainLoop()->getWindows()) { + if (w->settings.showOnlyInSelectedMonitor) { + if (allMonitors.rects.size() > w->settings.monitor) { + glfwShowWindow(((ofAppGLFWWindow*)&w)->windowP); + // TODO: set window to monitor + } else { + glfwHideWindow(((ofAppGLFWWindow*)&w)->windowP); + } + } + } +// ofGetMainLoop()->getWindows().size() } //------------------------------------------------------------ diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index bf23b505c82..a01d0b27841 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -50,6 +50,9 @@ class ofMainLoop { ofEvent loopEvent; std::thread::id get_thread_id() { return thread_id; }; + + // Testing + std::vector > getWindows() { return windows; } private: std::thread::id thread_id { std::this_thread::get_id() }; diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index 289f6a000e5..1fc6c8c164c 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -127,7 +127,8 @@ class ofWindowSettings { bool multiMonitorFullScreen = false; std::shared_ptr shareContextWith; std::vector fullscreenDisplays; - bool showInSelectedMonitor = false; + // FIXME: Define proper variable name + bool showOnlyInSelectedMonitor = false; protected: bool sizeSet { false }; diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index ee23f4d2f42..015801d27cc 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -853,6 +853,8 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS)"; + CLANG_X86_VECTOR_INSTRUCTIONS = default; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/local/lib; @@ -877,6 +879,8 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS)"; + CLANG_X86_VECTOR_INSTRUCTIONS = default; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/osx/"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = ""; From a905c6d7c5c7e8cc76b311a188285bb2e259bffb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 28 Jan 2024 13:17:40 -0300 Subject: [PATCH 060/143] ofGetElapsedTimef with chrono --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 101 +++++++++++++------- libs/openFrameworks/app/ofAppGLFWWindow.h | 3 + libs/openFrameworks/app/ofMainLoop.cpp | 2 +- libs/openFrameworks/app/ofWindowSettings.h | 1 + libs/openFrameworks/utils/ofUtils.cpp | 44 ++++++++- 5 files changed, 114 insertions(+), 37 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index f74d7739393..e0fa622bd10 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -54,10 +54,13 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ } ofAppGLFWWindow::~ofAppGLFWWindow() { + cout << "DISTRUKT! " << settings.windowName << endl; close(); } void ofAppGLFWWindow::close() { + cout << "ofAppGLFWWindow::close! " << settings.windowName << endl; + if (windowP) { glfwSetMouseButtonCallback( windowP, nullptr ); glfwSetCursorPosCallback( windowP, nullptr ); @@ -161,13 +164,19 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { GLFWmonitor *monitor = nullptr; + // FIXME: maybe use as a global variable for the window? + bool hideWindow = false; + int monitorIndex = 0; // Check to see if desired monitor is connected. if (allMonitors.rects.size() > settings.monitor) { monitorIndex = settings.monitor; } else { + if (settings.showOnlyInSelectedMonitor) { + hideWindow = true; + } ofLogError("ofAppGLFWWindow") << "requested monitor is: " << settings.monitor << " monitor count is: " << allMonitors.rects.size(); } @@ -179,17 +188,12 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { // MARK: - WINDOW -// glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); + glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); // saves window rectangle just created. windowRect = getWindowRect(); - - cout << "------------------------------" << endl; - cout << "allMonitors.rects.size() " << allMonitors.rects.size() << endl; - cout << "settings.monitor " << settings.monitor << endl; - cout << "monitor window = " << monitorIndex << endl; if (settings.windowMode == OF_WINDOW || settings.windowMode == OF_FULLSCREEN) { if (settings.isPositionSet()) { @@ -198,25 +202,18 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } if (monitorIndex > 0) { - cout << "before windowRect : " << windowRect << endl; windowRect.x += allMonitors.rects[monitorIndex].x; windowRect.y += allMonitors.rects[monitorIndex].y; // now it will trigger isPositionSet() as true settings.setPosition({ windowRect.x, windowRect.y }); - cout << "new windowRect : " << windowRect << endl; -// setWindowRect(windowRect); - } if (settings.isPositionSet()) { - // windowRect.x = settings.getPosition().x; - // windowRect.y = settings.getPosition().y; setWindowRect(windowRect); } else { setWindowShape(windowRect.width, windowRect.height); } } - if (!windowP) { ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; @@ -225,7 +222,6 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { // MARK: - - if (settings.windowMode != OF_GAME_MODE) { #ifdef TARGET_LINUX @@ -256,6 +252,10 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { //don't try and show a window if its been requsted to be hidden bWindowNeedsShowing = settings.visible; + if (hideWindow) { + bWindowNeedsShowing = false; +// cout << "HIDE U" << endl; + } glfwSetWindowUserPointer(windowP, this); glfwMakeContextCurrent(windowP); @@ -381,8 +381,14 @@ void ofAppGLFWWindow::update() { setFullscreen(false); } + // FIXME: Test only + if (settings.opacity != 1.0) { + glfwSetWindowOpacity(windowP, settings.opacity); + } + glfwShowWindow(windowP); - cout << "after show window rect " << getWindowRect() << endl; + +// cout << "after show window rect " << getWindowRect() << endl; } } @@ -810,6 +816,11 @@ ofAppGLFWWindow * ofAppGLFWWindow::setCurrent(GLFWwindow * windowP) { return instance; } +//------------------------------------------------------------ +ofAppGLFWWindow * ofAppGLFWWindow::getWindow(GLFWwindow * windowP) { + return static_cast(glfwGetWindowUserPointer(windowP)); +} + namespace { int glfwtToOFModifiers(int mods) { int modifiers = 0; @@ -971,7 +982,8 @@ unsigned long keycodeToUnicode(ofAppGLFWWindow * window, int scancode, int modif //------------------------------------------------------------ void ofAppGLFWWindow::mouse_cb(GLFWwindow * windowP_, int button, int state, int mods) { - ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); #ifdef TARGET_OSX //we do this as unlike glut, glfw doesn't report right click for ctrl click or middle click for alt click @@ -1014,7 +1026,8 @@ void ofAppGLFWWindow::mouse_cb(GLFWwindow * windowP_, int button, int state, int //------------------------------------------------------------ void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) { - ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y); ofMouseEventArgs::Type action; @@ -1034,7 +1047,9 @@ void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) { //------------------------------------------------------------ void ofAppGLFWWindow::entry_cb(GLFWwindow * windowP_, int entered) { - ofAppGLFWWindow * instance = setCurrent(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); + ofMouseEventArgs::Type action; if (entered) { action = ofMouseEventArgs::Entered; @@ -1052,7 +1067,8 @@ void ofAppGLFWWindow::entry_cb(GLFWwindow * windowP_, int entered) { //------------------------------------------------------------ void ofAppGLFWWindow::scroll_cb(GLFWwindow * windowP_, double x, double y) { - ofAppGLFWWindow * instance = setCurrent(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y); ofMouseEventArgs args(ofMouseEventArgs::Scrolled, @@ -1067,7 +1083,8 @@ void ofAppGLFWWindow::scroll_cb(GLFWwindow * windowP_, double x, double y) { //------------------------------------------------------------ void ofAppGLFWWindow::drop_cb(GLFWwindow * windowP_, int numFiles, const char ** dropString) { - ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); ofDragInfo drag; drag.position = { instance->events().getMouseX(), instance->events().getMouseY() }; drag.files.resize(numFiles); @@ -1086,7 +1103,9 @@ void ofAppGLFWWindow::error_cb(int errorCode, const char * errorDescription) { void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scancode, int action, int mods) { int key = 0; uint32_t codepoint = 0; - ofAppGLFWWindow * instance = setCurrent(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); + cout << "keyboard_cb " << instance->settings.windowName << endl; switch (keycode) { case GLFW_KEY_ESCAPE: key = OF_KEY_ESC; @@ -1267,28 +1286,37 @@ void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scanco //------------------------------------------------------------ void ofAppGLFWWindow::char_cb(GLFWwindow * windowP_, uint32_t key) { - ofAppGLFWWindow * instance = setCurrent(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); instance->events().charEvent.notify(key); } //------------------------------------------------------------ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { - ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); instance->draw(); +// thisWindow->draw(); } //------------------------------------------------------------ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { - cout << "monitor_cb!" << endl; allMonitors.update(); - +// cout << "monitor_cb!" << endl; +// cout << "monitors rect size: " << allMonitors.rects.size() << endl; + for (auto & w : ofGetMainLoop()->getWindows()) { if (w->settings.showOnlyInSelectedMonitor) { +// cout << "monitor_cb windowName " << w->settings.windowName << endl; + auto win = static_cast(w.get()); if (allMonitors.rects.size() > w->settings.monitor) { - glfwShowWindow(((ofAppGLFWWindow*)&w)->windowP); - // TODO: set window to monitor + if (w->settings.windowMode == OF_FULLSCREEN) { + w->setWindowRect(allMonitors.rects[w->settings.monitor]); + } + // TODO: set window to monitor, if it is windowed. + glfwShowWindow(win->getGLFWWindow()); } else { - glfwHideWindow(((ofAppGLFWWindow*)&w)->windowP); + glfwHideWindow(win->getGLFWWindow()); } } } @@ -1297,7 +1325,8 @@ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { //------------------------------------------------------------ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ - ofAppGLFWWindow * instance = setCurrent(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); // if (instance->settings.windowMode == OF_WINDOW) { // instance->windowRect.x = x; // instance->windowRect.y = y; @@ -1306,7 +1335,8 @@ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ } //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { - ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); instance->events().notifyWindowResized(w, h); // instance->nFramesSinceWindowResized = 0; @@ -1326,7 +1356,8 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { //------------------------------------------------------------ void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { // cout << "framebuffer_size_cb " << w << " : " << h << endl; - ofAppGLFWWindow * instance = setCurrent(windowP_); + auto instance = getWindow(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); instance->currentRenderer->clear(); instance->events().notifyFramebufferResized(w, h); @@ -1334,8 +1365,14 @@ void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { //-------------------------------------------- void ofAppGLFWWindow::exit_cb(GLFWwindow * windowP_) { - ofAppGLFWWindow * instance = setCurrent(windowP_); +// cout << "exit_cb " << endl; + auto instance = getWindow(windowP_); +// ofAppGLFWWindow * instance = setCurrent(windowP_); instance->events().notifyExit(); + + // TODO: handle window closing correctly here. +// instance->close(); +// instance->setWindowShouldClose(); } //------------------------------------------------------------ diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index df547bfe0b7..d69df84ca76 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -126,6 +126,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { private: static ofAppGLFWWindow * setCurrent(GLFWwindow* windowP); + static ofAppGLFWWindow * getWindow(GLFWwindow* windowP); static void mouse_cb(GLFWwindow* windowP_, int button, int state, int mods); static void motion_cb(GLFWwindow* windowP_, double x, double y); static void entry_cb(GLFWwindow* windowP_, int entered); @@ -171,6 +172,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { bool iconSet; +// static ofAppGLFWWindow * thisWindow = static_cast(this); + // window settings, this functions can only be called from main before calling ofSetupOpenGL // TODO: remove specialized version of ofSetupOpenGL when these go away [[deprecated("use ofGLFWWindowSettings to create the window")]] diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 996d014ca17..972bf8943c3 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -101,7 +101,7 @@ void ofMainLoop::run(const std::shared_ptr & window, std::share #endif } currentWindow = window; - window->makeCurrent(); +// window->makeCurrent(); if(!windowLoop){ window->events().notifySetup(); } diff --git a/libs/openFrameworks/app/ofWindowSettings.h b/libs/openFrameworks/app/ofWindowSettings.h index 1fc6c8c164c..8029eafbda2 100644 --- a/libs/openFrameworks/app/ofWindowSettings.h +++ b/libs/openFrameworks/app/ofWindowSettings.h @@ -129,6 +129,7 @@ class ofWindowSettings { std::vector fullscreenDisplays; // FIXME: Define proper variable name bool showOnlyInSelectedMonitor = false; + float opacity { 1.0 }; protected: bool sizeSet { false }; diff --git a/libs/openFrameworks/utils/ofUtils.cpp b/libs/openFrameworks/utils/ofUtils.cpp index 9a8bbd1ae07..6b3fc91b6ba 100644 --- a/libs/openFrameworks/utils/ofUtils.cpp +++ b/libs/openFrameworks/utils/ofUtils.cpp @@ -74,6 +74,35 @@ void endutils() { //#endif } +class timeCounterOF { +public: + time_point startTime; + typedef std::chrono::duration> duration; + + timeCounterOF() { + reset(); + } + + void reset() { + startTime = steady_clock::now(); + } + + std::chrono::duration getElapsedTime() { + return steady_clock::now() - startTime; + } + +// std::chrono::nanoseconds getElapsedTime() { +// return duration_cast(steady_clock::now() - startTime); +// } + + float getElapsedTimef() { + duration d = steady_clock::now() - startTime; + return d.count(); + } +} timeCounter; + + + class Clock { public: Clock() { @@ -307,22 +336,27 @@ ofTime ofGetCurrentTime() { //-------------------------------------- uint64_t ofGetElapsedTimeMillis() { - return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); + return std::chrono::duration_cast(of::priv::timeCounter.getElapsedTime()).count(); +// return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); } //-------------------------------------- uint64_t ofGetElapsedTimeMicros() { - return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); + return std::chrono::duration_cast(of::priv::timeCounter.getElapsedTime()).count(); +// return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); } //-------------------------------------- float ofGetElapsedTimef() { - return std::chrono::duration(of::priv::getClock().getElapsedTime()).count(); +// std::cout << of::priv::timeCounter.getElapsedTimef() << std::endl; + return of::priv::timeCounter.getElapsedTimef(); +// return std::chrono::duration(of::priv::getClock().getElapsedTime()).count(); } //-------------------------------------- void ofResetElapsedTimeCounter() { - of::priv::getClock().resetElapsedTimeCounter(); + of::priv::timeCounter.reset(); +// of::priv::getClock().resetElapsedTimeCounter(); } //-------------------------------------- @@ -1020,6 +1054,7 @@ std::string ofGetVersionPreRelease() { //from the forums http://www.openframeworks.cc/forum/viewtopic.php?t=1413 //-------------------------------------------------- +// FIXME: filesystem void ofSaveScreen(const string & filename) { /*ofImage screen; screen.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR); @@ -1031,6 +1066,7 @@ void ofSaveScreen(const string & filename) { } //-------------------------------------------------- +// FIXME: filesystem void ofSaveViewport(const string & filename) { // because ofSaveScreen doesn't related to viewports /*ofImage screen; From c721f7085490e9ec989df234607aae0a9c9b5f7d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 28 Jan 2024 14:19:31 -0300 Subject: [PATCH 061/143] testing glfw changes --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 10 +++++++++- libs/openFrameworks/app/ofMainLoop.cpp | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index e0fa622bd10..a1fd07416ad 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -818,7 +818,15 @@ ofAppGLFWWindow * ofAppGLFWWindow::setCurrent(GLFWwindow * windowP) { //------------------------------------------------------------ ofAppGLFWWindow * ofAppGLFWWindow::getWindow(GLFWwindow * windowP) { - return static_cast(glfwGetWindowUserPointer(windowP)); +// return static_cast(glfwGetWindowUserPointer(windowP)); + + auto instance = static_cast(glfwGetWindowUserPointer(windowP)); + auto mainLoop = ofGetMainLoop(); + if (mainLoop) { + mainLoop->setCurrentWindow(instance); + } + instance->makeCurrent(); + return instance; } namespace { diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 972bf8943c3..4f05abb2ea2 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -101,6 +101,8 @@ void ofMainLoop::run(const std::shared_ptr & window, std::share #endif } currentWindow = window; + + // FIXME: remove? // window->makeCurrent(); if(!windowLoop){ window->events().notifySetup(); From 1d52a7835bd4dca186740e8330e25b2af1684de8 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 1 Feb 2024 20:45:50 -0300 Subject: [PATCH 062/143] changes for rpi --- libs/openFrameworks/app/ofAppBaseWindow.h | 3 + libs/openFrameworks/app/ofAppGLFWWindow.cpp | 38 +++++++--- libs/openFrameworks/app/ofAppGLFWWindow.h | 3 + libs/openFrameworks/app/ofMainLoop.cpp | 72 ++++++++++++------- libs/openFrameworks/app/ofMainLoop.h | 7 ++ .../config.linuxaarch64.default.mk | 12 +++- 6 files changed, 101 insertions(+), 34 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 448e64a9a83..6166e507cbe 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -80,6 +80,9 @@ class ofAppBaseWindow { virtual void finishRender(){} virtual void * getWindowContext(){ return nullptr; } + + virtual void beginDraw(){} + virtual void endDraw(){} #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) virtual Display* getX11Display(){ return nullptr; } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index a1fd07416ad..48bdb8932b9 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -397,6 +397,28 @@ void ofAppGLFWWindow::pollEvents() { glfwPollEvents(); } + +//-------------------------------------------- +void ofAppGLFWWindow::beginDraw() { + currentRenderer->startRender(); + if (bEnableSetupScreen) { + currentRenderer->setupScreen(); + } +} + +//-------------------------------------------- +void ofAppGLFWWindow::endDraw() { + if (settings.doubleBuffering) { + glfwSwapBuffers(windowP); + // std::cout << "swap buffers " << ofGetFrameNum() << std::endl; + } else { + std::cout << "flush " << ofGetFrameNum() << " : " << settings.windowName << std::endl; + glFlush(); + } + + currentRenderer->finishRender(); +} + //-------------------------------------------- void ofAppGLFWWindow::draw() { currentRenderer->startRender(); @@ -818,15 +840,15 @@ ofAppGLFWWindow * ofAppGLFWWindow::setCurrent(GLFWwindow * windowP) { //------------------------------------------------------------ ofAppGLFWWindow * ofAppGLFWWindow::getWindow(GLFWwindow * windowP) { -// return static_cast(glfwGetWindowUserPointer(windowP)); + return static_cast(glfwGetWindowUserPointer(windowP)); - auto instance = static_cast(glfwGetWindowUserPointer(windowP)); - auto mainLoop = ofGetMainLoop(); - if (mainLoop) { - mainLoop->setCurrentWindow(instance); - } - instance->makeCurrent(); - return instance; +// auto instance = static_cast(glfwGetWindowUserPointer(windowP)); +// auto mainLoop = ofGetMainLoop(); +// if (mainLoop) { +// mainLoop->setCurrentWindow(instance); +// } +// instance->makeCurrent(); +// return instance; } namespace { diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index d69df84ca76..f4f8e97ba9f 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -172,6 +172,9 @@ class ofAppGLFWWindow : public ofAppBaseWindow { bool iconSet; + void beginDraw(); + void endDraw(); + // static ofAppGLFWWindow * thisWindow = static_cast(this); // window settings, this functions can only be called from main before calling ofSetupOpenGL diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 4f05abb2ea2..e9138ad388a 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -8,23 +8,31 @@ #include "ofMainLoop.h" #include "ofBaseApp.h" #include "ofConstants.h" +#include "ofAppBaseWindow.h" //======================================================================== // default windowing #ifdef TARGET_NODISPLAY #include "ofAppNoWindow.h" + typedef ofAppNoWindow ofWindow; #elif defined(TARGET_OF_IOS) #include "ofAppiOSWindow.h" + typedef ofAppiOSWindow ofWindow; + #elif defined(TARGET_ANDROID) #include "ofAppAndroidWindow.h" #include "ofxAndroidUtils.h" #include "ofxAndroidApp.h" -//#elif defined(TARGET_RASPBERRY_PI) + typedef ofAppAndroidWindow ofWindow; + +#elif defined(TARGET_RASPBERRY_PI) // #include "ofAppEGLWindow.h" #elif defined(TARGET_EMSCRIPTEN) #include "ofxAppEmscriptenWindow.h" + typedef ofxAppEmscriptenWindow ofWindow; #else #include "ofAppGLFWWindow.h" + typedef ofAppGLFWWindow ofWindow; #endif ofMainLoop::ofMainLoop() : bShouldClose(false), status(0), allowMultiWindow(true), escapeQuits(true) { @@ -35,25 +43,7 @@ ofMainLoop::~ofMainLoop() { } std::shared_ptr ofMainLoop::createWindow(const ofWindowSettings & settings){ -#ifdef TARGET_NODISPLAY - shared_ptr window { std::make_shared() }; -#else -#if defined(TARGET_OF_IOS) - std::shared_ptr window { std::make_shared() }; -#elif defined(TARGET_ANDROID) - std::shared_ptr window { std::make_shared() }; - #elif (defined(TARGET_RASPBERRY_PI) && defined(TARGET_GLFW_WINDOW)) - std::shared_ptr window { std::make_shared() }; -// #elif defined(TARGET_RASPBERRY_PI) -// std::shared_ptr window { std::make_shared() }; - #elif defined(TARGET_EMSCRIPTEN) - std::shared_ptr window { std::make_shared() }; - #elif defined(TARGET_OPENGLES) - std::shared_ptr window { std::make_shared() }; - #else - std::shared_ptr window { std::make_shared() }; - #endif -#endif + std::shared_ptr window { std::make_shared() }; addWindow(window); window->setup(settings); return window; @@ -136,18 +126,29 @@ void ofMainLoop::loopOnce(){ // std::cout << "ofMainLoop::loopOnce()" << std::endl; auto i = windows.begin(); + + currentWindow = (*i); + // here, not looping all windows + i->get()->makeCurrent(); + i->get()->update(); + i->get()->draw(); + for ( ; i != windows.end(); ) { if (i->get()->getWindowShouldClose()) { i = windows.erase(i); - } else { - currentWindow = (*i); - i->get()->makeCurrent(); - i->get()->update(); - i->get()->draw(); + } + else { +// currentWindow = (*i); +// i->get()->makeCurrent(); +// i->get()->update(); +// i->get()->draw(); ++i; } } + + + // for(auto i = windows.begin(); !windows.empty() && i != windows.end();){ // if(i->get()->getWindowShouldClose()){ //// const auto & window = i->first; @@ -307,3 +308,24 @@ void ofMainLoop::keyPressed(ofKeyEventArgs & key){ shouldClose(0); } } + +int thisWindow = 0; +void ofMainLoop::ofBeginWindow(int n) { + if (n < windows.size()) { + thisWindow = n; + currentWindow = windows[thisWindow]; + windows[thisWindow]->makeCurrent(); + windows[thisWindow]->update(); +// windows[n].draw(); + windows[thisWindow]->beginDraw(); + + } +// currentWindow.beginDraw(); +} + +void ofMainLoop::ofEndWindow() { + windows[thisWindow]->endDraw(); + thisWindow = 0; + currentWindow = windows[thisWindow]; + windows[thisWindow]->makeCurrent(); +} diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index a01d0b27841..602cbbf73fa 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -54,6 +54,11 @@ class ofMainLoop { // Testing std::vector > getWindows() { return windows; } + void ofBeginWindow(int n); + void ofEndWindow(); + + + private: std::thread::id thread_id { std::this_thread::get_id() }; @@ -70,4 +75,6 @@ class ofMainLoop { std::function windowLoop; std::function windowPollEvents; bool escapeQuits; + + }; diff --git a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk index d10f9885c78..cb84aa5a5de 100644 --- a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk +++ b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk @@ -42,9 +42,19 @@ PLATFORM_LDFLAGS += -lstdc++fs PLATFORM_LDFLAGS += -no-pie # PLATFORM_LDFLAGS += -nostartfiles +# -mcpu=cortex-a72 -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits PLATFORM_CFLAGS += -march=armv8-a PLATFORM_CFLAGS += -mcpu=cortex-a72 -PLATFORM_CFLAGS += -mtune=cortex-a72 + +# begin new tests +# PLATFORM_CFLAGS += -mtune=cortex-a72 +PLATFORM_CFLAGS += -mfloat-abi=hard +PLATFORM_CFLAGS += -mfpu=neon-fp-armv8 +PLATFORM_CFLAGS += -mneon-for-64bits + +# end new tests + + # PLATFORM_CFLAGS += -Wall # PLATFORM_CFLAGS += -Werror PLATFORM_CFLAGS += -fPIC From a43574144f521ad7a2f4c138fa9068cfc089cdac Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 1 Feb 2024 20:47:21 -0300 Subject: [PATCH 063/143] changes for rpi --- .../project/linuxaarch64/config.linuxaarch64.default.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk index cb84aa5a5de..f629a39a268 100644 --- a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk +++ b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk @@ -43,14 +43,14 @@ PLATFORM_LDFLAGS += -no-pie # PLATFORM_LDFLAGS += -nostartfiles # -mcpu=cortex-a72 -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits -PLATFORM_CFLAGS += -march=armv8-a +# PLATFORM_CFLAGS += -march=armv8-a PLATFORM_CFLAGS += -mcpu=cortex-a72 # begin new tests # PLATFORM_CFLAGS += -mtune=cortex-a72 -PLATFORM_CFLAGS += -mfloat-abi=hard -PLATFORM_CFLAGS += -mfpu=neon-fp-armv8 -PLATFORM_CFLAGS += -mneon-for-64bits +# PLATFORM_CFLAGS += -mfloat-abi=hard +# PLATFORM_CFLAGS += -mfpu=neon-fp-armv8 +# PLATFORM_CFLAGS += -mneon-for-64bits # end new tests From 904f852e88f6e6f1ec1c6d76700e4dd48433841d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 1 Feb 2024 23:09:43 -0300 Subject: [PATCH 064/143] some .h work --- libs/openFrameworks/app/ofAppBaseWindow.h | 2 +- libs/openFrameworks/app/ofMainLoop.cpp | 3 +- libs/openFrameworks/app/ofMainLoop.h | 2 +- libs/openFrameworks/gl/ofFbo.cpp | 13 +- libs/openFrameworks/gl/ofGLUtils.h | 2 +- libs/openFrameworks/gl/ofShader.cpp | 14 +- libs/openFrameworks/gl/ofTexture.h | 2 +- .../graphics/ofTrueTypeFont.cpp | 3 + libs/openFrameworks/sound/ofSoundStream.cpp | 16 +++ libs/openFrameworks/utils/ofConstants.h | 122 +++--------------- .../utils/ofRandomDistributions.h | 1 + .../video/ofAVFoundationGrabber.h | 2 - .../video/ofAVFoundationGrabber.mm | 2 - libs/openFrameworks/video/ofVideoGrabber.cpp | 65 ++++++++-- libs/openFrameworks/video/ofVideoPlayer.cpp | 32 +++++ scripts/osx/cc.sh | 2 +- 16 files changed, 147 insertions(+), 136 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 6166e507cbe..99826a03291 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -2,7 +2,7 @@ #include "ofWindowSettings.h" // MARK: Target -#include "ofConstants.h" +//#include "ofConstants.h" #include "ofRectangle.h" class ofBaseApp; diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index e9138ad388a..380383e9ae3 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -7,7 +7,8 @@ #include "ofMainLoop.h" #include "ofBaseApp.h" -#include "ofConstants.h" +// TEST WITHOUT +//#include "ofConstants.h" #include "ofAppBaseWindow.h" //======================================================================== diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index 602cbbf73fa..47ff34a9ab6 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -1,7 +1,7 @@ #pragma once #include "ofEvents.h" -#include +//#include class ofBaseApp; class ofAppBaseWindow; diff --git a/libs/openFrameworks/gl/ofFbo.cpp b/libs/openFrameworks/gl/ofFbo.cpp index 5d114de1aed..1215208e273 100644 --- a/libs/openFrameworks/gl/ofFbo.cpp +++ b/libs/openFrameworks/gl/ofFbo.cpp @@ -1,10 +1,13 @@ #include "ofFbo.h" -#include "ofAppRunner.h" -#include "ofUtils.h" -#include "ofGraphics.h" -#include "ofGLRenderer.h" +//#include "ofAppRunner.h" +//#include "ofUtils.h" +//#include "ofGraphics.h" + +#include "ofBufferObject.h" +#include "ofGLUtils.h" +#include "ofLog.h" // MARK: Targets -#include "ofConstants.h" +//#include "ofConstants.h" #include #ifdef TARGET_OPENGLES diff --git a/libs/openFrameworks/gl/ofGLUtils.h b/libs/openFrameworks/gl/ofGLUtils.h index a9882649c6f..0d4979048a7 100644 --- a/libs/openFrameworks/gl/ofGLUtils.h +++ b/libs/openFrameworks/gl/ofGLUtils.h @@ -9,7 +9,7 @@ #include "ofGraphicsConstants.h" // MARK: Targets / Defines -#include "ofConstants.h" +//#include "ofConstants.h" class ofShader; class ofGLProgrammableRenderer; diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 702fd711b61..b4524e07bd6 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -1,16 +1,16 @@ #include "ofBufferObject.h" #include "ofCubeMap.h" -#include "ofFileUtils.h" +//#include "ofFileUtils.h" #include "ofGLProgrammableRenderer.h" -#include "ofGraphics.h" +//#include "ofGraphics.h" #include "ofLight.h" -#include "ofMatrix3x3.h" -#include "ofMatrix4x4.h" -#include "ofParameter.h" +//#include "ofMatrix3x3.h" +//#include "ofMatrix4x4.h" +//#include "ofParameter.h" #include "ofShader.h" #include "ofShadow.h" -#include "ofTexture.h" -#include "ofUtils.h" +//#include "ofTexture.h" +//#include "ofUtils.h" #ifdef TARGET_ANDROID #include "ofxAndroidUtils.h" #endif diff --git a/libs/openFrameworks/gl/ofTexture.h b/libs/openFrameworks/gl/ofTexture.h index a7e74f256b4..d234e5ae8de 100644 --- a/libs/openFrameworks/gl/ofTexture.h +++ b/libs/openFrameworks/gl/ofTexture.h @@ -1,7 +1,7 @@ #pragma once #include "ofGraphicsBaseTypes.h" -// MARK: Targets, some can be moved to cpp +// MARK: Targets, some can be moved to cpp, GLEW also #include "ofConstants.h" #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL diff --git a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp index 20b49b89ae6..c127fe797ac 100644 --- a/libs/openFrameworks/graphics/ofTrueTypeFont.cpp +++ b/libs/openFrameworks/graphics/ofTrueTypeFont.cpp @@ -229,6 +229,9 @@ static ofPath makeContoursForCharacter(FT_Face face){ } #ifdef TARGET_OSX + +#include + //------------------------------------------------------------------ static string osxFontPathByName(const string& fontname){ CFStringRef targetName = CFStringCreateWithCString(nullptr, fontname.c_str(), kCFStringEncodingUTF8); diff --git a/libs/openFrameworks/sound/ofSoundStream.cpp b/libs/openFrameworks/sound/ofSoundStream.cpp index a3789987fb8..7f57f8225e5 100644 --- a/libs/openFrameworks/sound/ofSoundStream.cpp +++ b/libs/openFrameworks/sound/ofSoundStream.cpp @@ -2,6 +2,22 @@ #include "ofAppRunner.h" #include "ofLog.h" + +//------------------------------------------------ soundstream +// check if any soundstream api is defined from the compiler +#if !defined(OF_SOUNDSTREAM_RTAUDIO) && !defined(OF_SOUNDSTREAM_ANDROID) && !defined(OF_SOUNDSTREAM_IOS) && !defined(OF_SOUNDSTREAM_EMSCRIPTEN) + #if defined(TARGET_LINUX) || defined(TARGET_WIN32) || defined(TARGET_OSX) + #define OF_SOUNDSTREAM_RTAUDIO + #elif defined(TARGET_ANDROID) + #define OF_SOUNDSTREAM_ANDROID + #elif defined(TARGET_OF_IOS) + #define OF_SOUNDSTREAM_IOS + #elif defined(TARGET_EMSCRIPTEN) + #define OF_SOUNDSTREAM_EMSCRIPTEN + #endif +#endif + + #if defined(OF_SOUND_PLAYER_FMOD) #include "ofSoundPlayer.h" #include "ofFmodSoundPlayer.h" diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index 56c4dd81184..ac60edb8945 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -7,15 +7,15 @@ #define OF_VERSION_PRE_RELEASE "master" // core: --------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include // Set to 1 for compatibility with old projects using ofVec instead of glm #ifndef OF_USE_LEGACY_VECTOR_MATH @@ -98,25 +98,26 @@ enum ofTargetPlatform{ #endif #elif defined( __APPLE_CC__) #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 + #include + + #if (TARGET_OS_IPHONE || TARGET_OS_IOS || TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR) && !TARGET_OS_TV && !TARGET_OS_WATCH #define TARGET_OF_IPHONE #define TARGET_OF_IOS #define TARGET_OPENGLES - #include #elif TARGET_OS_TV #define TARGET_OF_IOS #define TARGET_OF_TVOS #define TARGET_OPENGLES - #include #elif TARGET_OS_WATCH #define TARGET_OF_IOS #define TARGET_OF_WATCHOS #define TARGET_OPENGLES - #include #else #define TARGET_OSX #endif + #include #elif defined (__ANDROID__) #define TARGET_ANDROID #define TARGET_OPENGLES @@ -191,9 +192,8 @@ enum ofTargetPlatform{ #ifndef __MACOSX_CORE__ #define __MACOSX_CORE__ #endif - #include #include "GL/glew.h" - #include +// #include #if defined(__LITTLE_ENDIAN__) #define TARGET_LITTLE_ENDIAN // intel cpu @@ -296,98 +296,6 @@ typedef TESSindex ofIndexType; -//------------------------------------------------ capture -// check if any video capture system is already defined from the compiler -#if !defined(OF_VIDEO_CAPTURE_GSTREAMER) && !defined(OF_VIDEO_CAPTURE_QUICKTIME) && !defined(OF_VIDEO_CAPTURE_DIRECTSHOW) && !defined(OF_VIDEO_CAPTURE_ANDROID) && !defined(OF_VIDEO_CAPTURE_IOS) - #ifdef TARGET_LINUX - - #define OF_VIDEO_CAPTURE_GSTREAMER - - #elif defined(TARGET_OSX) - //on 10.6 and below we can use the old grabber - #ifndef MAC_OS_X_VERSION_10_7 - #define OF_VIDEO_CAPTURE_QUICKTIME - //if we are below 10.12 or targeting below 10.12 we use QTKit - #elif !defined(MAC_OS_X_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 - #define OF_VIDEO_CAPTURE_QTKIT - #else - #define OF_VIDEO_CAPTURE_AVF - #endif - - #elif defined (TARGET_WIN32) - - // comment out this following line, if you'd like to use the - // quicktime capture interface on windows - // if not, we default to videoInput library for - // direct show capture... - - #define OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP - - #ifdef OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP - #define OF_VIDEO_CAPTURE_DIRECTSHOW - #else - #define OF_VIDEO_CAPTURE_QUICKTIME - #endif - - #elif defined(TARGET_ANDROID) - - #define OF_VIDEO_CAPTURE_ANDROID - - #elif defined(TARGET_EMSCRIPTEN) - - #define OF_VIDEO_CAPTURE_EMSCRIPTEN - - #elif defined(TARGET_OF_IOS) - - #define OF_VIDEO_CAPTURE_IOS - - #endif -#endif - -//------------------------------------------------ video player -// check if any video player system is already defined from the compiler -#if !defined(OF_VIDEO_PLAYER_GSTREAMER) && !defined(OF_VIDEO_PLAYER_IOS) && !defined(OF_VIDEO_PLAYER_DIRECTSHOW) && !defined(OF_VIDEO_PLAYER_MEDIA_FOUNDATION) && !defined(OF_VIDEO_PLAYER_QUICKTIME) && !defined(OF_VIDEO_PLAYER_AVFOUNDATION) && !defined(OF_VIDEO_PLAYER_EMSCRIPTEN) - #ifdef TARGET_LINUX - #define OF_VIDEO_PLAYER_GSTREAMER - #elif defined(TARGET_ANDROID) - #define OF_VIDEO_PLAYER_ANDROID - #elif defined(TARGET_OF_IOS) - #define OF_VIDEO_PLAYER_IOS - #elif defined(TARGET_WIN32) - #ifdef _MSC_VER //use MF Foundation player for VS as mingw doesn't have needed symbols - #define OF_VIDEO_PLAYER_MEDIA_FOUNDATION - #else - #define OF_VIDEO_PLAYER_DIRECTSHOW - #endif - #elif defined(TARGET_OSX) - //for 10.8 and 10.9 users we use AVFoundation, for 10.7 we use QTKit, for 10.6 users we use QuickTime - #ifndef MAC_OS_X_VERSION_10_7 - #define OF_VIDEO_PLAYER_QUICKTIME - #elif !defined(MAC_OS_X_VERSION_10_8) - #define OF_VIDEO_PLAYER_QTKIT - #else - #define OF_VIDEO_PLAYER_AVFOUNDATION - #endif - #elif defined(TARGET_EMSCRIPTEN) - #define OF_VIDEO_PLAYER_EMSCRIPTEN - #else - #define OF_VIDEO_PLAYER_QUICKTIME - #endif -#endif - -//------------------------------------------------ soundstream -// check if any soundstream api is defined from the compiler -#if !defined(OF_SOUNDSTREAM_RTAUDIO) && !defined(OF_SOUNDSTREAM_ANDROID) && !defined(OF_SOUNDSTREAM_IOS) && !defined(OF_SOUNDSTREAM_EMSCRIPTEN) - #if defined(TARGET_LINUX) || defined(TARGET_WIN32) || defined(TARGET_OSX) - #define OF_SOUNDSTREAM_RTAUDIO - #elif defined(TARGET_ANDROID) - #define OF_SOUNDSTREAM_ANDROID - #elif defined(TARGET_OF_IOS) - #define OF_SOUNDSTREAM_IOS - #elif defined(TARGET_EMSCRIPTEN) - #define OF_SOUNDSTREAM_EMSCRIPTEN - #endif -#endif #if (defined(_M_ARM64) || defined(_M_ARM64EC)) && defined(TARGET_WIN32) #undef USE_FMOD // No FMOD lib for ARM64 yet @@ -423,6 +331,8 @@ typedef TESSindex ofIndexType; #endif + +// Move to ofPath //------------------------------------------------ thread local storage // clang has a bug where it won't support tls on some versions even // on c++11, this is a workaround that bug diff --git a/libs/openFrameworks/utils/ofRandomDistributions.h b/libs/openFrameworks/utils/ofRandomDistributions.h index 6c60c07ca40..58730ff4b4f 100644 --- a/libs/openFrameworks/utils/ofRandomDistributions.h +++ b/libs/openFrameworks/utils/ofRandomDistributions.h @@ -2,6 +2,7 @@ #define OF_RANDOM_DISTRIBUTIONS_H_ #include "ofRandomEngine.h" +#include // https://gist.github.com/imneme/540829265469e673d045 // https://github.com/effolkronium/random/tree/master diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.h b/libs/openFrameworks/video/ofAVFoundationGrabber.h index b5b7a884174..e8f4eef4524 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.h +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.h @@ -6,7 +6,6 @@ #include "ofConstants.h" -#ifdef OF_VIDEO_CAPTURE_AVF //------ #include "ofVideoBaseTypes.h" @@ -120,4 +119,3 @@ class ofAVFoundationGrabber : virtual public ofBaseVideoGrabber{ }; -#endif diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.mm b/libs/openFrameworks/video/ofAVFoundationGrabber.mm index 47ed71330c9..db90f8eeef4 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.mm +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.mm @@ -7,7 +7,6 @@ #include "ofRectangle.h" #include "ofGLUtils.h" -#ifdef OF_VIDEO_CAPTURE_AVF #import @@ -537,4 +536,3 @@ - (void)eraseGrabberPtr { return pixelFormat; } -#endif diff --git a/libs/openFrameworks/video/ofVideoGrabber.cpp b/libs/openFrameworks/video/ofVideoGrabber.cpp index 6d903d8f77b..765ea2cb84c 100644 --- a/libs/openFrameworks/video/ofVideoGrabber.cpp +++ b/libs/openFrameworks/video/ofVideoGrabber.cpp @@ -5,20 +5,69 @@ #include "ofPixels.h" #include "ofConstants.h" +//------------------------------------------------ capture +// check if any video capture system is already defined from the compiler +#if !defined(OF_VIDEO_CAPTURE_GSTREAMER) && !defined(OF_VIDEO_CAPTURE_QUICKTIME) && !defined(OF_VIDEO_CAPTURE_DIRECTSHOW) && !defined(OF_VIDEO_CAPTURE_ANDROID) && !defined(OF_VIDEO_CAPTURE_IOS) + #ifdef TARGET_LINUX + + #define OF_VIDEO_CAPTURE_GSTREAMER + + #elif defined(TARGET_OSX) +// #include + + + #define OF_VIDEO_CAPTURE_AVF + + #elif defined (TARGET_WIN32) + + // comment out this following line, if you'd like to use the + // quicktime capture interface on windows + // if not, we default to videoInput library for + // direct show capture... + + #define OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP + + #ifdef OF_SWITCH_TO_DSHOW_FOR_WIN_VIDCAP + #define OF_VIDEO_CAPTURE_DIRECTSHOW + #else + #define OF_VIDEO_CAPTURE_QUICKTIME + #endif + + #elif defined(TARGET_ANDROID) + + #define OF_VIDEO_CAPTURE_ANDROID + + #elif defined(TARGET_EMSCRIPTEN) + + #define OF_VIDEO_CAPTURE_EMSCRIPTEN + + #elif defined(TARGET_OF_IOS) + + #define OF_VIDEO_CAPTURE_IOS + + #endif +#endif + + + +#ifdef TARGET_OF_OSX +#include +#endif + #ifdef OF_VIDEO_CAPTURE_IOS #include "ofxiOSVideoGrabber.h" #define OF_VID_GRABBER_TYPE ofxiOSVideoGrabber #endif -#ifdef OF_VIDEO_CAPTURE_QUICKTIME - #include "ofQuickTimeGrabber.h" - #define OF_VID_GRABBER_TYPE ofQuickTimeGrabber -#endif +//#ifdef OF_VIDEO_CAPTURE_QUICKTIME +// #include "ofQuickTimeGrabber.h" +// #define OF_VID_GRABBER_TYPE ofQuickTimeGrabber +//#endif -#ifdef OF_VIDEO_CAPTURE_QTKIT - #include "ofQTKitGrabber.h" - #define OF_VID_GRABBER_TYPE ofQTKitGrabber -#endif +//#ifdef OF_VIDEO_CAPTURE_QTKIT +// #include "ofQTKitGrabber.h" +// #define OF_VID_GRABBER_TYPE ofQTKitGrabber +//#endif #ifdef OF_VIDEO_CAPTURE_AVF #include "ofAVFoundationGrabber.h" diff --git a/libs/openFrameworks/video/ofVideoPlayer.cpp b/libs/openFrameworks/video/ofVideoPlayer.cpp index 7c9e18d9284..0619bfad986 100644 --- a/libs/openFrameworks/video/ofVideoPlayer.cpp +++ b/libs/openFrameworks/video/ofVideoPlayer.cpp @@ -9,6 +9,38 @@ using std::vector; using std::string; +//------------------------------------------------ video player +// check if any video player system is already defined from the compiler +#if !defined(OF_VIDEO_PLAYER_GSTREAMER) && !defined(OF_VIDEO_PLAYER_IOS) && !defined(OF_VIDEO_PLAYER_DIRECTSHOW) && !defined(OF_VIDEO_PLAYER_MEDIA_FOUNDATION) && !defined(OF_VIDEO_PLAYER_QUICKTIME) && !defined(OF_VIDEO_PLAYER_AVFOUNDATION) && !defined(OF_VIDEO_PLAYER_EMSCRIPTEN) + #ifdef TARGET_LINUX + #define OF_VIDEO_PLAYER_GSTREAMER + #elif defined(TARGET_ANDROID) + #define OF_VIDEO_PLAYER_ANDROID + #elif defined(TARGET_OF_IOS) + #define OF_VIDEO_PLAYER_IOS + #elif defined(TARGET_WIN32) + #ifdef _MSC_VER //use MF Foundation player for VS as mingw doesn't have needed symbols + #define OF_VIDEO_PLAYER_MEDIA_FOUNDATION + #else + #define OF_VIDEO_PLAYER_DIRECTSHOW + #endif + #elif defined(TARGET_OSX) + //for 10.8 and 10.9 users we use AVFoundation, for 10.7 we use QTKit, for 10.6 users we use QuickTime + #ifndef MAC_OS_X_VERSION_10_7 + #define OF_VIDEO_PLAYER_QUICKTIME + #elif !defined(MAC_OS_X_VERSION_10_8) + #define OF_VIDEO_PLAYER_QTKIT + #else + #define OF_VIDEO_PLAYER_AVFOUNDATION + #endif + #elif defined(TARGET_EMSCRIPTEN) + #define OF_VIDEO_PLAYER_EMSCRIPTEN + #else + #define OF_VIDEO_PLAYER_QUICKTIME + #endif +#endif + + #ifdef OF_VIDEO_PLAYER_GSTREAMER #include "ofGstVideoPlayer.h" #define OF_VID_PLAYER_TYPE ofGstVideoPlayer diff --git a/scripts/osx/cc.sh b/scripts/osx/cc.sh index e501e02aa68..4850029e0da 100755 --- a/scripts/osx/cc.sh +++ b/scripts/osx/cc.sh @@ -1,3 +1,3 @@ #!/bin/zsh -${ccache} clang "$@" +time ${ccache} clang "$@" # clang "$@" From 9a210145639c625e8c15dc7d772ba064f6bbbeb7 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 1 Feb 2024 23:15:05 -0300 Subject: [PATCH 065/143] revert vector --- libs/openFrameworks/utils/ofConstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index ac60edb8945..ad9b0d73eca 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -13,7 +13,7 @@ //#include //#include //#include -//#include +#include //#include //#include From fba537331d8103441ceadd31dc195f300c91a249 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 1 Feb 2024 23:29:06 -0300 Subject: [PATCH 066/143] includes back --- libs/openFrameworks/utils/ofConstants.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index ad9b0d73eca..f69b5531d6e 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -7,15 +7,15 @@ #define OF_VERSION_PRE_RELEASE "master" // core: --------------------------- -//#include -//#include -//#include -//#include -//#include -//#include +#include +#include +#include +#include +#include +#include #include -//#include -//#include +#include +#include // Set to 1 for compatibility with old projects using ofVec instead of glm #ifndef OF_USE_LEGACY_VECTOR_MATH From 5709d727b88811af4270a060b56a302e23ba50c3 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 16:20:54 -0300 Subject: [PATCH 067/143] rpi changes --- .../config.linuxaarch64.default.mk | 28 +++++------ .../project/makefileCommon/compile.core.mk | 47 +++++++++++++------ .../project/makefileCommon/compile.project.mk | 44 +++++++++++------ .../makefileCommon/config.linux.common.mk | 8 ++++ scripts/osx/cc.sh | 1 - 5 files changed, 80 insertions(+), 48 deletions(-) diff --git a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk index f629a39a268..40e08491f37 100644 --- a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk +++ b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk @@ -42,25 +42,15 @@ PLATFORM_LDFLAGS += -lstdc++fs PLATFORM_LDFLAGS += -no-pie # PLATFORM_LDFLAGS += -nostartfiles -# -mcpu=cortex-a72 -mfloat-abi=hard -mfpu=neon-fp-armv8 -mneon-for-64bits -# PLATFORM_CFLAGS += -march=armv8-a +PLATFORM_CFLAGS += -march=armv8-a PLATFORM_CFLAGS += -mcpu=cortex-a72 - -# begin new tests -# PLATFORM_CFLAGS += -mtune=cortex-a72 -# PLATFORM_CFLAGS += -mfloat-abi=hard -# PLATFORM_CFLAGS += -mfpu=neon-fp-armv8 -# PLATFORM_CFLAGS += -mneon-for-64bits - -# end new tests - - +PLATFORM_CFLAGS += -mtune=cortex-a72 # PLATFORM_CFLAGS += -Wall # PLATFORM_CFLAGS += -Werror -PLATFORM_CFLAGS += -fPIC -PLATFORM_CFLAGS += -ftree-vectorize -PLATFORM_CFLAGS += -Wno-psabi -PLATFORM_CFLAGS += -pipe +# PLATFORM_CFLAGS += -fPIC +# PLATFORM_CFLAGS += -ftree-vectorize +# PLATFORM_CFLAGS += -Wno-psabi +# PLATFORM_CFLAGS += -pipe ################################################################################ # PLATFORM LIBRARIES @@ -85,7 +75,11 @@ PLATFORM_PKG_CONFIG_LIBRARIES += glesv1_cm PLATFORM_PKG_CONFIG_LIBRARIES += glesv2 PLATFORM_PKG_CONFIG_LIBRARIES += egl - +## TEST +PLATFORM_PKG_CONFIG_LIBRARIES += gl +PLATFORM_PKG_CONFIG_LIBRARIES += glu +PLATFORM_PKG_CONFIG_LIBRARIES += glew +PLATFORM_LIBRARIES += glfw ################################################################################ # PLATFORM CORE EXCLUSIONS # During compilation, these makefiles will generate lists of sources, headers diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk index a23dd9897b2..d065807530c 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk @@ -36,9 +36,12 @@ else endif ifdef ${ccache} -$(info 💿 Using CCACHE - compile.core.mk ) - CXX := ${ccache} $(CXX) - CC := ${ccache} $(CXX) + $(info 💿 Using CCACHE - compile.core.mk ) + CXX := time ${ccache} $(CXX) + CC := time ${ccache} $(CXX) +# else + # CXX := time $(CXX) + # CC := time $(CXX) endif ################################################################################ @@ -142,7 +145,7 @@ ifeq ($(findstring Release,$(TARGET_NAME)),Release) endif ifeq ($(findstring Debug,$(TARGET_NAME)),Debug) - ifdef ABIS_TO_COMPILE_DEBUG + ifdef _DEBUG ifeq ($(findstring Release,$(TARGET_NAME)),Release) ifdef ABIS_TO_COMPILE_RELEASE ABIS_TO_COMPILE = $(filter-out $(ABIS_TO_COMPILE_DEBUG),$(ABIS_TO_COMPILE_RELEASE)) @@ -205,21 +208,35 @@ endif # avoid conflict with files of the same name and to improve performance. .PHONY: all Debug Release after clean CleanDebug CleanRelease help force +# USE_CORES=-j + +# ifeq ($(PLATFORM_ARCH),armv6l) +# USE_CORES=-j2 +# endif + +# ifeq ($(PLATFORM_ARCH),armv7l) +# USE_CORES=-j2 +# endif + +# ifeq ($(PLATFORM_ARCH),aarch64) +# USE_CORES=-j3 +# endif + Release: ifndef ABIS_TO_COMPILE_RELEASE - @$(MAKE) --no-print-directory ReleaseABI + @$(MAKE) $(USE_CORES) --no-print-directory ReleaseABI else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) --no-print-directory ReleaseABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) --no-print-directory ReleaseABI ABI=$(abi) &&) echo endif - @$(MAKE) --no-print-directory after + @$(MAKE) $(USE_CORES) --no-print-directory after Debug: ifndef ABIS_TO_COMPILE_DEBUG - @$(MAKE) --no-print-directory DebugABI + @$(MAKE) $(USE_CORES) --no-print-directory DebugABI else - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) --no-print-directory DebugABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) --no-print-directory DebugABI ABI=$(abi) &&) echo endif - @$(MAKE) --no-print-directory after + @$(MAKE) $(USE_CORES) --no-print-directory after # Release will pass the library name (i.e. ... libopenFrameworks.a) # down the the @(TARGET) target @@ -231,8 +248,8 @@ DebugABI: $(TARGET) # all will first run the debug target, then the release target all: - @$(MAKE) --no-print-directory Debug - @$(MAKE) --no-print-directory Release + @$(MAKE) $(USE_CORES) --no-print-directory Debug + @$(MAKE) $(USE_CORES) --no-print-directory Release $(OF_CORE_OBJ_OUTPUT_PATH).compiler_flags: force @mkdir -p $(OF_CORE_OBJ_OUTPUT_PATH) @@ -291,12 +308,12 @@ $(CLEANTARGET)ABI: $(CLEANTARGET): ifndef ABIS_TO_COMPILE - $(MAKE) --no-print-directory $(CLEANTARGET)ABI + $(MAKE) $(USE_CORES) --no-print-directory $(CLEANTARGET)ABI else ifeq ($(TARGET_NAME),Debug) - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done endif endif diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk index 1d17327d439..52c95ea315a 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk @@ -119,65 +119,79 @@ endif .PHONY: all Debug Release after clean CleanDebug CleanRelease help force +USE_CORES=-j + +ifeq ($(PLATFORM_ARCH),armv6l) + USE_CORES=-j2 +endif + +ifeq ($(PLATFORM_ARCH),armv7l) + USE_CORES=-j2 +endif + +ifeq ($(PLATFORM_ARCH),aarch64) + USE_CORES=-j3 +endif Release: @echo Compiling OF library for Release - @$(MAKE) -j -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Release PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_RELEASE="$(ABIS_TO_COMPILE_RELEASE)" + @echo $(MAKE) $(USE_CORES) -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Release PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_RELEASE="$(ABIS_TO_COMPILE_RELEASE)" + @$(MAKE) $(USE_CORES) -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Release PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_RELEASE="$(ABIS_TO_COMPILE_RELEASE)" @echo @echo @echo Compiling $(APPNAME) for Release ifndef ABIS_TO_COMPILE_RELEASE - @$(MAKE) -j ReleaseABI + @$(MAKE) $(USE_CORES) ReleaseABI else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) -j ReleaseABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) ReleaseABI ABI=$(abi) &&) echo endif Debug: @echo Compiling OF library for Debug - $(MAKE) -j -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Debug PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_DEBUG="$(ABIS_TO_COMPILE_DEBUG)" + $(MAKE) $(USE_CORES) -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Debug PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_DEBUG="$(ABIS_TO_COMPILE_DEBUG)" @echo @echo @echo Compiling $(APPNAME) for Debug ifndef ABIS_TO_COMPILE_DEBUG - @$(MAKE) -j DebugABI + @$(MAKE) $(USE_CORES) DebugABI else - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) DebugABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) DebugABI ABI=$(abi) &&) echo endif ReleaseNoOF: @echo Compiling $(APPNAME) for Release ifndef ABIS_TO_COMPILE_RELEASE - @$(MAKE) -j ReleaseABI + @$(MAKE) $(USE_CORES) ReleaseABI else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) ReleaseABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) ReleaseABI ABI=$(abi) &&) echo endif DebugNoOF: @echo Compiling $(APPNAME) for Debug ifndef ABIS_TO_COMPILE_DEBUG - @$(MAKE) -j DebugABI + @$(MAKE) $(USE_CORES) DebugABI else - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) DebugABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) DebugABI ABI=$(abi) &&) echo endif ReleaseABI: $(TARGET) ifneq ($(strip $(PROJECT_ADDONS_DATA)),) - @$(MAKE) -j copyaddonsdata PROJECT_ADDONS_DATA="$(PROJECT_ADDONS_DATA)" + @$(MAKE) $(USE_CORES) copyaddonsdata PROJECT_ADDONS_DATA="$(PROJECT_ADDONS_DATA)" endif - @$(MAKE) -j afterplatform BIN_NAME=$(BIN_NAME) ABIS_TO_COMPILE="$(ABIS_TO_COMPILE_RELEASE)" RUN_TARGET=$(RUN_TARGET) TARGET=$(TARGET) + @$(MAKE) $(USE_CORES) afterplatform BIN_NAME=$(BIN_NAME) ABIS_TO_COMPILE="$(ABIS_TO_COMPILE_RELEASE)" RUN_TARGET=$(RUN_TARGET) TARGET=$(TARGET) @$(PROJECT_AFTER) DebugABI: $(TARGET) ifneq ($(strip $(PROJECT_ADDONS_DATA)),) - @$(MAKE) -j copyaddonsdata PROJECT_ADDONS_DATA="$(PROJECT_ADDONS_DATA)" + @$(MAKE) $(USE_CORES) copyaddonsdata PROJECT_ADDONS_DATA="$(PROJECT_ADDONS_DATA)" endif - @$(MAKE) -j afterplatform BIN_NAME=$(BIN_NAME) ABIS_TO_COMPILE="$(ABIS_TO_COMPILE_DEBUG)" RUN_TARGET=$(RUN_TARGET) TARGET=$(TARGET) + @$(MAKE) $(USE_CORES) afterplatform BIN_NAME=$(BIN_NAME) ABIS_TO_COMPILE="$(ABIS_TO_COMPILE_DEBUG)" RUN_TARGET=$(RUN_TARGET) TARGET=$(TARGET) @$(PROJECT_AFTER) all: - $(MAKE) -j Debug + $(MAKE) $(USE_CORES) Debug run: ifeq ($(PLATFORM_RUN_COMMAND),) diff --git a/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk b/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk index 7614ab84347..3df9e015321 100755 --- a/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk @@ -22,6 +22,10 @@ ifeq ($(PLATFORM_ARCH),armv7l) LINUX_ARM=1 endif +ifeq ($(PLATFORM_ARCH),aarch64) + LINUX_ARM=1 +endif + #check if gtk exists and add it ifeq ($(CROSS_COMPILING),1) HAS_SYSTEM_GTK3 = $(shell export PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR);pkg-config gtk+-3.0 --exists; echo $$?) @@ -255,6 +259,7 @@ PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofMediaFoundati ifeq ($(LINUX_ARM),1) PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGlutWindow.cpp + PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp else PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp endif @@ -395,6 +400,9 @@ ifneq ($(LINUX_ARM),1) PLATFORM_PKG_CONFIG_LIBRARIES += gl PLATFORM_PKG_CONFIG_LIBRARIES += glu PLATFORM_PKG_CONFIG_LIBRARIES += glew +## TEST +else + PLATFORM_PKG_CONFIG_LIBRARIES += glew endif diff --git a/scripts/osx/cc.sh b/scripts/osx/cc.sh index 4850029e0da..aad224b38dc 100755 --- a/scripts/osx/cc.sh +++ b/scripts/osx/cc.sh @@ -1,3 +1,2 @@ #!/bin/zsh time ${ccache} clang "$@" -# clang "$@" From 9daf722ecac36e75c51526705c8cab75f3cf9639 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 17:13:34 -0300 Subject: [PATCH 068/143] rpi changes --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 356 ++++++++++---------- libs/openFrameworks/app/ofAppGLFWWindow.h | 22 +- 2 files changed, 189 insertions(+), 189 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 48bdb8932b9..49ea9d0a68f 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -14,11 +14,11 @@ #else #define GLFW_EXPOSE_NATIVE_EGL #endif - #include - #include - #include - #include - #include +// #include +// #include +// #include +// #include +// #include #elif defined(TARGET_OSX) #include #define GLFW_EXPOSE_NATIVE_COCOA @@ -225,18 +225,18 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { if (settings.windowMode != OF_GAME_MODE) { #ifdef TARGET_LINUX - if (!iconSet) { - ofPixels iconPixels; - // FIXME: we can have this define in ofIcon.h instead - #ifdef DEBUG - iconPixels.allocate(ofIconDebug.width, ofIconDebug.height, ofIconDebug.bytes_per_pixel); - GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(), ofIconDebug.rle_pixel_data, iconPixels.getWidth() * iconPixels.getHeight(), ofIconDebug.bytes_per_pixel); - #else - iconPixels.allocate(ofIcon.width, ofIcon.height, ofIcon.bytes_per_pixel); - GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(), ofIcon.rle_pixel_data, iconPixels.getWidth() * iconPixels.getHeight(), ofIcon.bytes_per_pixel); - #endif - setWindowIcon(iconPixels); - } +// if (!iconSet) { +// ofPixels iconPixels; +// // FIXME: we can have this define in ofIcon.h instead +// #ifdef DEBUG +// iconPixels.allocate(ofIconDebug.width, ofIconDebug.height, ofIconDebug.bytes_per_pixel); +// GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(), ofIconDebug.rle_pixel_data, iconPixels.getWidth() * iconPixels.getHeight(), ofIconDebug.bytes_per_pixel); +// #else +// iconPixels.allocate(ofIcon.width, ofIcon.height, ofIcon.bytes_per_pixel); +// GIMP_IMAGE_RUN_LENGTH_DECODE(iconPixels.getData(), ofIcon.rle_pixel_data, iconPixels.getWidth() * iconPixels.getHeight(), ofIcon.bytes_per_pixel); +// #endif +// setWindowIcon(iconPixels); +// } #endif //FIXME: check if it works with hint GLFW_AUTO_ICONIFY @@ -305,48 +305,48 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwSetWindowRefreshCallback(windowP, refresh_cb); #ifdef TARGET_LINUX - XSetLocaleModifiers(""); - xim = XOpenIM(getX11Display(), 0, 0, 0); - if (!xim) { - // fallback to internal input method - XSetLocaleModifiers("@im=none"); - xim = XOpenIM(getX11Display(), 0, 0, 0); - } - xic = XCreateIC(xim, - XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, getX11Window(), - XNFocusWindow, getX11Window(), - NULL); +// XSetLocaleModifiers(""); +// xim = XOpenIM(getX11Display(), 0, 0, 0); +// if (!xim) { +// // fallback to internal input method +// XSetLocaleModifiers("@im=none"); +// xim = XOpenIM(getX11Display(), 0, 0, 0); +// } +// xic = XCreateIC(xim, +// XNInputStyle, XIMPreeditNothing | XIMStatusNothing, +// XNClientWindow, getX11Window(), +// XNFocusWindow, getX11Window(), +// NULL); #endif } #ifdef TARGET_LINUX //------------------------------------------------------------ -void ofAppGLFWWindow::setWindowIcon(const of::filesystem::path & path) { - ofPixels iconPixels; - ofLoadImage(iconPixels, path); - setWindowIcon(iconPixels); -} - -//------------------------------------------------------------ -void ofAppGLFWWindow::setWindowIcon(const ofPixels & iconPixels) { - iconSet = true; - int length = 2 + iconPixels.getWidth() * iconPixels.getHeight(); - vector buffer(length); - buffer[0] = iconPixels.getWidth(); - buffer[1] = iconPixels.getHeight(); - for (size_t i = 0; i < iconPixels.getWidth() * iconPixels.getHeight(); i++) { - buffer[i + 2] = iconPixels[i * 4 + 3] << 24; - buffer[i + 2] += iconPixels[i * 4 + 0] << 16; - buffer[i + 2] += iconPixels[i * 4 + 1] << 8; - buffer[i + 2] += iconPixels[i * 4 + 2]; - } - - XChangeProperty(getX11Display(), getX11Window(), XInternAtom(getX11Display(), "_NET_WM_ICON", False), XA_CARDINAL, 32, - PropModeReplace, (const unsigned char *)buffer.data(), length); - XFlush(getX11Display()); -} +//void ofAppGLFWWindow::setWindowIcon(const of::filesystem::path & path) { +// ofPixels iconPixels; +// ofLoadImage(iconPixels, path); +// setWindowIcon(iconPixels); +//} +// +////------------------------------------------------------------ +//void ofAppGLFWWindow::setWindowIcon(const ofPixels & iconPixels) { +// iconSet = true; +// int length = 2 + iconPixels.getWidth() * iconPixels.getHeight(); +// vector buffer(length); +// buffer[0] = iconPixels.getWidth(); +// buffer[1] = iconPixels.getHeight(); +// for (size_t i = 0; i < iconPixels.getWidth() * iconPixels.getHeight(); i++) { +// buffer[i + 2] = iconPixels[i * 4 + 3] << 24; +// buffer[i + 2] += iconPixels[i * 4 + 0] << 16; +// buffer[i + 2] += iconPixels[i * 4 + 1] << 8; +// buffer[i + 2] += iconPixels[i * 4 + 2]; +// } +// +// XChangeProperty(getX11Display(), getX11Window(), XInternAtom(getX11Display(), "_NET_WM_ICON", False), XA_CARDINAL, 32, +// PropModeReplace, (const unsigned char *)buffer.data(), length); +// XFlush(getX11Display()); +//} #endif //-------------------------------------------- @@ -669,120 +669,120 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { #elif defined(TARGET_LINUX) - #include - - Window nativeWin = glfwGetX11Window(windowP); - Display * display = glfwGetX11Display(); - if (targetWindowMode == OF_FULLSCREEN) { - - // FIXME: Remove legacy code here - - int monitorCount; - GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); - if (settings.multiMonitorFullScreen && monitorCount > 1) { - // find the monitors at the edges of the virtual desktop - int minx = numeric_limits::max(); - int miny = numeric_limits::max(); - int maxx = numeric_limits::min(); - int maxy = numeric_limits::min(); - int x, y, w, h; - int monitorLeft = 0, monitorRight = 0, monitorTop = 0, monitorBottom = 0; - for (int i = 0; i < monitorCount; i++) { - glfwGetMonitorPos(monitors[i], &x, &y); - auto videoMode = glfwGetVideoMode(monitors[i]); - w = videoMode->width; - h = videoMode->height; - if (x < minx) { - monitorLeft = i; - minx = x; - } - if (y < miny) { - monitorTop = i; - miny = y; - } - if (x + w > maxx) { - monitorRight = i; - maxx = x + w; - } - if (y + h > maxy) { - monitorBottom = i; - maxy = y + h; - } - } - - // send fullscreen_monitors event with the edges monitors - Atom m_net_fullscreen_monitors = XInternAtom(display, "_NET_WM_FULLSCREEN_MONITORS", false); - - XEvent xev; - - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = nativeWin; - xev.xclient.message_type = m_net_fullscreen_monitors; - xev.xclient.format = 32; - - xev.xclient.data.l[0] = monitorTop; - xev.xclient.data.l[1] = monitorBottom; - xev.xclient.data.l[2] = monitorLeft; - xev.xclient.data.l[3] = monitorRight; - xev.xclient.data.l[4] = 1; - XSendEvent(display, RootWindow(display, DefaultScreen(display)), - False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); - - // FIXME: review - windowRect.width = maxx - minx; - windowRect.height = maxy - minx; -// currentW = maxx - minx; -// currentH = maxy - minx; - } else { - auto monitor = glfwGetWindowMonitor(windowP); - if (monitor) { - auto videoMode = glfwGetVideoMode(monitor); - if (videoMode) { - windowRect.width = videoMode->width; - windowRect.height = videoMode->height; -// currentW = videoMode->width; -// currentH = videoMode->height; - } - } - } - } - - // send fullscreen event - Atom m_net_state = XInternAtom(display, "_NET_WM_STATE", false); - Atom m_net_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", false); - - XEvent xev; - - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = nativeWin; - xev.xclient.message_type = m_net_state; - xev.xclient.format = 32; - - if (fullscreen) - xev.xclient.data.l[0] = 1; - else - xev.xclient.data.l[0] = 0; - - xev.xclient.data.l[1] = m_net_fullscreen; - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; - XSendEvent(display, RootWindow(display, DefaultScreen(display)), - False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); - - // tell the window manager to bypass composition for this window in fullscreen for speed - // it'll probably help solving vsync issues - Atom m_bypass_compositor = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); - unsigned long value = fullscreen ? 1 : 0; - XChangeProperty(display, nativeWin, m_bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&value, 1); - - XFlush(display); - - // setWindowShape(windowW, windowH); +// #include +// +// Window nativeWin = glfwGetX11Window(windowP); +// Display * display = glfwGetX11Display(); +// if (targetWindowMode == OF_FULLSCREEN) { +// +// // FIXME: Remove legacy code here +// +// int monitorCount; +// GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); +// if (settings.multiMonitorFullScreen && monitorCount > 1) { +// // find the monitors at the edges of the virtual desktop +// int minx = numeric_limits::max(); +// int miny = numeric_limits::max(); +// int maxx = numeric_limits::min(); +// int maxy = numeric_limits::min(); +// int x, y, w, h; +// int monitorLeft = 0, monitorRight = 0, monitorTop = 0, monitorBottom = 0; +// for (int i = 0; i < monitorCount; i++) { +// glfwGetMonitorPos(monitors[i], &x, &y); +// auto videoMode = glfwGetVideoMode(monitors[i]); +// w = videoMode->width; +// h = videoMode->height; +// if (x < minx) { +// monitorLeft = i; +// minx = x; +// } +// if (y < miny) { +// monitorTop = i; +// miny = y; +// } +// if (x + w > maxx) { +// monitorRight = i; +// maxx = x + w; +// } +// if (y + h > maxy) { +// monitorBottom = i; +// maxy = y + h; +// } +// } +// +// // send fullscreen_monitors event with the edges monitors +// Atom m_net_fullscreen_monitors = XInternAtom(display, "_NET_WM_FULLSCREEN_MONITORS", false); +// +// XEvent xev; +// +// xev.xclient.type = ClientMessage; +// xev.xclient.serial = 0; +// xev.xclient.send_event = True; +// xev.xclient.window = nativeWin; +// xev.xclient.message_type = m_net_fullscreen_monitors; +// xev.xclient.format = 32; +// +// xev.xclient.data.l[0] = monitorTop; +// xev.xclient.data.l[1] = monitorBottom; +// xev.xclient.data.l[2] = monitorLeft; +// xev.xclient.data.l[3] = monitorRight; +// xev.xclient.data.l[4] = 1; +// XSendEvent(display, RootWindow(display, DefaultScreen(display)), +// False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); +// +// // FIXME: review +// windowRect.width = maxx - minx; +// windowRect.height = maxy - minx; +//// currentW = maxx - minx; +//// currentH = maxy - minx; +// } else { +// auto monitor = glfwGetWindowMonitor(windowP); +// if (monitor) { +// auto videoMode = glfwGetVideoMode(monitor); +// if (videoMode) { +// windowRect.width = videoMode->width; +// windowRect.height = videoMode->height; +//// currentW = videoMode->width; +//// currentH = videoMode->height; +// } +// } +// } +// } +// +// // send fullscreen event +// Atom m_net_state = XInternAtom(display, "_NET_WM_STATE", false); +// Atom m_net_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", false); +// +// XEvent xev; +// +// xev.xclient.type = ClientMessage; +// xev.xclient.serial = 0; +// xev.xclient.send_event = True; +// xev.xclient.window = nativeWin; +// xev.xclient.message_type = m_net_state; +// xev.xclient.format = 32; +// +// if (fullscreen) +// xev.xclient.data.l[0] = 1; +// else +// xev.xclient.data.l[0] = 0; +// +// xev.xclient.data.l[1] = m_net_fullscreen; +// xev.xclient.data.l[2] = 0; +// xev.xclient.data.l[3] = 0; +// xev.xclient.data.l[4] = 0; +// XSendEvent(display, RootWindow(display, DefaultScreen(display)), +// False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); +// +// // tell the window manager to bypass composition for this window in fullscreen for speed +// // it'll probably help solving vsync issues +// Atom m_bypass_compositor = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); +// unsigned long value = fullscreen ? 1 : 0; +// XChangeProperty(display, nativeWin, m_bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&value, 1); +// +// XFlush(display); +// +// // setWindowShape(windowW, windowH); #endif settings.windowMode = targetWindowMode; @@ -1484,17 +1484,17 @@ void ofAppGLFWWindow::makeCurrent() { } #if defined(TARGET_LINUX) -Display * ofAppGLFWWindow::getX11Display() { - return glfwGetX11Display(); -} - -Window ofAppGLFWWindow::getX11Window() { - return glfwGetX11Window(windowP); -} - -XIC ofAppGLFWWindow::getX11XIC() { - return xic; -} +//Display * ofAppGLFWWindow::getX11Display() { +// return glfwGetX11Display(); +//} +// +//Window ofAppGLFWWindow::getX11Window() { +// return glfwGetX11Window(windowP); +//} +// +//XIC ofAppGLFWWindow::getX11XIC() { +// return xic; +//} #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index f4f8e97ba9f..486b42371cd 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -93,15 +93,15 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void iconify(bool bIconify); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) - typedef struct _XIM * XIM; - typedef struct _XIC * XIC; - - Display * getX11Display(); - Window getX11Window(); - XIC getX11XIC(); - - void setWindowIcon(const of::filesystem::path & path); - void setWindowIcon(const ofPixels & iconPixels); +// typedef struct _XIM * XIM; +// typedef struct _XIC * XIC; +// +// Display * getX11Display(); +// Window getX11Window(); +// XIC getX11XIC(); +// +// void setWindowIcon(const of::filesystem::path & path); +// void setWindowIcon(const ofPixels & iconPixels); #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) @@ -145,8 +145,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void close(); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) - XIM xim; - XIC xic; +// XIM xim; +// XIC xic; #endif std::unique_ptr coreEvents; From 752675038f35f13657ab747d7f8a7ad549683e85 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 17:14:34 -0300 Subject: [PATCH 069/143] rpi changes --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 6 +++--- libs/openFrameworks/app/ofAppGLFWWindow.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 49ea9d0a68f..47a818c1f3f 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1498,9 +1498,9 @@ void ofAppGLFWWindow::makeCurrent() { #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) -GLXContext ofAppGLFWWindow::getGLXContext() { - return glfwGetGLXContext(windowP); -} +//GLXContext ofAppGLFWWindow::getGLXContext() { +// return glfwGetGLXContext(windowP); +//} #endif #if defined(TARGET_LINUX) && defined(TARGET_OPENGLES) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 486b42371cd..8875584e86d 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -105,7 +105,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) - GLXContext getGLXContext(); +// GLXContext getGLXContext(); #endif #if defined(TARGET_LINUX) && defined(TARGET_OPENGLES) From a9f85e36b1c627c26fb6d79519cb82d38dfcbd0e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 17:16:28 -0300 Subject: [PATCH 070/143] rpi changes --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 68 ++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 47a818c1f3f..84ea4118047 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -871,40 +871,40 @@ int glfwtToOFModifiers(int mods) { unsigned long keycodeToUnicode(ofAppGLFWWindow * window, int scancode, int modifier) { #ifdef TARGET_LINUX - XkbStateRec xkb_state = {}; - XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); - XEvent ev = { 0 }; - ev.xkey.keycode = scancode; - ev.xkey.state = xkb_state.mods & ~ControlMask; - ev.xkey.display = window->getX11Display(); - ev.xkey.type = KeyPress; - KeySym keysym = NoSymbol; - int status; - char buffer[32] = { 0 }; - char * chars = buffer; - auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); - if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { - char ** c = &chars; - unsigned int ch = 0, count = 0; - static const unsigned int offsets[] = { - 0x00000000u, 0x00003080u, 0x000e2080u, - 0x03c82080u, 0xfa082080u, 0x82082080u - }; - - do { - ch = (ch << 6) + (unsigned char)**c; - (*c)++; - count++; - } while ((**c & 0xc0) == 0x80); - - if (count > 6) { - return 0; - } else { - return ch - offsets[count - 1]; - } - } else { - return 0; - } +// XkbStateRec xkb_state = {}; +// XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); +// XEvent ev = { 0 }; +// ev.xkey.keycode = scancode; +// ev.xkey.state = xkb_state.mods & ~ControlMask; +// ev.xkey.display = window->getX11Display(); +// ev.xkey.type = KeyPress; +// KeySym keysym = NoSymbol; +// int status; +// char buffer[32] = { 0 }; +// char * chars = buffer; +// auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); +// if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { +// char ** c = &chars; +// unsigned int ch = 0, count = 0; +// static const unsigned int offsets[] = { +// 0x00000000u, 0x00003080u, 0x000e2080u, +// 0x03c82080u, 0xfa082080u, 0x82082080u +// }; +// +// do { +// ch = (ch << 6) + (unsigned char)**c; +// (*c)++; +// count++; +// } while ((**c & 0xc0) == 0x80); +// +// if (count > 6) { +// return 0; +// } else { +// return ch - offsets[count - 1]; +// } +// } else { +// return 0; +// } #endif #ifdef TARGET_WIN32 static WCHAR buf[2]; From ce2c1c59034e4ae7a6dcbdd08acd3a612d11090e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 17:30:31 -0300 Subject: [PATCH 071/143] revert keyboard back --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 68 ++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 84ea4118047..47a818c1f3f 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -871,40 +871,40 @@ int glfwtToOFModifiers(int mods) { unsigned long keycodeToUnicode(ofAppGLFWWindow * window, int scancode, int modifier) { #ifdef TARGET_LINUX -// XkbStateRec xkb_state = {}; -// XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); -// XEvent ev = { 0 }; -// ev.xkey.keycode = scancode; -// ev.xkey.state = xkb_state.mods & ~ControlMask; -// ev.xkey.display = window->getX11Display(); -// ev.xkey.type = KeyPress; -// KeySym keysym = NoSymbol; -// int status; -// char buffer[32] = { 0 }; -// char * chars = buffer; -// auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); -// if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { -// char ** c = &chars; -// unsigned int ch = 0, count = 0; -// static const unsigned int offsets[] = { -// 0x00000000u, 0x00003080u, 0x000e2080u, -// 0x03c82080u, 0xfa082080u, 0x82082080u -// }; -// -// do { -// ch = (ch << 6) + (unsigned char)**c; -// (*c)++; -// count++; -// } while ((**c & 0xc0) == 0x80); -// -// if (count > 6) { -// return 0; -// } else { -// return ch - offsets[count - 1]; -// } -// } else { -// return 0; -// } + XkbStateRec xkb_state = {}; + XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); + XEvent ev = { 0 }; + ev.xkey.keycode = scancode; + ev.xkey.state = xkb_state.mods & ~ControlMask; + ev.xkey.display = window->getX11Display(); + ev.xkey.type = KeyPress; + KeySym keysym = NoSymbol; + int status; + char buffer[32] = { 0 }; + char * chars = buffer; + auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); + if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { + char ** c = &chars; + unsigned int ch = 0, count = 0; + static const unsigned int offsets[] = { + 0x00000000u, 0x00003080u, 0x000e2080u, + 0x03c82080u, 0xfa082080u, 0x82082080u + }; + + do { + ch = (ch << 6) + (unsigned char)**c; + (*c)++; + count++; + } while ((**c & 0xc0) == 0x80); + + if (count > 6) { + return 0; + } else { + return ch - offsets[count - 1]; + } + } else { + return 0; + } #endif #ifdef TARGET_WIN32 static WCHAR buf[2]; From 7b61d1584ca826fcc572f4aeb1df7c2b4f91e79d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 17:40:43 -0300 Subject: [PATCH 072/143] kb --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 73 +++++++++++---------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 47a818c1f3f..483234e73f1 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -14,7 +14,7 @@ #else #define GLFW_EXPOSE_NATIVE_EGL #endif -// #include + #include // #include // #include // #include @@ -871,40 +871,40 @@ int glfwtToOFModifiers(int mods) { unsigned long keycodeToUnicode(ofAppGLFWWindow * window, int scancode, int modifier) { #ifdef TARGET_LINUX - XkbStateRec xkb_state = {}; - XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); - XEvent ev = { 0 }; - ev.xkey.keycode = scancode; - ev.xkey.state = xkb_state.mods & ~ControlMask; - ev.xkey.display = window->getX11Display(); - ev.xkey.type = KeyPress; - KeySym keysym = NoSymbol; - int status; - char buffer[32] = { 0 }; - char * chars = buffer; - auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); - if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { - char ** c = &chars; - unsigned int ch = 0, count = 0; - static const unsigned int offsets[] = { - 0x00000000u, 0x00003080u, 0x000e2080u, - 0x03c82080u, 0xfa082080u, 0x82082080u - }; - - do { - ch = (ch << 6) + (unsigned char)**c; - (*c)++; - count++; - } while ((**c & 0xc0) == 0x80); - - if (count > 6) { - return 0; - } else { - return ch - offsets[count - 1]; - } - } else { - return 0; - } +// XkbStateRec xkb_state = {}; +// XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); +// XEvent ev = { 0 }; +// ev.xkey.keycode = scancode; +// ev.xkey.state = xkb_state.mods & ~ControlMask; +// ev.xkey.display = window->getX11Display(); +// ev.xkey.type = KeyPress; +// KeySym keysym = NoSymbol; +// int status; +// char buffer[32] = { 0 }; +// char * chars = buffer; +// auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); +// if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { +// char ** c = &chars; +// unsigned int ch = 0, count = 0; +// static const unsigned int offsets[] = { +// 0x00000000u, 0x00003080u, 0x000e2080u, +// 0x03c82080u, 0xfa082080u, 0x82082080u +// }; +// +// do { +// ch = (ch << 6) + (unsigned char)**c; +// (*c)++; +// count++; +// } while ((**c & 0xc0) == 0x80); +// +// if (count > 6) { +// return 0; +// } else { +// return ch - offsets[count - 1]; +// } +// } else { +// return 0; +// } #endif #ifdef TARGET_WIN32 static WCHAR buf[2]; @@ -1294,7 +1294,8 @@ void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scanco key = codepoint = '='; break; default: - codepoint = keycodeToUnicode(instance, scancode, mods); +// codepoint = keycodeToUnicode(instance, scancode, mods); + codepoint = scancode; key = codepoint; break; } From f0f5bd2af9fbe3a9c019bec9346c1e9e2c885cd6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 20:02:51 -0300 Subject: [PATCH 073/143] kbd --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 68 ++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 483234e73f1..e986e6f7d8c 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -871,40 +871,40 @@ int glfwtToOFModifiers(int mods) { unsigned long keycodeToUnicode(ofAppGLFWWindow * window, int scancode, int modifier) { #ifdef TARGET_LINUX -// XkbStateRec xkb_state = {}; -// XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); -// XEvent ev = { 0 }; -// ev.xkey.keycode = scancode; -// ev.xkey.state = xkb_state.mods & ~ControlMask; -// ev.xkey.display = window->getX11Display(); -// ev.xkey.type = KeyPress; -// KeySym keysym = NoSymbol; -// int status; -// char buffer[32] = { 0 }; -// char * chars = buffer; -// auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); -// if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { -// char ** c = &chars; -// unsigned int ch = 0, count = 0; -// static const unsigned int offsets[] = { -// 0x00000000u, 0x00003080u, 0x000e2080u, -// 0x03c82080u, 0xfa082080u, 0x82082080u -// }; -// -// do { -// ch = (ch << 6) + (unsigned char)**c; -// (*c)++; -// count++; -// } while ((**c & 0xc0) == 0x80); -// -// if (count > 6) { -// return 0; -// } else { -// return ch - offsets[count - 1]; -// } -// } else { -// return 0; -// } + XkbStateRec xkb_state = {}; + XkbGetState(window->getX11Display(), XkbUseCoreKbd, &xkb_state); + XEvent ev = { 0 }; + ev.xkey.keycode = scancode; + ev.xkey.state = xkb_state.mods & ~ControlMask; + ev.xkey.display = window->getX11Display(); + ev.xkey.type = KeyPress; + KeySym keysym = NoSymbol; + int status; + char buffer[32] = { 0 }; + char * chars = buffer; + auto count = Xutf8LookupString(window->getX11XIC(), &ev.xkey, chars, sizeof(buffer) - 1, &keysym, &status); + if ((count > 0 && (status == XLookupChars || status == XLookupBoth)) || status == XLookupKeySym) { + char ** c = &chars; + unsigned int ch = 0, count = 0; + static const unsigned int offsets[] = { + 0x00000000u, 0x00003080u, 0x000e2080u, + 0x03c82080u, 0xfa082080u, 0x82082080u + }; + + do { + ch = (ch << 6) + (unsigned char)**c; + (*c)++; + count++; + } while ((**c & 0xc0) == 0x80); + + if (count > 6) { + return 0; + } else { + return ch - offsets[count - 1]; + } + } else { + return 0; + } #endif #ifdef TARGET_WIN32 static WCHAR buf[2]; From c45739c820404ec053ca8f7d45846b8583342d2b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 20:07:04 -0300 Subject: [PATCH 074/143] kbd --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 22 ++++++++++----------- libs/openFrameworks/app/ofAppGLFWWindow.h | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index e986e6f7d8c..cc93c569fe9 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1485,17 +1485,17 @@ void ofAppGLFWWindow::makeCurrent() { } #if defined(TARGET_LINUX) -//Display * ofAppGLFWWindow::getX11Display() { -// return glfwGetX11Display(); -//} -// -//Window ofAppGLFWWindow::getX11Window() { -// return glfwGetX11Window(windowP); -//} -// -//XIC ofAppGLFWWindow::getX11XIC() { -// return xic; -//} +Display * ofAppGLFWWindow::getX11Display() { + return glfwGetX11Display(); +} + +Window ofAppGLFWWindow::getX11Window() { + return glfwGetX11Window(windowP); +} + +XIC ofAppGLFWWindow::getX11XIC() { + return xic; +} #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 8875584e86d..573293a2f86 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -96,9 +96,9 @@ class ofAppGLFWWindow : public ofAppBaseWindow { // typedef struct _XIM * XIM; // typedef struct _XIC * XIC; // -// Display * getX11Display(); -// Window getX11Window(); -// XIC getX11XIC(); + Display * getX11Display(); + Window getX11Window(); + XIC getX11XIC(); // // void setWindowIcon(const of::filesystem::path & path); // void setWindowIcon(const ofPixels & iconPixels); From bc5f1a13ae4f1fc441f6e3751dbaa7692997fa63 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 20:13:28 -0300 Subject: [PATCH 075/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 573293a2f86..2528ea89b63 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -93,9 +93,9 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void iconify(bool bIconify); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) -// typedef struct _XIM * XIM; -// typedef struct _XIC * XIC; -// + typedef struct _XIM * XIM; + typedef struct _XIC * XIC; + Display * getX11Display(); Window getX11Window(); XIC getX11XIC(); @@ -145,8 +145,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { void close(); #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) -// XIM xim; -// XIC xic; + XIM xim; + XIC xic; #endif std::unique_ptr coreEvents; From 7053980edfad89380fbad2761a688f3be865cdcf Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sat, 3 Feb 2024 20:14:22 -0300 Subject: [PATCH 076/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index cc93c569fe9..bc6ae0b2ebe 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -15,10 +15,12 @@ #define GLFW_EXPOSE_NATIVE_EGL #endif #include -// #include -// #include -// #include -// #include + #include + #include + #include + #include + + #elif defined(TARGET_OSX) #include #define GLFW_EXPOSE_NATIVE_COCOA From c3d364d3b58f78e7201b89b76ae6fb85bbe4cc6e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 5 Feb 2024 16:25:09 -0300 Subject: [PATCH 077/143] fix conflicts --- libs/openFrameworks/utils/ofConstants.h | 4 ---- libs/openFrameworks/video/ofAVFoundationGrabber.h | 4 ---- libs/openFrameworks/video/ofAVFoundationGrabber.mm | 4 ---- 3 files changed, 12 deletions(-) diff --git a/libs/openFrameworks/utils/ofConstants.h b/libs/openFrameworks/utils/ofConstants.h index bdf5026473c..298e7937917 100644 --- a/libs/openFrameworks/utils/ofConstants.h +++ b/libs/openFrameworks/utils/ofConstants.h @@ -296,10 +296,6 @@ typedef TESSindex ofIndexType; -<<<<<<< HEAD - -======= ->>>>>>> origin #if (defined(_M_ARM64) || defined(_M_ARM64EC)) && defined(TARGET_WIN32) #undef USE_FMOD // No FMOD lib for ARM64 yet #define OF_NO_FMOD diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.h b/libs/openFrameworks/video/ofAVFoundationGrabber.h index 610de78810d..d321004db67 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.h +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.h @@ -116,7 +116,3 @@ class ofAVFoundationGrabber : virtual public ofBaseVideoGrabber{ std::mutex capMutex; }; -<<<<<<< HEAD - -======= ->>>>>>> origin diff --git a/libs/openFrameworks/video/ofAVFoundationGrabber.mm b/libs/openFrameworks/video/ofAVFoundationGrabber.mm index 7f81a0e00a5..bd1ec65d6dd 100644 --- a/libs/openFrameworks/video/ofAVFoundationGrabber.mm +++ b/libs/openFrameworks/video/ofAVFoundationGrabber.mm @@ -534,7 +534,3 @@ - (void)eraseGrabberPtr { ofPixelFormat ofAVFoundationGrabber::getPixelFormat() const{ return pixelFormat; } -<<<<<<< HEAD - -======= ->>>>>>> origin From 4098a8e43d61b9c5fdb82231a853f2065de2bc22 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 5 Feb 2024 16:34:07 -0300 Subject: [PATCH 078/143] .mk --- .../project/makefileCommon/compile.core.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk index d065807530c..bd635fec55a 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk @@ -36,12 +36,12 @@ else endif ifdef ${ccache} - $(info 💿 Using CCACHE - compile.core.mk ) +$(info 💿 Using CCACHE - compile.core.mk ) CXX := time ${ccache} $(CXX) CC := time ${ccache} $(CXX) # else - # CXX := time $(CXX) - # CC := time $(CXX) +# CXX := time $(CXX) +# CC := time $(CXX) endif ################################################################################ From 994f35af7b80d25e20a6db3c44edb8281331a7bd Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 5 Feb 2024 17:03:05 -0300 Subject: [PATCH 079/143] updates --- libs/openFrameworks/app/ofAppBaseWindow.h | 2 +- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 99826a03291..6166e507cbe 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -2,7 +2,7 @@ #include "ofWindowSettings.h" // MARK: Target -//#include "ofConstants.h" +#include "ofConstants.h" #include "ofRectangle.h" class ofBaseApp; diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index cd47cbd1f56..409f361c5a7 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -388,6 +388,7 @@ void ofAppGLFWWindow::update() { glfwSetWindowOpacity(windowP, settings.opacity); } + cout << "SHOW WINDOW! " << settings.windowName << endl; glfwShowWindow(windowP); // cout << "after show window rect " << getWindowRect() << endl; @@ -500,6 +501,7 @@ glm::ivec2 ofAppGLFWWindow::getFramebufferSize() { // FIXME: cache size and handle in framebuffer_size_cb glm::ivec2 size; glfwGetFramebufferSize(windowP, &size.x, &size.y); +// cout << "getFramebufferSize " << settings.windowName << " : " << size << " : " << ofGetFrameNum() << endl; return size; } @@ -590,6 +592,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { if (settings.fullscreenDisplays.size()) { windowRectFS = allMonitors.getRectFromMonitors(settings.fullscreenDisplays); } + cout << "windowRectFS " << windowRectFS << " : " << settings.windowName << endl; setWindowRect(windowRectFS); } @@ -601,7 +604,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { -// cout << "setFullScreen " << fullscreen << endl; + cout << "setFullScreen " << fullscreen << " : " << settings.windowName << endl; if (fullscreen) { targetWindowMode = OF_FULLSCREEN; } else { @@ -1373,6 +1376,7 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { instance->events().notifyWindowResized(w, h); // instance->nFramesSinceWindowResized = 0; + #if defined(TARGET_OSX) if (!instance->bWindowNeedsShowing) { // FIXME - only after first update From 608ee96d6d3d9f95aeb3a024d6825a27e0555b88 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 7 Feb 2024 07:31:02 -0300 Subject: [PATCH 080/143] fix rpi --- libs/openFrameworks/app/ofMainLoop.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 380383e9ae3..5a2fdd1a252 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -16,17 +16,20 @@ #ifdef TARGET_NODISPLAY #include "ofAppNoWindow.h" typedef ofAppNoWindow ofWindow; + #elif defined(TARGET_OF_IOS) #include "ofAppiOSWindow.h" typedef ofAppiOSWindow ofWindow; + #elif defined(TARGET_ANDROID) #include "ofAppAndroidWindow.h" #include "ofxAndroidUtils.h" #include "ofxAndroidApp.h" typedef ofAppAndroidWindow ofWindow; -#elif defined(TARGET_RASPBERRY_PI) +// Raspi removed to use GLFW +//#elif defined(TARGET_RASPBERRY_PI) // #include "ofAppEGLWindow.h" #elif defined(TARGET_EMSCRIPTEN) #include "ofxAppEmscriptenWindow.h" From 9c451bb8f9bf865c3523dc92f38a848c1474253c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 12 Feb 2024 11:38:55 -0300 Subject: [PATCH 081/143] up test --- apps/d/A3/addons.make | 2 + apps/d/A3/bin/.DS_Store | Bin 0 -> 6148 bytes apps/d/A3/bin/data/.DS_Store | Bin 0 -> 6148 bytes apps/d/A3/bin/data/.gitkeep | 0 apps/d/A3/of.yml | 15 +++ apps/d/A3/src/.DS_Store | Bin 0 -> 6148 bytes apps/d/A3/src/main.cpp | 46 +++++++++ apps/d/A3/src/ofApp.cpp | 192 +++++++++++++++++++++++++++++++++++ apps/d/A3/src/ofApp.h | 104 +++++++++++++++++++ apps/d/A3/src/structs.h | 113 +++++++++++++++++++++ 10 files changed, 472 insertions(+) create mode 100644 apps/d/A3/addons.make create mode 100644 apps/d/A3/bin/.DS_Store create mode 100644 apps/d/A3/bin/data/.DS_Store create mode 100644 apps/d/A3/bin/data/.gitkeep create mode 100644 apps/d/A3/of.yml create mode 100644 apps/d/A3/src/.DS_Store create mode 100644 apps/d/A3/src/main.cpp create mode 100644 apps/d/A3/src/ofApp.cpp create mode 100644 apps/d/A3/src/ofApp.h create mode 100644 apps/d/A3/src/structs.h diff --git a/apps/d/A3/addons.make b/apps/d/A3/addons.make new file mode 100644 index 00000000000..01d5713d190 --- /dev/null +++ b/apps/d/A3/addons.make @@ -0,0 +1,2 @@ +ofxMicroUI +ofxTools diff --git a/apps/d/A3/bin/.DS_Store b/apps/d/A3/bin/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ca338d99c01cd11c5316737fba3c2ee9aa44299f GIT binary patch literal 6148 zcmeHKJ5Iwu5S;}VmS|E^?iF%_B{C;SK}&)qC}KGU^zOI}2jBuxZbMJUn-5VUVLy?d1vN%?N@j_B9azQ?ObFgA~jr5o^=_U=G8}b7Lf{=^d6i0`SPyswxi1FfO0Eo zWhIZY`htJRb$!#UH~kv*_1pXY_2p)FbO!Le HzoEbfI(92~ literal 0 HcmV?d00001 diff --git a/apps/d/A3/bin/data/.DS_Store b/apps/d/A3/bin/data/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0() }; + auto window { ofCreateWindow(settings) }; + + +#define SECOND +#ifdef SECOND + settings.windowName = "second"; + settings.shareContextWith = window; + + settings.setPosition({ 600, 600 }); + settings.setSize(1200, 300); + +// settings.doubleBuffering = true; +// settings.windowMode = OF_FULLSCREEN; +// settings.monitor = 1; +// settings.windowMode = OF_GAME_MODE; +// settings.fullscreenDisplays = { 1, 2, 3 }; + settings.showOnlyInSelectedMonitor = true; + + auto newWindow { ofCreateWindow(settings) }; +// ofAddListener(newWindow->events().draw, mainApp.get(), &ofApp::drawSecondWindow); +#endif + + ofRunApp(window, mainApp); + ofRunMainLoop(); + +} diff --git a/apps/d/A3/src/ofApp.cpp b/apps/d/A3/src/ofApp.cpp new file mode 100644 index 00000000000..1734a9ad84a --- /dev/null +++ b/apps/d/A3/src/ofApp.cpp @@ -0,0 +1,192 @@ +#include "ofApp.h" + +ofPolyline p1, p2; +#define NEUEFPS + +bool vs = false; +//int fps = 120/1; +int fps = 333; +//ofTimerFpsX t { fps }; +ofTimerFpsX t; + +GLFWwindow* wn; + +void ofApp::setup(){ + ofRectangle windowRect { 100, 100, 600, 400 }; + +#ifdef NW + ofGLFWWindowSettings settings; + settings.windowName = "second"; + settings.shareContextWith = ofGetCurrentWindow(); + settings.windowMode = OF_FULLSCREEN; +// settings.fullscreenDisplays = { 1, 2, 3 }; + settings.monitor = 1; + settings.showOnlyInSelectedMonitor = true; + auto newWindow { ofCreateWindow(settings) }; + + ofAddListener(newWindow->events().draw, + this, + &ofApp::drawSecondWindow); +#endif + +// GLFWwindow * sharedContext = nullptr; +// GLFWmonitor *monitor = nullptr; +// GLFWmonitor** monitors; +// int numberOfMonitors; +// monitors = glfwGetMonitors(&numberOfMonitors); +// if (numberOfMonitors > 1) { +// monitor = monitors[1]; +// } +// wn = glfwCreateWindow(windowRect.width, windowRect.height, "", monitor, sharedContext); + + ofSetCircleResolution(96); + cout << "GLFW version " << glfwGetVersionString() << endl; +#ifdef NEUEFPS +// ofSetFrameRate(fps); + ofSetFrameRate(0); + vs = false; + ofSetVerticalSync(vs); +#else + ofSetFrameRate(fps); //40 eh especial pq eh 25ms + ofSetVerticalSync(false); +#endif +// glfwWindowHint(GLFW_REFRESH_RATE, fps); + ofSetBackgroundAuto(false); + + cout << "getwindows size " << ofGetMainLoop()->getWindows().size() << endl; + +} + +void ofApp::update() { +#ifdef NEUEFPS +// t.waitNext(); +#endif +} + +void ofApp::draw(){ +// cout << ofGetSeconds() << endl; +// cout << ofGetElapsedTimeMicros() / 1000000 << endl; +// cout << ofGetElapsedTimeMillis() / (float)1000000000 << endl; + + + ofGetMainLoop()->ofBeginWindow(1); + ofClear(255, 0, 0); + ofSetColor(0, 255, 0); + ofDrawRectangle(50, 50, ofGetWindowWidth()-100, ofGetWindowHeight()-100); + ofSetColor(0); + ofDrawBitmapString("second window", 40, 40); + ofGetMainLoop()->ofEndWindow(); + + string s { ofToString(ofGetMouseX()) + " : " + ofToString(ofGetMouseY()) }; +// ofSetWindowTitle(s); +// cout << ofGetWindowHeight() << endl; +// ofScale(2, 2); +// ofSetColor(255, 0, 0); +// p1.draw(); +// ofSetColor(0, 255, 0); +// p2.draw(); + count.tick(); +// ofSetWindowTitle(ofToString(ofGetFrameRate())); + int w = 800; + int h = 600 + sin(ofGetElapsedTimef() * 0.5) * 150; +// ofSetWindowShape(w, h); + int x = 40; + int y = 100 + sin(ofGetElapsedTimef() * 0.4) * 100; +// ofSetWindowPosition(w, h); + + ofRectangle re = ofRectangle(x, y, ofGetWindowWidth(), ofGetWindowHeight()); +// ofSetWindowRect(re); + +// ofBackground(0, 60, 130); + + ofSetColor(0, 0, 255, 3); + ofDrawRectangle(0, 0, ofGetWindowWidth(), ofGetWindowHeight()); + + ofSetColor(255, 0, 0); + ofDrawCircle(200, 200, 200); + ofDrawLine(0, 0, 400, 400); + + ofSetColor(0, 255, 0 ); + float yy = ofGetWindowHeight() * .5; + ofDrawLine(0, yy, 600, yy); + ofSetColor(0, 255, 255 ); + yy = ofGetWindowHeight() * .5 + (fps-count.get())* 100.0; + ofDrawLine(0, yy, 600, yy); + + + + string t = "of " + ofToString(ofGetFrameRate()) + "\n" + + "new " +ofToString(count.get()) + " \n" + + ofToString(fps-count.get()) + "\n" + + ofToString(vs) + "\n" + ; + + ofSetColor(255); + ofDrawBitmapString(t, 200, 30); +// ofSetWindowTitle(t); + + + ofSetColor(0, 255, 0); + ofDrawCircle(ofGetMouseX(), ofGetMouseY(), 30); + +// for (int a=0; agetWindows()[1]->getWindowRect() << endl; + } + if (key == 'v') { + vs ^= 1; + ofSetVerticalSync(vs); + cout << "vs " << vs << endl; + } + if (key == 'r') { + ofSetFrameRate(ofRandom(25, 100)); + } + if (key == 'q') { + setupSecond(); + } + if (key == 'w') { + closeSecond(); + } + if (key == 'f') { + ofToggleFullscreen(); + } + else if (key == 'g') { + cout << int(ofGetWindowMode()) << endl; + } + else if (key == 's') { + cout << "ofGetWindowRect " << ofGetWindowRect() << endl; + cout << "ofGetWindowSize " << ofGetWindowSize() << endl; +#ifdef FORK + cout << "ofGetScreenSize " << ofGetScreenSize() << endl; +#endif +// cout << "ofGetWindowPosition " << ofGetWindowPosition() << endl; + cout << "ofGetWindowPositionX " << ofGetWindowPositionX() << endl; + cout << "ofGetWindowPositionY " << ofGetWindowPositionY() << endl; +// auto windowP = ((ofAppGLFWWindow*)ofGetWindowPtr())->getGLFWWindow(); + glm::vec2 scale; + glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &scale.x, &scale.y); + cout << "glfwGetMonitorContentScale " << scale << endl; + + cout << "getPixelScreenCoordScale" << ((ofAppGLFWWindow*)ofGetWindowPtr())->getPixelScreenCoordScale() << endl; + + + + } +} diff --git a/apps/d/A3/src/ofApp.h b/apps/d/A3/src/ofApp.h new file mode 100644 index 00000000000..896d2bad4cf --- /dev/null +++ b/apps/d/A3/src/ofApp.h @@ -0,0 +1,104 @@ +#pragma once + +#include "ofMain.h" +#include "GLFW/glfw3.h" + +#include "structs.h" + +class ofApp : public ofBaseApp{ +public: + void setup(); + void update(); + void draw(); + void keyPressed(int key); + + ofPolyline poly; + ofPath path; + fpsCounter count; + + + void drawSecondWindow(ofEventArgs & args) { +// cout << "drawSecondWindow" << endl; +// ofSetCircleResolution(4); + float s = sin(ofGetElapsedTimef()*3.0) * 40 + 40; + ofBackground(s); + int space = 200; + for (int b=0; b<=ofGetWindowHeight()/space; b++) { + for (int a=0; a<=ofGetWindowWidth()/space; a++) { + float h = a*9; + ofSetColor(ofColor::fromHsb(h, 255, 255)); + ofPushMatrix(); + ofTranslate(a*space + space*.5, b*space + space*.5); + + ofDrawCircle(0, 0, space*.5); + string t = ofToString(a) + " x " + ofToString(b); + ofSetColor(0); + ofDrawBitmapString(t, 0, 0); + ofPopMatrix(); + } + } +// drawOut(); + } + + + std::vector > allWindows; + std::function drawFunction = NULL; + + vector positionsFromRect(const ofRectangle & rect, int divisions) { + vector pos; + int w = rect.width / divisions; + int h = rect.height / divisions; + for (int a=0; aevents().draw, this, &ofApp::drawWindow); + } + } + } + + + + virtual void drawWindow(ofEventArgs & args) { +// cout << "drawSecondWindow" << endl; +// ofBackground(0, 255, 0); + ofSetColor(0); + ofSetColor(ofColor::fromHsb(ofRandom(0,45), 255, 255)); + ofDrawRectangle(10, 10, 100, 100); + } + + void closeSecond() { + for (auto & a : allWindows) { + a->setWindowShouldClose(); + } + allWindows.clear(); + } + + +}; diff --git a/apps/d/A3/src/structs.h b/apps/d/A3/src/structs.h new file mode 100644 index 00000000000..a7b33818375 --- /dev/null +++ b/apps/d/A3/src/structs.h @@ -0,0 +1,113 @@ + + +#include +using namespace std::chrono; +using namespace std::chrono_literals; + +struct fpsCounter { +public: + int nAverages = 20; + using space = std::chrono::duration; + time_point lastTick; + steady_clock::duration onesec = 1s; + vector intervals; + space interval; + space average; + bool firstTick = true; + int cursor = 0; + + void tick() { + if (firstTick) { + firstTick = false; + lastTick = steady_clock::now(); + return; + } + + interval = steady_clock::now() - lastTick; + lastTick = steady_clock::now(); + if (intervals.size() < nAverages) { + intervals.emplace_back(interval); + } else { + intervals[cursor] = interval; + cursor = (cursor+1)%nAverages; + } + } + + float get() { +// average = std::reduce(intervals.begin(), intervals.end())/intervals.size(); +// return onesec / average; + average = std::reduce(intervals.begin(), intervals.end()); + return intervals.size() * onesec / average; + } +} ; + + + +#include +#include +#include +#include + +using std::cout; +using std::endl; + +class ofTimerFpsX { +public: + ofTimerFpsX(){ + reset(); + } + ofTimerFpsX(int f) { + reset(); + setFps(f); + } + using space = std::chrono::duration; //micro + time_point wakeTime; + time_point lastWakeTime; + space interval; + space drift; + + void setFps(int fps) { + interval = duration_cast(1s) / fps; + wakeTime = steady_clock::now() + interval; + lastWakeTime = steady_clock::now(); + } + + void reset() { + wakeTime = steady_clock::now(); + lastWakeTime = steady_clock::now(); + } + + void waitNext(){ + bool debug = false; + + if (debug) { + std::cout << "interval:" << duration_cast(wakeTime - lastWakeTime).count() << std::endl; + + auto el = duration_cast(steady_clock::now() - lastWakeTime).count(); + std::cout << "ellapsed:" << el << std::endl; + + auto ws = duration_cast(wakeTime - steady_clock::now()).count(); + std::cout << "will sleep:" << ws << std::endl; + cout << "soma" << (el + ws) << endl; + } + if (wakeTime > steady_clock::now()) { + std::this_thread::sleep_until(wakeTime); + } + drift = steady_clock::now() - wakeTime; + auto driftNs = duration_cast(drift).count(); + + + if (debug) { + std::cout << "drift: " << driftNs << std::endl; + std::cout << "----" << std::endl; + } + + lastWakeTime = wakeTime; + wakeTime += interval; + if (drift < interval) { + wakeTime -= (drift/1000); + } + } +}; + + From 58b6a262b854e440ed719c45604967e341270d71 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 13 Feb 2024 11:42:24 -0300 Subject: [PATCH 082/143] mk --- .../project/makefileCommon/compile.core.mk | 12 +++--------- .../project/makefileCommon/config.project.mk | 7 ++----- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk index bd635fec55a..29cbfbbb716 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk @@ -35,14 +35,8 @@ else ARFLAGS = -cr endif -ifdef ${ccache} -$(info 💿 Using CCACHE - compile.core.mk ) - CXX := time ${ccache} $(CXX) - CC := time ${ccache} $(CXX) -# else -# CXX := time $(CXX) -# CC := time $(CXX) -endif +CXX := time ${ccache} $(CXX) +CC := time ${ccache} $(CXX) ################################################################################ # CFLAGS @@ -208,7 +202,7 @@ endif # avoid conflict with files of the same name and to improve performance. .PHONY: all Debug Release after clean CleanDebug CleanRelease help force -# USE_CORES=-j +USE_CORES=-j1 # ifeq ($(PLATFORM_ARCH),armv6l) # USE_CORES=-j2 diff --git a/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk b/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk index f7b1c3b3e8c..0490b524f2e 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk @@ -389,11 +389,8 @@ ifdef PLATFORM_CC CC ?= $(PLATFORM_CC) endif -ifdef ${ccache} -$(info 💿 Using CCACHE -- config.project.mk ) - CXX := ${ccache} $(CXX) - CC := ${ccache} $(CXX) -endif +CXX := time ${ccache} $(CXX) +CC := time ${ccache} $(CXX) ifdef PROJECT_RESOURCE_COMPILER RESOURCE_COMPILER ?= $(PROJECT_RESOURCE_COMPILER) From 07c0a62292a3eda2e4bff3b0c0bdef5db174ad5b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 13 Feb 2024 11:45:19 -0300 Subject: [PATCH 083/143] up --- .../project/makefileCommon/compile.project.mk | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk index 52c95ea315a..565d527dece 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk @@ -119,19 +119,19 @@ endif .PHONY: all Debug Release after clean CleanDebug CleanRelease help force -USE_CORES=-j +# USE_CORES=-j -ifeq ($(PLATFORM_ARCH),armv6l) - USE_CORES=-j2 -endif +# ifeq ($(PLATFORM_ARCH),armv6l) +# USE_CORES=-j2 +# endif -ifeq ($(PLATFORM_ARCH),armv7l) - USE_CORES=-j2 -endif +# ifeq ($(PLATFORM_ARCH),armv7l) +# USE_CORES=-j2 +# endif -ifeq ($(PLATFORM_ARCH),aarch64) - USE_CORES=-j3 -endif +# ifeq ($(PLATFORM_ARCH),aarch64) +# USE_CORES=-j3 +# endif Release: @echo Compiling OF library for Release From dadbcd6ed660bad064b188d35f6514f211e47de1 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 13 Feb 2024 13:41:49 -0300 Subject: [PATCH 084/143] keyboard back working --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 409f361c5a7..d1a1919cc57 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1138,8 +1138,8 @@ void ofAppGLFWWindow::error_cb(int errorCode, const char * errorDescription) { void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scancode, int action, int mods) { int key = 0; uint32_t codepoint = 0; -// ofAppGLFWWindow * instance = setCurrent(windowP_); - auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); cout << "keyboard_cb " << instance->settings.windowName << endl; switch (keycode) { case GLFW_KEY_ESCAPE: @@ -1299,8 +1299,8 @@ void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scanco key = codepoint = '='; break; default: -// codepoint = keycodeToUnicode(instance, scancode, mods); - codepoint = scancode; + codepoint = keycodeToUnicode(instance, scancode, mods); +// codepoint = scancode; key = codepoint; break; } From d2a1bd8d8a847c73c2449149696f156603b5857b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 15 Feb 2024 13:26:25 -0300 Subject: [PATCH 085/143] changes --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 40 ++++++++++----------- libs/openFrameworks/app/ofMainLoop.cpp | 20 +++++------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index d1a1919cc57..f3e854c3eb0 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1061,8 +1061,8 @@ void ofAppGLFWWindow::mouse_cb(GLFWwindow * windowP_, int button, int state, int //------------------------------------------------------------ void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) { - auto instance = getWindow(windowP_); -// ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y); ofMouseEventArgs::Type action; @@ -1082,8 +1082,8 @@ void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) { //------------------------------------------------------------ void ofAppGLFWWindow::entry_cb(GLFWwindow * windowP_, int entered) { -// ofAppGLFWWindow * instance = setCurrent(windowP_); - auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); ofMouseEventArgs::Type action; if (entered) { @@ -1102,8 +1102,8 @@ void ofAppGLFWWindow::entry_cb(GLFWwindow * windowP_, int entered) { //------------------------------------------------------------ void ofAppGLFWWindow::scroll_cb(GLFWwindow * windowP_, double x, double y) { -// ofAppGLFWWindow * instance = setCurrent(windowP_); - auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y); ofMouseEventArgs args(ofMouseEventArgs::Scrolled, @@ -1118,8 +1118,8 @@ void ofAppGLFWWindow::scroll_cb(GLFWwindow * windowP_, double x, double y) { //------------------------------------------------------------ void ofAppGLFWWindow::drop_cb(GLFWwindow * windowP_, int numFiles, const char ** dropString) { - auto instance = getWindow(windowP_); -// ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); ofDragInfo drag; drag.position = { instance->events().getMouseX(), instance->events().getMouseY() }; drag.files.resize(numFiles); @@ -1322,15 +1322,15 @@ void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scanco //------------------------------------------------------------ void ofAppGLFWWindow::char_cb(GLFWwindow * windowP_, uint32_t key) { -// ofAppGLFWWindow * instance = setCurrent(windowP_); - auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); instance->events().charEvent.notify(key); } //------------------------------------------------------------ void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { - auto instance = getWindow(windowP_); -// ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); instance->draw(); // thisWindow->draw(); } @@ -1361,8 +1361,8 @@ void ofAppGLFWWindow::monitor_cb(GLFWmonitor * monitor, int event) { //------------------------------------------------------------ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ -// ofAppGLFWWindow * instance = setCurrent(windowP_); - auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); // if (instance->settings.windowMode == OF_WINDOW) { // instance->windowRect.x = x; // instance->windowRect.y = y; @@ -1371,8 +1371,8 @@ void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ } //------------------------------------------------------------ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { - auto instance = getWindow(windowP_); -// ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); instance->events().notifyWindowResized(w, h); // instance->nFramesSinceWindowResized = 0; @@ -1393,8 +1393,8 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { //------------------------------------------------------------ void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { // cout << "framebuffer_size_cb " << w << " : " << h << endl; - auto instance = getWindow(windowP_); -// ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); instance->currentRenderer->clear(); instance->events().notifyFramebufferResized(w, h); @@ -1403,8 +1403,8 @@ void ofAppGLFWWindow::framebuffer_size_cb(GLFWwindow * windowP_, int w, int h) { //-------------------------------------------- void ofAppGLFWWindow::exit_cb(GLFWwindow * windowP_) { // cout << "exit_cb " << endl; - auto instance = getWindow(windowP_); -// ofAppGLFWWindow * instance = setCurrent(windowP_); +// auto instance = getWindow(windowP_); + ofAppGLFWWindow * instance = setCurrent(windowP_); instance->events().notifyExit(); // TODO: handle window closing correctly here. diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 5a2fdd1a252..7e072a21060 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -97,7 +97,7 @@ void ofMainLoop::run(const std::shared_ptr & window, std::share currentWindow = window; // FIXME: remove? -// window->makeCurrent(); + window->makeCurrent(); if(!windowLoop){ window->events().notifySetup(); } @@ -131,21 +131,21 @@ void ofMainLoop::loopOnce(){ // std::cout << "ofMainLoop::loopOnce()" << std::endl; auto i = windows.begin(); - currentWindow = (*i); - // here, not looping all windows - i->get()->makeCurrent(); - i->get()->update(); - i->get()->draw(); +// currentWindow = (*i); +// // here, not looping all windows +// i->get()->makeCurrent(); +// i->get()->update(); +// i->get()->draw(); for ( ; i != windows.end(); ) { if (i->get()->getWindowShouldClose()) { i = windows.erase(i); } else { -// currentWindow = (*i); -// i->get()->makeCurrent(); -// i->get()->update(); -// i->get()->draw(); + currentWindow = (*i); + i->get()->makeCurrent(); + i->get()->update(); + i->get()->draw(); ++i; } } From f400b15deb421ce01e141be6ff7dad7ef39a59f6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 15 Feb 2024 13:59:01 -0300 Subject: [PATCH 086/143] updates --- libs/openFrameworks/app/ofAppRunner.cpp | 1 + libs/openFrameworks/app/ofMainLoop.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 95466396428..d109463ea2d 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -104,6 +104,7 @@ void ofCloseFreeImage(); void ofInit(){ + std::cout << "ofINIT!!!" << std::endl; if(initialized()) return; initialized() = true; exiting() = false; diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 7e072a21060..7a7142ab225 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -8,7 +8,7 @@ #include "ofMainLoop.h" #include "ofBaseApp.h" // TEST WITHOUT -//#include "ofConstants.h" +#include "ofConstants.h" #include "ofAppBaseWindow.h" //======================================================================== @@ -21,7 +21,6 @@ #include "ofAppiOSWindow.h" typedef ofAppiOSWindow ofWindow; - #elif defined(TARGET_ANDROID) #include "ofAppAndroidWindow.h" #include "ofxAndroidUtils.h" From c682fd646ff53a9711f55342270d6ef7c1a0efcc Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 19 Feb 2024 15:10:45 -0300 Subject: [PATCH 087/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index f3e854c3eb0..36dfefcc4d5 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -788,6 +788,8 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // XFlush(display); // // // setWindowShape(windowW, windowH); + setFSTarget(targetWindowMode); + #endif settings.windowMode = targetWindowMode; From ae25320ed55496887a6ab4e11d93a8bf772e4aef Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 3 Mar 2024 10:02:28 -0300 Subject: [PATCH 088/143] updates glfw --- addons/ofxKinect/src/ofxKinect.cpp | 1 - libs/openFrameworks/app/ofAppGLFWWindow.cpp | 45 ++++++++++++--------- libs/openFrameworks/app/ofAppRunner.cpp | 2 +- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/addons/ofxKinect/src/ofxKinect.cpp b/addons/ofxKinect/src/ofxKinect.cpp index c5f051d0125..3c327490ad4 100644 --- a/addons/ofxKinect/src/ofxKinect.cpp +++ b/addons/ofxKinect/src/ofxKinect.cpp @@ -30,7 +30,6 @@ ==============================================================================*/ #include "ofxKinect.h" -#include "ofMain.h" #include "libfreenect_registration.h" #include "freenect_internal.h" // for access to freenect_device.registration.zero_plane_info diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 36dfefcc4d5..93948bc52ee 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -193,6 +193,12 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); + + if (!windowP) { + ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; + return; + } + // saves window rectangle just created. windowRect = getWindowRect(); @@ -217,10 +223,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } } - if (!windowP) { - ofLogError("ofAppGLFWWindow") << "couldn't create GLFW window"; - return; - } + // MARK: - @@ -307,18 +310,18 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { glfwSetWindowRefreshCallback(windowP, refresh_cb); #ifdef TARGET_LINUX -// XSetLocaleModifiers(""); -// xim = XOpenIM(getX11Display(), 0, 0, 0); -// if (!xim) { -// // fallback to internal input method -// XSetLocaleModifiers("@im=none"); -// xim = XOpenIM(getX11Display(), 0, 0, 0); -// } -// xic = XCreateIC(xim, -// XNInputStyle, XIMPreeditNothing | XIMStatusNothing, -// XNClientWindow, getX11Window(), -// XNFocusWindow, getX11Window(), -// NULL); + XSetLocaleModifiers(""); + xim = XOpenIM(getX11Display(), 0, 0, 0); + if (!xim) { + // fallback to internal input method + XSetLocaleModifiers("@im=none"); + xim = XOpenIM(getX11Display(), 0, 0, 0); + } + xic = XCreateIC(xim, + XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, getX11Window(), + XNFocusWindow, getX11Window(), + NULL); #endif } @@ -388,7 +391,7 @@ void ofAppGLFWWindow::update() { glfwSetWindowOpacity(windowP, settings.opacity); } - cout << "SHOW WINDOW! " << settings.windowName << endl; +// cout << "SHOW WINDOW! " << settings.windowName << endl; glfwShowWindow(windowP); // cout << "after show window rect " << getWindowRect() << endl; @@ -536,7 +539,8 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { -// cout << settings.windowName << " setWindowRect " << rect << endl; + cout << settings.windowName << " setWindowRect " << rect << endl; + glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -577,6 +581,7 @@ void ofAppGLFWWindow::disableSetupScreen() { //------------------------------------------------------------ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { + cout << "setFSTarget " << targetWindowMode << endl; if (targetWindowMode == OF_FULLSCREEN) { // save window shape before going fullscreen windowRect = getWindowRect(); @@ -592,7 +597,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { if (settings.fullscreenDisplays.size()) { windowRectFS = allMonitors.getRectFromMonitors(settings.fullscreenDisplays); } - cout << "windowRectFS " << windowRectFS << " : " << settings.windowName << endl; +// cout << "windowRectFS " << windowRectFS << " : " << settings.windowName << endl; setWindowRect(windowRectFS); } @@ -785,7 +790,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { // unsigned long value = fullscreen ? 1 : 0; // XChangeProperty(display, nativeWin, m_bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&value, 1); // -// XFlush(display); +// -(display); // // // setWindowShape(windowW, windowH); setFSTarget(targetWindowMode); diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index d109463ea2d..ced06509e57 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -104,7 +104,7 @@ void ofCloseFreeImage(); void ofInit(){ - std::cout << "ofINIT!!!" << std::endl; +// std::cout << "ofInit !!!" << std::endl; if(initialized()) return; initialized() = true; exiting() = false; From 398d4958fbb6aa0a4eaa335f5c8c145c7e44aed4 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 13 Mar 2024 17:27:21 -0300 Subject: [PATCH 089/143] update all --- .../src/ofxAssimpModelLoader.cpp | 6 +++ .../src/ofxAssimpModelLoader.h | 2 + apps/projectGenerator | 2 +- examples/gl/pointLightsExample/src/main.cpp | 3 +- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 37 +++++++++++--- libs/openFrameworks/events/ofEvents.cpp | 7 +-- libs/openFrameworks/events/ofEvents.h | 4 +- libs/openFrameworks/gl/ofTexture.h | 1 + libs/openFrameworks/graphics/ofGraphics.h | 1 + libs/openFrameworks/math/ofMathConstants.h | 1 + libs/openFrameworks/math/ofVec2f.h | 1 - .../sound/ofRtAudioSoundStream.cpp | 1 + libs/openFrameworks/sound/ofSoundBuffer.cpp | 1 + libs/openFrameworks/sound/ofSoundStream.cpp | 4 ++ libs/openFrameworks/utils/ofFpsCounter.h | 51 +++++++++++++++++++ libs/openFrameworks/utils/ofMatrixStack.h | 1 + libs/openFrameworks/utils/ofTimer.h | 10 ++-- scripts/dev/download_libs.sh | 30 +++++++---- scripts/dev/downloader.sh | 41 ++++++++++----- scripts/osx/download_latest_libs.sh | 16 +++++- 20 files changed, 174 insertions(+), 46 deletions(-) diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp index 634d322127b..b696b8c419d 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp @@ -749,6 +749,12 @@ void ofxAssimpModelLoader::setPositionForAllAnimations(float position) { } } +void ofxAssimpModelLoader::setSpeedForAllAnimations(float speed) { + for(size_t i = 0; i < animations.size(); i++) { + animations[i].setSpeed(speed); + } +} + // DEPRECATED. void ofxAssimpModelLoader::setAnimation(int animationIndex) { if(!hasAnimations()) { diff --git a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h index 1acf712edae..e4cfcbd38fb 100644 --- a/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h +++ b/addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h @@ -76,6 +76,8 @@ class ofxAssimpModelLoader{ void setPausedForAllAnimations(bool pause); void setLoopStateForAllAnimations(ofLoopType state); void setPositionForAllAnimations(float position); + void setSpeedForAllAnimations(float speed); + [[deprecated("Use ofxAssimpAnimation")]] void setAnimation(int animationIndex); [[deprecated("Use ofxAssimpAnimation")]] diff --git a/apps/projectGenerator b/apps/projectGenerator index 67f29fb2b56..db8c6e92bfc 160000 --- a/apps/projectGenerator +++ b/apps/projectGenerator @@ -1 +1 @@ -Subproject commit 67f29fb2b5638cc727afda8e97b211d4634f69b8 +Subproject commit db8c6e92bfc08d69f20bea2e6f37096cc7e650ae diff --git a/examples/gl/pointLightsExample/src/main.cpp b/examples/gl/pointLightsExample/src/main.cpp index 108491824be..020743b8c1b 100644 --- a/examples/gl/pointLightsExample/src/main.cpp +++ b/examples/gl/pointLightsExample/src/main.cpp @@ -8,7 +8,8 @@ int main( ){ ofGLWindowSettings settings; settings.setSize(1024, 768); settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN - + settings.setGLVersion(3, 2); + auto window = ofCreateWindow(settings); ofRunApp(window, std::make_shared()); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 93948bc52ee..91e6480a5ac 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -56,7 +56,7 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ } ofAppGLFWWindow::~ofAppGLFWWindow() { - cout << "DISTRUKT! " << settings.windowName << endl; + cout << "ofAppGLFWWindow::~ofAppGLFWWindow() " << settings.windowName << endl; close(); } @@ -189,9 +189,32 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { } - // MARK: - WINDOW - glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); + +// cout << "will create window" << endl; +// cout << "monitors size: " << allMonitors.rects.size() << endl; + bool displayOK = false; + if (settings.fullscreenDisplays.size()) { + for (auto & d : settings.fullscreenDisplays) { + cout << "GLFWWindow fullscreenDisplays " << d << " : " << allMonitors.rects.size() << endl; + if (d <= (allMonitors.rects.size()-1)) { + displayOK = true; + break; + } +// cout << d << endl; + } + } else { + displayOK = true; + } + windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); + + + if (displayOK) { + } else { + // MARK: - WINDOW + glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); +// return; + } if (!windowP) { @@ -539,7 +562,7 @@ GLFWwindow * ofAppGLFWWindow::getGLFWWindow() { //------------------------------------------------------------ void ofAppGLFWWindow::setWindowRect(const ofRectangle & rect) { - cout << settings.windowName << " setWindowRect " << rect << endl; +// cout << settings.windowName << " setWindowRect " << rect << endl; glfwSetWindowMonitor(windowP, NULL, rect.x, rect.y, rect.width, rect.height, GLFW_DONT_CARE); } @@ -581,7 +604,7 @@ void ofAppGLFWWindow::disableSetupScreen() { //------------------------------------------------------------ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { - cout << "setFSTarget " << targetWindowMode << endl; +// cout << "setFSTarget " << targetWindowMode << endl; if (targetWindowMode == OF_FULLSCREEN) { // save window shape before going fullscreen windowRect = getWindowRect(); @@ -609,7 +632,7 @@ void ofAppGLFWWindow::setFSTarget(ofWindowMode targetWindowMode) { //------------------------------------------------------------ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { - cout << "setFullScreen " << fullscreen << " : " << settings.windowName << endl; +// cout << "setFullScreen " << fullscreen << " : " << settings.windowName << endl; if (fullscreen) { targetWindowMode = OF_FULLSCREEN; } else { @@ -1147,7 +1170,7 @@ void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scanco uint32_t codepoint = 0; ofAppGLFWWindow * instance = setCurrent(windowP_); // auto instance = getWindow(windowP_); - cout << "keyboard_cb " << instance->settings.windowName << endl; +// cout << "keyboard_cb " << instance->settings.windowName << endl; switch (keycode) { case GLFW_KEY_ESCAPE: key = OF_KEY_ESC; diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index 52ffcd44830..ea8c09a7165 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -211,9 +211,9 @@ void ofCoreEvents::setFrameRate(int _targetRate) { } else { bFrameRateSet = true; targetRate = _targetRate; - uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate; - timer.setPeriodicEvent(nanosPerFrame); -// timer.setFps(targetRate); +// uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate; +// timer.setPeriodicEvent(nanosPerFrame); + timer.setFps(targetRate); } } @@ -224,6 +224,7 @@ bool ofCoreEvents::getTargetFrameRateEnabled() const { //-------------------------------------- float ofCoreEvents::getFrameRate() const { return fps.getFps(); +// return fps2.getFps(); } //-------------------------------------- diff --git a/libs/openFrameworks/events/ofEvents.h b/libs/openFrameworks/events/ofEvents.h index a9db0c16dd0..075060e799c 100644 --- a/libs/openFrameworks/events/ofEvents.h +++ b/libs/openFrameworks/events/ofEvents.h @@ -407,8 +407,8 @@ class ofCoreEvents { private: float targetRate; bool bFrameRateSet; -// ofTimerFps timer; - ofTimer timer; + ofTimerFps timer; +// ofTimer timer; ofFpsCounter fps; int currentMouseX, currentMouseY; diff --git a/libs/openFrameworks/gl/ofTexture.h b/libs/openFrameworks/gl/ofTexture.h index 9c1ab05822f..903deb38ce2 100644 --- a/libs/openFrameworks/gl/ofTexture.h +++ b/libs/openFrameworks/gl/ofTexture.h @@ -3,6 +3,7 @@ #include "ofGraphicsBaseTypes.h" // MARK: Targets, some can be moved to cpp, GLEW also #include "ofConstants.h" + #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include diff --git a/libs/openFrameworks/graphics/ofGraphics.h b/libs/openFrameworks/graphics/ofGraphics.h index 3ac4f1b2965..9725931eb09 100644 --- a/libs/openFrameworks/graphics/ofGraphics.h +++ b/libs/openFrameworks/graphics/ofGraphics.h @@ -1,4 +1,5 @@ #pragma once + #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include diff --git a/libs/openFrameworks/math/ofMathConstants.h b/libs/openFrameworks/math/ofMathConstants.h index bc43fd54d92..4e660e5ee01 100644 --- a/libs/openFrameworks/math/ofMathConstants.h +++ b/libs/openFrameworks/math/ofMathConstants.h @@ -2,6 +2,7 @@ // MARK: if OF_USE_LEGACY_VECTOR_MATH #include "ofConstants.h" + #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include diff --git a/libs/openFrameworks/math/ofVec2f.h b/libs/openFrameworks/math/ofVec2f.h index 45c216a1899..bfe127316df 100644 --- a/libs/openFrameworks/math/ofVec2f.h +++ b/libs/openFrameworks/math/ofVec2f.h @@ -6,7 +6,6 @@ #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL - #include #include //#include diff --git a/libs/openFrameworks/sound/ofRtAudioSoundStream.cpp b/libs/openFrameworks/sound/ofRtAudioSoundStream.cpp index db0919f19b8..62aa78b93b7 100644 --- a/libs/openFrameworks/sound/ofRtAudioSoundStream.cpp +++ b/libs/openFrameworks/sound/ofRtAudioSoundStream.cpp @@ -4,6 +4,7 @@ #include "ofAppRunner.h" #include "ofLog.h" #include +#include "ofConstants.h" using std::vector; using std::shared_ptr; diff --git a/libs/openFrameworks/sound/ofSoundBuffer.cpp b/libs/openFrameworks/sound/ofSoundBuffer.cpp index 90b148d1593..c5f585cb8ae 100644 --- a/libs/openFrameworks/sound/ofSoundBuffer.cpp +++ b/libs/openFrameworks/sound/ofSoundBuffer.cpp @@ -8,6 +8,7 @@ #include "ofSoundBuffer.h" #include "ofSoundUtils.h" #include "ofLog.h" + #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include diff --git a/libs/openFrameworks/sound/ofSoundStream.cpp b/libs/openFrameworks/sound/ofSoundStream.cpp index fc290e6961a..3bdfc91e1f3 100644 --- a/libs/openFrameworks/sound/ofSoundStream.cpp +++ b/libs/openFrameworks/sound/ofSoundStream.cpp @@ -2,6 +2,10 @@ #include "ofAppRunner.h" #include "ofLog.h" +// REMOVE +//#define OF_SOUND_PLAYER_FMOD +//#include "ofConstants.h" + //------------------------------------------------ soundstream // check if any soundstream api is defined from the compiler #if !defined(OF_SOUNDSTREAM_RTAUDIO) && !defined(OF_SOUNDSTREAM_ANDROID) && !defined(OF_SOUNDSTREAM_IOS) && !defined(OF_SOUNDSTREAM_EMSCRIPTEN) diff --git a/libs/openFrameworks/utils/ofFpsCounter.h b/libs/openFrameworks/utils/ofFpsCounter.h index 066daee41b3..99760a2f0f1 100644 --- a/libs/openFrameworks/utils/ofFpsCounter.h +++ b/libs/openFrameworks/utils/ofFpsCounter.h @@ -4,6 +4,7 @@ #include "ofUtils.h" #include + class ofFpsCounter { public: ofFpsCounter(); @@ -34,3 +35,53 @@ class ofFpsCounter { double filterAlpha; std::queue timestamps; }; + + + + + +#include +using namespace std::chrono; +using namespace std::chrono_literals; + +struct fpsCounter { +public: + int nAverages = 20; + using space = std::chrono::duration; + time_point lastTick; + steady_clock::duration onesec = 1s; + std::vector intervals; + space interval; + space average; + bool firstTick = true; + int cursor = 0; + + void tick() { + if (firstTick) { + firstTick = false; + lastTick = steady_clock::now(); + return; + } + + interval = steady_clock::now() - lastTick; + lastTick = steady_clock::now(); + if (intervals.size() < nAverages) { + intervals.emplace_back(interval); + } else { + intervals[cursor] = interval; + cursor = (cursor+1)%nAverages; + } + } + + double getFps() { + average = std::reduce(intervals.begin(), intervals.end()); + return intervals.size() * onesec / average; + } + + float get() { +// average = std::reduce(intervals.begin(), intervals.end())/intervals.size(); +// return onesec / average; + average = std::reduce(intervals.begin(), intervals.end()); + return intervals.size() * onesec / average; + } +}; diff --git a/libs/openFrameworks/utils/ofMatrixStack.h b/libs/openFrameworks/utils/ofMatrixStack.h index e6bebc09681..e3a9221a5de 100644 --- a/libs/openFrameworks/utils/ofMatrixStack.h +++ b/libs/openFrameworks/utils/ofMatrixStack.h @@ -10,6 +10,7 @@ // ofRectangle currentViewport only #include "ofRectangle.h" #include "ofGraphicsConstants.h" + #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include diff --git a/libs/openFrameworks/utils/ofTimer.h b/libs/openFrameworks/utils/ofTimer.h index 0ed610b8fa5..42919ab2819 100644 --- a/libs/openFrameworks/utils/ofTimer.h +++ b/libs/openFrameworks/utils/ofTimer.h @@ -1,6 +1,7 @@ #pragma once #include "ofUtils.h" + #include #include #include @@ -23,6 +24,7 @@ class ofTimerFps { // FIXME: double? float? void setFps(int fps) { +// std::cout << "ofTimerFps " << fps << std::endl; interval = duration_cast(1s) / fps; } @@ -31,10 +33,10 @@ class ofTimerFps { } void waitNext(){ - std::cout << "interval:" << duration_cast(wakeTime - lastWakeTime).count() << std::endl; - std::cout << "ellapsed:" << duration_cast(steady_clock::now() - lastWakeTime).count() << std::endl; - std::cout << "will sleep:" << duration_cast(wakeTime - steady_clock::now()).count() << std::endl; - std::cout << "----" << std::endl; +// std::cout << "interval:" << duration_cast(wakeTime - lastWakeTime).count() << std::endl; +// std::cout << "ellapsed:" << duration_cast(steady_clock::now() - lastWakeTime).count() << std::endl; +// std::cout << "will sleep:" << duration_cast(wakeTime - steady_clock::now()).count() << std::endl; +// std::cout << "----" << std::endl; std::this_thread::sleep_until(wakeTime); lastWakeTime = wakeTime; wakeTime += interval; diff --git a/scripts/dev/download_libs.sh b/scripts/dev/download_libs.sh index 560f61446f8..5605cd3f551 100755 --- a/scripts/dev/download_libs.sh +++ b/scripts/dev/download_libs.sh @@ -33,15 +33,21 @@ if [[ ! -d "$SCRIPT_DIR" ]]; then SCRIPT_DIR="$PWD"; fi . "$SCRIPT_DIR/downloader.sh" download(){ + echo '-----' echo "Downloading $1" # downloader ci.openframeworks.cc/libs/$1 $SILENT_ARGS + + COMMAND=" " + REPO="nightly" if [[ $BLEEDING_EDGE = 1 ]] ; then - echo downloader https://github.com/openframeworks/apothecary/releases/download/bleeding/$1 $SILENT_ARGS - downloader https://github.com/openframeworks/apothecary/releases/download/bleeding/$1 $SILENT_ARGS - else - echo downloader https://github.com/openframeworks/apothecary/releases/download/nightly/$1 $SILENT_ARGS - downloader https://github.com/openframeworks/apothecary/releases/download/nightly/$1 $SILENT_ARGS + REPO="bleeding" fi + + for PKG in $1; do + COMMAND+="https://github.com/openframeworks/apothecary/releases/download/$REPO/$PKG " + done + echo $COMMAND; + downloader $COMMAND $SILENT_ARGS } # trap any script errors and exit @@ -195,9 +201,9 @@ elif [ "$PLATFORM" == "vs" ]; then fi elif [[ "$PLATFORM" =~ ^(osx|ios|tvos|xros|catos|watchos)$ ]]; then if [[ $BLEEDING_EDGE = 1 ]] ; then - PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_1.tar.bz2 \ - openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_2.tar.bz2 \ - openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_3.tar.bz2" + PKGS="openFrameworksLibs_${VER}_${PLATFORM}_1.tar.bz2 \ + openFrameworksLibs_${VER}_${PLATFORM}_2.tar.bz2 \ + openFrameworksLibs_${VER}_${PLATFORM}_3.tar.bz2" else PKGS="openFrameworksLibs_${VER}_${PLATFORM}1.tar.bz2 \ openFrameworksLibs_${VER}_${PLATFORM}2.tar.bz2 \ @@ -223,9 +229,11 @@ else # Linux fi fi -for PKG in $PKGS; do - download $PKG -done +# for PKG in $PKGS; do +# download $PKG +# done +# echo $PKGS +download "${PKGS[@]}" cd ../../ mkdir -p libs diff --git a/scripts/dev/downloader.sh b/scripts/dev/downloader.sh index c2fe46c3d48..2f11618da56 100755 --- a/scripts/dev/downloader.sh +++ b/scripts/dev/downloader.sh @@ -13,24 +13,37 @@ EOF } downloader() { - if [ -z "$1" ] then printDownloaderHelp; fi - SILENTARGS=""; - if [ $# -ge 2 ]; then - SILENTARGS=$2 - fi - if [[ "${SILENTARGS}" == "-s" ]]; then - if command -v curl 2>/dev/null; then - curl -LO --retry 20 -O -s $@; - else - wget -q $@ 2> /dev/null; fi; + SILENTARGS=""; + if [ $# -ge 2 ]; then + SILENTARGS=$2 + fi + if [[ "${SILENTARGS}" == "-s" ]]; then + if command -v wget2 2>/dev/null; then + wget2 -q $@; + elif command -v curl 2>/dev/null; then + for PKG in $@; do + curl -LO --retry 20 -O -s $PKG; + done + else + for PKG in $@; do + wget -q $PKG@ 2> /dev/null; + done + fi; else - if command -v curl 2>/dev/null; then - curl -LO --retry 20 -O --progress-bar $@; - else - wget $@ 2> /dev/null; fi; + if command -v wget2 2>/dev/null; then + wget2 $@; + elif command -v curl 2>/dev/null; then + for PKG in $@; do + curl -LO --retry 20 -O --progress-bar $PKG; + done + else + for PKG in $@; do + wget $PKG 2> /dev/null; + done + fi; fi diff --git a/scripts/osx/download_latest_libs.sh b/scripts/osx/download_latest_libs.sh index 61fbbb6aed3..87958f2e171 100755 --- a/scripts/osx/download_latest_libs.sh +++ b/scripts/osx/download_latest_libs.sh @@ -1,10 +1,22 @@ #!/usr/bin/env bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $SCRIPT_DIR -cd $SCRIPT_DIR +# cd $SCRIPT_DIR if [ ! -z ${BITS+x} ]; then ../dev/download_libs.sh -p osx -b -a $BITS $@ else - ../dev/download_libs.sh -p osx -b -a x86_64 $@ + # ../dev/download_libs.sh -p osx -b -a x86_64 $@ ../dev/download_libs.sh -p osx -b -a arm64 -n $@ fi + + +# URL_LIST=('https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_1.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_2.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_3.tar.bz2') + +# echo $URL_LIST +# echo $URL_LIST | xargs -n 1 -P 8 curl -LO -q + +# wget -b $URL_LIST[0] +# wget -b $URL_LIST[1] +# wget -b $URL_LIST[2] + +# wget2 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_1.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_2.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_3.tar.bz2' \ No newline at end of file From b7cdc904cb5214019585131615ef7651413194be Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 29 Apr 2024 12:46:42 -0300 Subject: [PATCH 090/143] more unrelated changes --- addons/ofxSvg/src/ofxSvg.cpp | 2 +- libs/openFrameworks/3d/ofEasyCam.h | 7 +- libs/openFrameworks/3d/ofMesh.inl | 36 ++++---- libs/openFrameworks/events/ofEvents.h | 1 + libs/openFrameworks/gl/ofCubeMapShaders.h | 23 +++--- libs/openFrameworks/gl/ofFbo.cpp | 3 + libs/openFrameworks/gl/ofTexture.cpp | 96 ++++++++++++++-------- libs/openFrameworks/gl/ofTexture.h | 2 + libs/openFrameworks/math/ofMathConstants.h | 88 ++++++++++---------- 9 files changed, 151 insertions(+), 107 deletions(-) diff --git a/addons/ofxSvg/src/ofxSvg.cpp b/addons/ofxSvg/src/ofxSvg.cpp index 9f6b0e30b00..6db5c60d9c7 100644 --- a/addons/ofxSvg/src/ofxSvg.cpp +++ b/addons/ofxSvg/src/ofxSvg.cpp @@ -98,7 +98,7 @@ void ofxSvg::fixSvgString(std::string & xmlstring) { for (ofXml & element : strokeWidthElements) { //cout << element.toString() << endl; float strokewidth = element.getAttribute("stroke-width").getFloatValue(); - strokewidth = MAX(1, round(strokewidth)); + strokewidth = std::fmax(1, round(strokewidth)); element.getAttribute("stroke-width").set(strokewidth); } } diff --git a/libs/openFrameworks/3d/ofEasyCam.h b/libs/openFrameworks/3d/ofEasyCam.h index 48f95878c8e..37ad84af57b 100644 --- a/libs/openFrameworks/3d/ofEasyCam.h +++ b/libs/openFrameworks/3d/ofEasyCam.h @@ -1,8 +1,11 @@ #pragma once #include "ofCamera.h" -#include "ofEvents.h" -#include "ofRectangle.h" +//#include "ofEvents.h" +class ofEventListeners; +class ofEventArgs; +//#include "ofRectangle.h" +class ofRectangle; #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL diff --git a/libs/openFrameworks/3d/ofMesh.inl b/libs/openFrameworks/3d/ofMesh.inl index b093b1101cd..559986a9580 100644 --- a/libs/openFrameworks/3d/ofMesh.inl +++ b/libs/openFrameworks/3d/ofMesh.inl @@ -1784,9 +1784,11 @@ void ofMesh_::smoothNormals( float angle ) { if( getMode() == OF_PRIMITIVE_TRIANGLES) { std::vector> triangles = getUniqueFaces(); std::vector verts; + verts.reserve( triangles.size() * 3 ); + for(ofIndexType i = 0; i < triangles.size(); i++) { for(ofIndexType j = 0; j < 3; j++) { - verts.push_back( triangles[i].getVertex(j) ); + verts.emplace_back( triangles[i].getVertex(j) ); } } @@ -1813,20 +1815,21 @@ void ofMesh_::smoothNormals( float angle ) { //ofLogNotice("ofMesh") << "smoothNormals(): num verts = " << verts.size() << " tris size = " << triangles.size(); - std::string xStr, yStr, zStr; for(ofIndexType i = 0; i < verts.size(); i++ ) { - xStr = "x"+ofToString(verts[i].x==-0?0:verts[i].x); - yStr = "y"+ofToString(verts[i].y==-0?0:verts[i].y); - zStr = "z"+ofToString(verts[i].z==-0?0:verts[i].z); - std::string vstring = xStr+yStr+zStr; + std::string vstring { + "x"+ofToString(verts[i].x==-0?0:verts[i].x) + + "y"+ofToString(verts[i].y==-0?0:verts[i].y) + + "z"+ofToString(verts[i].z==-0?0:verts[i].z) + }; + if(vertHash.find(vstring) == vertHash.end()) { for(ofIndexType j = 0; j < triangles.size(); j++) { for(ofIndexType k = 0; k < 3; k++) { if(verts[i].x == triangles[j].getVertex(k).x) { if(verts[i].y == triangles[j].getVertex(k).y) { if(verts[i].z == triangles[j].getVertex(k).z) { - vertHash[vstring].push_back( j ); + vertHash[vstring].emplace_back( j ); } } } @@ -1848,11 +1851,12 @@ void ofMesh_::smoothNormals( float angle ) { for(ofIndexType j = 0; j < triangles.size(); j++) { for(ofIndexType k = 0; k < 3; k++) { vert = triangles[j].getVertex(k); - xStr = "x"+ofToString(vert.x==-0?0:vert.x); - yStr = "y"+ofToString(vert.y==-0?0:vert.y); - zStr = "z"+ofToString(vert.z==-0?0:vert.z); - - std::string vstring = xStr+yStr+zStr; + std::string vstring { + "x"+ofToString(vert.x==-0?0:vert.x) + + "y"+ofToString(vert.y==-0?0:vert.y) + + "z"+ofToString(vert.z==-0?0:vert.z) + }; + numNormals=0; normal = {0.f,0.f,0.f}; if(vertHash.find(vstring) != vertHash.end()) { @@ -2120,8 +2124,8 @@ ofMesh_ ofMesh_::sphere( float radius, int res, ofPrimitiveMod //-------------------------------------------------------------- template ofMesh_ ofMesh_::icosahedron(float radius) { - auto mesh = icosphere(radius, 0); - mesh.flatNormals(); + auto mesh { icosphere(radius, 0) }; + mesh.flatNormals(); return mesh; } @@ -2139,6 +2143,8 @@ ofMesh_ ofMesh_::icosphere(float radius, std::size_t iteration const float phi = (1.0f + sqrt5) * 0.5f; const float invnorm = 1/sqrt(phi*phi+1); + + // FIXME: addvertices XAXA sphere.addVertex(invnorm * V(-1, phi, 0));//0 sphere.addVertex(invnorm * V( 1, phi, 0));//1 sphere.addVertex(invnorm * V(0, 1, -phi));//2 @@ -2175,7 +2181,7 @@ ofMesh_ ofMesh_::icosphere(float radius, std::size_t iteration 10,11,9 }; - for(ofIndexType i = 0; i < 60; i+=3) { + for(ofIndexType i = 0; i < 60; i+=3) { sphere.addTriangle(firstFaces[i], firstFaces[i+1], firstFaces[i+2]); } diff --git a/libs/openFrameworks/events/ofEvents.h b/libs/openFrameworks/events/ofEvents.h index 075060e799c..4337a44de86 100644 --- a/libs/openFrameworks/events/ofEvents.h +++ b/libs/openFrameworks/events/ofEvents.h @@ -3,6 +3,7 @@ #define GLM_FORCE_CTOR_INIT #define GLM_ENABLE_EXPERIMENTAL #include + #include "ofEventUtils.h" #include "ofFpsCounter.h" #include "ofTimer.h" diff --git a/libs/openFrameworks/gl/ofCubeMapShaders.h b/libs/openFrameworks/gl/ofCubeMapShaders.h index fadcc90732c..465b968d725 100644 --- a/libs/openFrameworks/gl/ofCubeMapShaders.h +++ b/libs/openFrameworks/gl/ofCubeMapShaders.h @@ -18,7 +18,7 @@ class ofCubeMapShaders { }; static std::string getGLSLHeader() { - std::string vstr = "#version 150\n"; + std::string vstr { "#version 150\n" }; if( ofGetGLRenderer() ) { vstr = "#version "+ofGLSLVersionFromGL(ofGetGLRenderer()->getGLVersionMajor(), ofGetGLRenderer()->getGLVersionMinor())+"\n"; } @@ -40,18 +40,19 @@ class ofCubeMapShaders { } static std::string defaultVertShader() { - std::string vshader = getGLSLHeader(); + + std::string vshader { getGLSLHeader() }; vshader += R"(in vec4 position; uniform mat4 uProjection; - uniform mat4 uView; - - out vec3 oLocalPos; - - void main() { - oLocalPos = position.xyz; - gl_Position = uProjection * uView * vec4(position.xyz, 1.0); - } - )"; + uniform mat4 uView; + + out vec3 oLocalPos; + + void main() { + oLocalPos = position.xyz; + gl_Position = uProjection * uView * vec4(position.xyz, 1.0); + } + )"; return vshader; } diff --git a/libs/openFrameworks/gl/ofFbo.cpp b/libs/openFrameworks/gl/ofFbo.cpp index fe9db48486d..b5042587e3a 100644 --- a/libs/openFrameworks/gl/ofFbo.cpp +++ b/libs/openFrameworks/gl/ofFbo.cpp @@ -1,4 +1,5 @@ #include "ofFbo.h" + // #include "ofAppRunner.h" // #include "ofUtils.h" // #include "ofGraphics.h" @@ -23,6 +24,8 @@ using std::unordered_map; using std::vector; +ofTexture depthBufferTex; + /* See diff --git a/libs/openFrameworks/gl/ofTexture.cpp b/libs/openFrameworks/gl/ofTexture.cpp index 8aae4795ab3..14082bbe42e 100644 --- a/libs/openFrameworks/gl/ofTexture.cpp +++ b/libs/openFrameworks/gl/ofTexture.cpp @@ -574,6 +574,8 @@ void ofTexture::loadData(const int16_t * data, int w, int h, int glFormat){ //---------------------------------------------------------- void ofTexture::loadData(const int32_t * data, int w, int h, int glFormat){ + + // FIXME: should w,2 be w,4? ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,w,2,ofGetNumChannelsFromGLFormat(glFormat)); loadData(data, w, h, glFormat, GL_INT); } @@ -883,14 +885,19 @@ glm::vec2 ofTexture::getCoordFromPoint(float xPos, float yPos) const{ // non arb textures are 0 to 1, so we // (a) convert to a pct: - float pctx = xPos / texData.width; - float pcty = yPos / texData.height; - - // (b) mult by our internal pct (since we might not be 0-1 internally) - - pctx *= texData.tex_t; - pcty *= texData.tex_u; - +// float pctx = xPos / texData.width; +// float pcty = yPos / texData.height; +// +// // (b) mult by our internal pct (since we might not be 0-1 internally) +// +// pctx *= texData.tex_t; +// pcty *= texData.tex_u; + + + // more straight, with multiplication first + float pctx = texData.tex_t * xPos / texData.width; + float pcty = texData.tex_u * yPos / texData.height; + temp = {pctx, pcty}; #ifndef TARGET_OPENGLES @@ -1078,15 +1085,21 @@ void ofTexture::drawSubsection(float x, float y, float z, float w, float h, floa //------------------------------------ ofMesh ofTexture::getMeshForSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh, bool vflipped, ofRectMode rectMode) const{ - ofMesh quad; + if(!texData.bAllocated){ - return quad; + return {}; } - GLfloat px0 = x; // up to you to get the aspect ratio right - GLfloat py0 = y; - GLfloat px1 = w+x; - GLfloat py1 = h+y; + ofMesh quad; +// if (quad.hasVertices()) { +// return quad; +// } +// std::cout << "getMeshForSubsection " << ofGetFrameNum() << std::endl; + + GLfloat px0 { x }; // up to you to get the aspect ratio right + GLfloat py0 { y }; + GLfloat px1 { w+x }; + GLfloat py1 { h+y }; if (texData.bFlipTexture == vflipped){ std::swap(py0,py1); @@ -1094,10 +1107,10 @@ ofMesh ofTexture::getMeshForSubsection(float x, float y, float z, float w, float // for rect mode center, let's do this: if (rectMode == OF_RECTMODE_CENTER){ - px0 -= w/2; - py0 -= h/2; - px1 -= w/2; - py1 -= h/2; + px0 -= w*0.5; + py0 -= h*0.5; + px1 -= w*0.5; + py1 -= h*0.5; } //we translate our drawing points by our anchor point. @@ -1128,8 +1141,8 @@ ofMesh ofTexture::getMeshForSubsection(float x, float y, float z, float w, float // to constantly add a 2 pixel border on all uploaded images // is insane.. - GLfloat offsetw = 0.0f; - GLfloat offseth = 0.0f; + GLfloat offsetw { 0.0f }; + GLfloat offseth { 0.0f }; if (!ofGLSupportsNPOTTextures() && bTexHackEnabled) { offsetw = 1.0f / (texData.tex_w); @@ -1137,26 +1150,41 @@ ofMesh ofTexture::getMeshForSubsection(float x, float y, float z, float w, float } // ------------------------------------------------- - auto topLeft = getCoordFromPoint(sx, sy); - auto bottomRight = getCoordFromPoint(sx + sw, sy + sh); + auto topLeft { getCoordFromPoint(sx, sy) }; + auto bottomRight { getCoordFromPoint(sx + sw, sy + sh) }; - GLfloat tx0 = topLeft.x + offsetw; - GLfloat ty0 = topLeft.y + offseth; - GLfloat tx1 = bottomRight.x - offsetw; - GLfloat ty1 = bottomRight.y - offseth; + GLfloat tx0 { topLeft.x + offsetw }; + GLfloat ty0 { topLeft.y + offseth }; + GLfloat tx1 { bottomRight.x - offsetw }; + GLfloat ty1 { bottomRight.y - offseth }; quad.setMode(OF_PRIMITIVE_TRIANGLE_FAN); quad.getVertices().resize(4); quad.getTexCoords().resize(4); - quad.getVertices()[0] = {px0,py0,z}; - quad.getVertices()[1] = {px1,py0,z}; - quad.getVertices()[2] = {px1,py1,z}; - quad.getVertices()[3] = {px0,py1,z}; + + quad.getVertices() = { + {px0,py0,z}, + {px1,py0,z}, + {px1,py1,z}, + {px0,py1,z}, + }; - quad.getTexCoords()[0] = {tx0,ty0}; - quad.getTexCoords()[1] = {tx1,ty0}; - quad.getTexCoords()[2] = {tx1,ty1}; - quad.getTexCoords()[3] = {tx0,ty1}; + quad.getTexCoords() = { + {tx0,ty0}, + {tx1,ty0}, + {tx1,ty1}, + {tx0,ty1}, + }; + + // quad.getVertices()[0] = {px0,py0,z}; +// quad.getVertices()[1] = {px1,py0,z}; +// quad.getVertices()[2] = {px1,py1,z}; +// quad.getVertices()[3] = {px0,py1,z}; + +// quad.getTexCoords()[0] = {tx0,ty0}; +// quad.getTexCoords()[1] = {tx1,ty0}; +// quad.getTexCoords()[2] = {tx1,ty1}; +// quad.getTexCoords()[3] = {tx0,ty1}; return quad; } diff --git a/libs/openFrameworks/gl/ofTexture.h b/libs/openFrameworks/gl/ofTexture.h index 903deb38ce2..3e2d48e7b3f 100644 --- a/libs/openFrameworks/gl/ofTexture.h +++ b/libs/openFrameworks/gl/ofTexture.h @@ -8,6 +8,7 @@ #define GLM_ENABLE_EXPERIMENTAL #include + class ofRectangle; template @@ -948,6 +949,7 @@ class ofTexture : public ofBaseDraws { ofTextureData texData; ///< Internal texture data access. ///< For backwards compatibility. + protected: /// \brief Enable a texture target. diff --git a/libs/openFrameworks/math/ofMathConstants.h b/libs/openFrameworks/math/ofMathConstants.h index 4e660e5ee01..2dd0609c690 100644 --- a/libs/openFrameworks/math/ofMathConstants.h +++ b/libs/openFrameworks/math/ofMathConstants.h @@ -21,47 +21,47 @@ using ofDefaultVec4 = glm::vec4; #endif -#ifndef PI - #define PI 3.14159265358979323846 -#endif - -#ifndef TWO_PI - #define TWO_PI 6.28318530717958647693 -#endif - -#ifndef M_TWO_PI - #define M_TWO_PI 6.28318530717958647693 -#endif - -#ifndef FOUR_PI - #define FOUR_PI 12.56637061435917295385 -#endif - -#ifndef HALF_PI - #define HALF_PI 1.57079632679489661923 -#endif - -#ifndef DEG_TO_RAD - #define DEG_TO_RAD (PI/180.0) -#endif - -#ifndef RAD_TO_DEG - #define RAD_TO_DEG (180.0/PI) -#endif - -#ifndef MIN - #define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#endif - -#ifndef MAX - #define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef CLAMP - #define CLAMP(val,min,max) ((val) < (min) ? (min) : ((val > max) ? (max) : (val))) -#endif - -#ifndef ABS - #define ABS(x) (((x) < 0) ? -(x) : (x)) -#endif - +//#ifndef PI +// #define PI 3.14159265358979323846 +//#endif +// +//#ifndef TWO_PI +// #define TWO_PI 6.28318530717958647693 +//#endif +// +//#ifndef M_TWO_PI +// #define M_TWO_PI 6.28318530717958647693 +//#endif +// +//#ifndef FOUR_PI +// #define FOUR_PI 12.56637061435917295385 +//#endif +// +//#ifndef HALF_PI +// #define HALF_PI 1.57079632679489661923 +//#endif +// +//#ifndef DEG_TO_RAD +// #define DEG_TO_RAD (PI/180.0) +//#endif +// +//#ifndef RAD_TO_DEG +// #define RAD_TO_DEG (180.0/PI) +//#endif +// +//#ifndef MIN +// #define MIN(x,y) (((x) < (y)) ? (x) : (y)) +//#endif +// +//#ifndef MAX +// #define MAX(x,y) (((x) > (y)) ? (x) : (y)) +//#endif +// +//#ifndef CLAMP +// #define CLAMP(val,min,max) ((val) < (min) ? (min) : ((val > max) ? (max) : (val))) +//#endif +// +//#ifndef ABS +// #define ABS(x) (((x) < 0) ? -(x) : (x)) +//#endif +// From 3739134783e3fc21d4d1e4e80e68db97ad2e7032 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 May 2024 18:41:46 -0300 Subject: [PATCH 091/143] update rpi actions --- .github/workflows/build-rpi.yml | 55 +++++++++++++++++++++++++++++++++ apps/projectGenerator | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-rpi.yml diff --git a/.github/workflows/build-rpi.yml b/.github/workflows/build-rpi.yml new file mode 100644 index 00000000000..6ed0aaf4605 --- /dev/null +++ b/.github/workflows/build-rpi.yml @@ -0,0 +1,55 @@ +name: build-rpi + +# make the action not run on the local repo if the branch is also in a pull request to OF/OF +on: + push: + if: github.event_name == 'push' && github.event.pull_request == null + paths-ignore: + - '**/*.md' + - 'examples/**' + pull_request: + if: github.event_name == 'pull_request' && github.repository == 'openframeworks/openFrameworks' + paths-ignore: + - '**/*.md' + - 'examples/**' + +env: + ccache: ccache + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + rpi-build: + runs-on: ubuntu-latest + strategy: + matrix: + cfg: + - { libs: armv6l, multistrap_arch: armhf, suffix: arm-linux-gnueabihf, alladdons: 1 } + - { libs: aarch64, multistrap_arch: arm64, suffix: aarch64-linux-gnu, alladdons: 1 } + env: + ARCH: ${{matrix.cfg.libs}} + MULTISTRAP_ARCH: ${{matrix.cfg.multistrap_arch}} + ALLADDONSEXAMPLE: ${{matrix.cfg.alladdons}} + steps: + - name: Cache Packages + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: multistrap unzip gcc-${{matrix.cfg.suffix}} g++-${{matrix.cfg.suffix}} + version: 1.0 + + - uses: actions/checkout@v4 + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2.12 + with: + key: ${{ matrix.cfg.libs }} + + - name: Download libs + run: ./scripts/linux/download_libs.sh -a ${{matrix.cfg.libs}}; + - name: Install dependencies + run: ./scripts/ci/linuxrpi/install.sh; + - name: Build + run: ./scripts/ci/linuxrpi/build.sh; + diff --git a/apps/projectGenerator b/apps/projectGenerator index db8c6e92bfc..22db54d0c4f 160000 --- a/apps/projectGenerator +++ b/apps/projectGenerator @@ -1 +1 @@ -Subproject commit db8c6e92bfc08d69f20bea2e6f37096cc7e650ae +Subproject commit 22db54d0c4f84ae71a6f09e876c592c5f8779b93 From b47948464f1a6fee7589d9e6a5cd5827ba7e92e0 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 May 2024 18:45:27 -0300 Subject: [PATCH 092/143] up --- scripts/ci/linuxrpi/build.sh | 50 +++++++++++++++++++++++++++++ scripts/ci/linuxrpi/install.sh | 34 ++++++++++++++++++++ scripts/ci/linuxrpi/multistrap.conf | 21 ++++++++++++ scripts/osx/cxx.sh | 1 - scripts/osx/download_latest_libs.sh | 16 ++------- 5 files changed, 107 insertions(+), 15 deletions(-) create mode 100755 scripts/ci/linuxrpi/build.sh create mode 100755 scripts/ci/linuxrpi/install.sh create mode 100644 scripts/ci/linuxrpi/multistrap.conf diff --git a/scripts/ci/linuxrpi/build.sh b/scripts/ci/linuxrpi/build.sh new file mode 100755 index 00000000000..b6a7208b203 --- /dev/null +++ b/scripts/ci/linuxrpi/build.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -ev +OF_ROOT=$( cd "$(dirname "$0")/../../.." ; pwd -P ) + +export CROSS_COMPILING=1 + +# Allows test locally without github actions env variables. +if [ -n "$ARCH" ]; then +export PLATFORM_ARCH=${ARCH} +else +# github actions will be defining this one, next line will set if we are working locally +export PLATFORM_ARCH=armv6l +# export PLATFORM_ARCH=aarch64 +fi + +export RPI_ROOT=${OF_ROOT}/scripts/ci/linuxrpi/raspbian +echo "${RPI_ROOT}" + +if [ ${PLATFORM_ARCH} = "aarch64" ]; then +export GCC_PREFIX=aarch64-linux-gnu +else +export GCC_PREFIX=arm-linux-gnueabihf +fi + +export GST_VERSION=1.0 +export PLATFORM_OS=Linux + +# export PKG_CONFIG_LIBDIR= +export PKG_CONFIG_PATH=${BCM_FOLDER}:${RPI_ROOT}/usr/include:${RPI_ROOT}/usr/lib/pkgconfig:${RPI_ROOT}/usr/lib/${GCC_PREFIX}/pkgconfig:${RPI_ROOT}/usr/share/pkgconfig +export TOOLCHAIN_ROOT=/usr +export CXX="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-g++" +export CC="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-gcc" +export AR=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ar +export LD=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ld + +echo "**** Building emptyExample ****" +cd $OF_ROOT +cp scripts/templates/linux${PLATFORM_ARCH}/Makefile examples/templates/emptyExample/ +cp scripts/templates/linux${PLATFORM_ARCH}/config.make examples/templates/emptyExample/ +cd examples/templates/emptyExample/ +make Debug -j + +# if [[ "$ALLADDONSEXAMPLE" == 1 ]]; then +echo "**** Building allAddonsExample ****" +cd $OF_ROOT +cp scripts/templates/linux${PLATFORM_ARCH}/Makefile examples/templates/allAddonsExample/ +cp scripts/templates/linux${PLATFORM_ARCH}/config.make examples/templates/allAddonsExample/ +cd examples/templates/allAddonsExample/ +make Debug -j +# fi \ No newline at end of file diff --git a/scripts/ci/linuxrpi/install.sh b/scripts/ci/linuxrpi/install.sh new file mode 100755 index 00000000000..f236fd122a7 --- /dev/null +++ b/scripts/ci/linuxrpi/install.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e +set -o pipefail +# trap any script errors and exit +trap "trapError" ERR + +if [ -n "$MULTISTRAP_ARCH" ]; then +echo ${MULTISTRAP_ARCH} +else +export MULTISTRAP_ARCH=armhf +fi + +trapError() { + echo + echo " ^ Received error ^" + cat formula.log + exit 1 +} + +# SCRIPT_DIR="${BASH_SOURCE%/*}" +# if [[ ! -d "$SCRIPT_DIR" ]]; then SCRIPT_DIR="$PWD"; fi +# . "$SCRIPT_DIR/../../dev/downloader.sh" + +ROOT=$( cd "$(dirname "$0")" ; pwd -P ) +echo $ROOT +cd $ROOT + +mkdir -p raspbian/etc/apt/apt.conf.d/ +echo 'Acquire::AllowInsecureRepositories "true";' | sudo tee raspbian/etc/apt/apt.conf.d/90insecure +multistrap -a ${MULTISTRAP_ARCH} -d raspbian -f multistrap.conf + +if [ ${MULTISTRAP_ARCH} = "armhf" ]; then + git clone https://github.com/raspberrypi/userland --depth 1 raspbian/userland +fi diff --git a/scripts/ci/linuxrpi/multistrap.conf b/scripts/ci/linuxrpi/multistrap.conf new file mode 100644 index 00000000000..8f3008bdf4c --- /dev/null +++ b/scripts/ci/linuxrpi/multistrap.conf @@ -0,0 +1,21 @@ +[General] +# arch=arm64 +directory=~/raspbian +cleanup=true +noauth=true +unpack=true +aptsources=OpenFrameworks +debootstrap=OpenFrameworks + +[OpenFrameworks] +packages=libudev-dev libasound2-dev libxmu-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libssl-dev libpulse-dev libusb-1.0-0-dev libopencv-dev libegl1-mesa-dev libglvnd-dev libgles2-mesa-dev libassimp-dev librtaudio-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav gstreamer1.0-pulseaudio gstreamer1.0-x gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good liburiparser-dev libcurl4-openssl-dev libxml2-dev libpugixml-dev libpoco-dev libglfw3-dev libxrandr-dev libxinerama-dev libxcursor-dev freeglut3-dev libxi-dev liblapack-dev libblas-dev + +# g++ base-files dbus dpkg dropbear initscripts iputils-ping isc-dhcp-client kmod login locales lsb-base lsb-release makedev netbase net-tools sysvinit-utils sysv-rc +# libboost-filesystem-dev +# libraspberrypi-dev raspberrypi-kernel-headers +# libblas3 liblapack3 +# libopenblas-dev liblapack-dev +source=http://deb.debian.org/debian +keyring=debian-archive-keyring +components=main contrib non-free rpi +suite=bookworm diff --git a/scripts/osx/cxx.sh b/scripts/osx/cxx.sh index ab44ff4837c..48bd528bffa 100755 --- a/scripts/osx/cxx.sh +++ b/scripts/osx/cxx.sh @@ -1,4 +1,3 @@ #!/bin/zsh ${ccache} clang++ "$@" -# clang++ "$@" diff --git a/scripts/osx/download_latest_libs.sh b/scripts/osx/download_latest_libs.sh index 87958f2e171..61fbbb6aed3 100755 --- a/scripts/osx/download_latest_libs.sh +++ b/scripts/osx/download_latest_libs.sh @@ -1,22 +1,10 @@ #!/usr/bin/env bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $SCRIPT_DIR -# cd $SCRIPT_DIR +cd $SCRIPT_DIR if [ ! -z ${BITS+x} ]; then ../dev/download_libs.sh -p osx -b -a $BITS $@ else - # ../dev/download_libs.sh -p osx -b -a x86_64 $@ + ../dev/download_libs.sh -p osx -b -a x86_64 $@ ../dev/download_libs.sh -p osx -b -a arm64 -n $@ fi - - -# URL_LIST=('https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_1.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_2.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_3.tar.bz2') - -# echo $URL_LIST -# echo $URL_LIST | xargs -n 1 -P 8 curl -LO -q - -# wget -b $URL_LIST[0] -# wget -b $URL_LIST[1] -# wget -b $URL_LIST[2] - -# wget2 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_1.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_2.tar.bz2' 'https://github.com/openframeworks/apothecary/releases/download/bleeding/openFrameworksLibs_bleeding_osx_3.tar.bz2' \ No newline at end of file From 80f4449cd40b7fa587e92692c894ebaa2291edc4 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 May 2024 18:45:51 -0300 Subject: [PATCH 093/143] downloader --- scripts/dev/downloader.sh | 41 +++++++++++++-------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/scripts/dev/downloader.sh b/scripts/dev/downloader.sh index 2f11618da56..c2fe46c3d48 100755 --- a/scripts/dev/downloader.sh +++ b/scripts/dev/downloader.sh @@ -13,37 +13,24 @@ EOF } downloader() { + if [ -z "$1" ] then printDownloaderHelp; fi - SILENTARGS=""; - if [ $# -ge 2 ]; then - SILENTARGS=$2 - fi - if [[ "${SILENTARGS}" == "-s" ]]; then - if command -v wget2 2>/dev/null; then - wget2 -q $@; - elif command -v curl 2>/dev/null; then - for PKG in $@; do - curl -LO --retry 20 -O -s $PKG; - done - else - for PKG in $@; do - wget -q $PKG@ 2> /dev/null; - done - fi; + SILENTARGS=""; + if [ $# -ge 2 ]; then + SILENTARGS=$2 + fi + if [[ "${SILENTARGS}" == "-s" ]]; then + if command -v curl 2>/dev/null; then + curl -LO --retry 20 -O -s $@; + else + wget -q $@ 2> /dev/null; fi; else - if command -v wget2 2>/dev/null; then - wget2 $@; - elif command -v curl 2>/dev/null; then - for PKG in $@; do - curl -LO --retry 20 -O --progress-bar $PKG; - done - else - for PKG in $@; do - wget $PKG 2> /dev/null; - done - fi; + if command -v curl 2>/dev/null; then + curl -LO --retry 20 -O --progress-bar $@; + else + wget $@ 2> /dev/null; fi; fi From e7884587cd714917154ad7d019415805ef67abbe Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 6 May 2024 19:40:07 -0300 Subject: [PATCH 094/143] changes in fps --- libs/openFrameworks/utils/ofFpsCounter.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/utils/ofFpsCounter.h b/libs/openFrameworks/utils/ofFpsCounter.h index 99760a2f0f1..38137a118d1 100644 --- a/libs/openFrameworks/utils/ofFpsCounter.h +++ b/libs/openFrameworks/utils/ofFpsCounter.h @@ -75,13 +75,11 @@ struct fpsCounter { double getFps() { average = std::reduce(intervals.begin(), intervals.end()); - return intervals.size() * onesec / average; + return (double)intervals.size() * onesec / average; } float get() { -// average = std::reduce(intervals.begin(), intervals.end())/intervals.size(); -// return onesec / average; average = std::reduce(intervals.begin(), intervals.end()); - return intervals.size() * onesec / average; + return (float)intervals.size() * onesec / average; } }; From 77b3128e2a8ced71532295cbfb89be000468ae25 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 10 May 2024 21:30:43 -0300 Subject: [PATCH 095/143] up --- libs/openFrameworks/utils/ofFpsCounter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/utils/ofFpsCounter.h b/libs/openFrameworks/utils/ofFpsCounter.h index 38137a118d1..8621e5d461b 100644 --- a/libs/openFrameworks/utils/ofFpsCounter.h +++ b/libs/openFrameworks/utils/ofFpsCounter.h @@ -44,7 +44,7 @@ class ofFpsCounter { using namespace std::chrono; using namespace std::chrono_literals; -struct fpsCounter { +struct fpsCounterX { public: int nAverages = 20; using space = std::chrono::duration; From 4917e2e229d48b7e4fc7c0f3c1862829f413c027 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 10 May 2024 22:11:52 -0300 Subject: [PATCH 096/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 91e6480a5ac..bc2ce25b440 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -188,17 +188,19 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { monitor = allMonitors.monitors[monitorIndex]; } - - // cout << "will create window" << endl; // cout << "monitors size: " << allMonitors.rects.size() << endl; bool displayOK = false; if (settings.fullscreenDisplays.size()) { for (auto & d : settings.fullscreenDisplays) { cout << "GLFWWindow fullscreenDisplays " << d << " : " << allMonitors.rects.size() << endl; - if (d <= (allMonitors.rects.size()-1)) { + if (d < allMonitors.rects.size()) { +// cout << "glfw ok opening " << endl; displayOK = true; - break; +// break; + } else { +// cout << "glfw not enough displays" << endl; +// return nullptr; } // cout << d << endl; } @@ -206,13 +208,15 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { displayOK = true; } +// cout << "glfw displayok " << displayOK << endl; windowP = glfwCreateWindow(settings.getWidth(), settings.getHeight(), settings.title.c_str(), monitor, sharedContext); - if (displayOK) { + glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); } else { // MARK: - WINDOW - glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); +// cout << "glfw hint visible false" << endl; + glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // return; } From ba0a9c4c904ee295e4b00371511e8b5b61f37e5f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 12 May 2024 21:45:59 -0300 Subject: [PATCH 097/143] up --- .../openFrameworks/video/ofDirectShowPlayer.h | 1 + libs/openFrameworks/video/ofGstUtils.cpp | 1 - .../config.linuxaarch64.default.mk | 14 +++---- .../project/makefileCommon/compile.core.mk | 38 ++++++------------- .../project/makefileCommon/compile.project.mk | 6 +-- .../makefileCommon/config.linux.common.mk | 8 ---- .../project/makefileCommon/config.project.mk | 7 +++- scripts/ci/linuxrpi/build.sh | 19 ---------- scripts/dev/download_libs.sh | 24 ++++-------- 9 files changed, 34 insertions(+), 84 deletions(-) diff --git a/libs/openFrameworks/video/ofDirectShowPlayer.h b/libs/openFrameworks/video/ofDirectShowPlayer.h index c404fd11948..427d14ba0d5 100644 --- a/libs/openFrameworks/video/ofDirectShowPlayer.h +++ b/libs/openFrameworks/video/ofDirectShowPlayer.h @@ -8,6 +8,7 @@ template class ofPixels_; + typedef ofPixels_ ofPixels; class DirectShowVideo; diff --git a/libs/openFrameworks/video/ofGstUtils.cpp b/libs/openFrameworks/video/ofGstUtils.cpp index 21e5aac8f58..4ab125d692f 100644 --- a/libs/openFrameworks/video/ofGstUtils.cpp +++ b/libs/openFrameworks/video/ofGstUtils.cpp @@ -1,5 +1,4 @@ #include "ofGstUtils.h" - #ifndef TARGET_ANDROID #include #include diff --git a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk index 5a28173ad11..bdf92f3871d 100644 --- a/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk +++ b/libs/openFrameworksCompiled/project/linuxaarch64/config.linuxaarch64.default.mk @@ -53,10 +53,10 @@ PLATFORM_CFLAGS += -mcpu=cortex-a72 PLATFORM_CFLAGS += -mtune=cortex-a72 # PLATFORM_CFLAGS += -Wall # PLATFORM_CFLAGS += -Werror -# PLATFORM_CFLAGS += -fPIC -# PLATFORM_CFLAGS += -ftree-vectorize -# PLATFORM_CFLAGS += -Wno-psabi -# PLATFORM_CFLAGS += -pipe +PLATFORM_CFLAGS += -fPIC +PLATFORM_CFLAGS += -ftree-vectorize +PLATFORM_CFLAGS += -Wno-psabi +PLATFORM_CFLAGS += -pipe ################################################################################ # PLATFORM LIBRARIES @@ -81,11 +81,7 @@ PLATFORM_PKG_CONFIG_LIBRARIES += glesv1_cm PLATFORM_PKG_CONFIG_LIBRARIES += glesv2 PLATFORM_PKG_CONFIG_LIBRARIES += egl -## TEST -PLATFORM_PKG_CONFIG_LIBRARIES += gl -PLATFORM_PKG_CONFIG_LIBRARIES += glu -PLATFORM_PKG_CONFIG_LIBRARIES += glew -PLATFORM_LIBRARIES += glfw + ################################################################################ # PLATFORM CORE EXCLUSIONS # During compilation, these makefiles will generate lists of sources, headers diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk index 8278aea5327..9efe24699b4 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.core.mk @@ -145,7 +145,7 @@ ifeq ($(findstring Release,$(TARGET_NAME)),Release) endif ifeq ($(findstring Debug,$(TARGET_NAME)),Debug) - ifdef _DEBUG + ifdef ABIS_TO_COMPILE_DEBUG ifeq ($(findstring Release,$(TARGET_NAME)),Release) ifdef ABIS_TO_COMPILE_RELEASE ABIS_TO_COMPILE = $(filter-out $(ABIS_TO_COMPILE_DEBUG),$(ABIS_TO_COMPILE_RELEASE)) @@ -208,35 +208,21 @@ endif # avoid conflict with files of the same name and to improve performance. .PHONY: all Debug Release after clean CleanDebug CleanRelease help force -USE_CORES=-j1 - -# ifeq ($(PLATFORM_ARCH),armv6l) -# USE_CORES=-j2 -# endif - -# ifeq ($(PLATFORM_ARCH),armv7l) -# USE_CORES=-j2 -# endif - -# ifeq ($(PLATFORM_ARCH),aarch64) -# USE_CORES=-j3 -# endif - Release: ifndef ABIS_TO_COMPILE_RELEASE - @$(MAKE) $(USE_CORES) --no-print-directory ReleaseABI + @$(MAKE) --no-print-directory ReleaseABI else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) --no-print-directory ReleaseABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) --no-print-directory ReleaseABI ABI=$(abi) &&) echo endif - @$(MAKE) $(USE_CORES) --no-print-directory after + @$(MAKE) --no-print-directory after Debug: ifndef ABIS_TO_COMPILE_DEBUG - @$(MAKE) $(USE_CORES) --no-print-directory DebugABI + @$(MAKE) --no-print-directory DebugABI else - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) --no-print-directory DebugABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) --no-print-directory DebugABI ABI=$(abi) &&) echo endif - @$(MAKE) $(USE_CORES) --no-print-directory after + @$(MAKE) --no-print-directory after # Release will pass the library name (i.e. ... libopenFrameworks.a) # down the the @(TARGET) target @@ -248,8 +234,8 @@ DebugABI: $(TARGET) # all will first run the debug target, then the release target all: - @$(MAKE) $(USE_CORES) --no-print-directory Debug - @$(MAKE) $(USE_CORES) --no-print-directory Release + @$(MAKE) --no-print-directory Debug + @$(MAKE) --no-print-directory Release $(OF_CORE_OBJ_OUTPUT_PATH).compiler_flags: force @mkdir -p $(OF_CORE_OBJ_OUTPUT_PATH) @@ -308,12 +294,12 @@ $(CLEANTARGET)ABI: $(CLEANTARGET): ifndef ABIS_TO_COMPILE - $(MAKE) $(USE_CORES) --no-print-directory $(CLEANTARGET)ABI + $(MAKE) --no-print-directory $(CLEANTARGET)ABI else ifeq ($(TARGET_NAME),Debug) - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) --no-print-directory $(CLEANTARGET)ABI ABI=$(abi) &&) echo done endif endif diff --git a/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk b/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk index bc2a6b04923..2ae26267cc5 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk @@ -145,7 +145,7 @@ Debug: ifndef ABIS_TO_COMPILE_DEBUG @$(MAKE) $(JOBS) DebugABI else - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) DebugABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) DebugABI ABI=$(abi) &&) echo endif ReleaseNoOF: @@ -153,7 +153,7 @@ ReleaseNoOF: ifndef ABIS_TO_COMPILE_RELEASE @$(MAKE) $(JOBS) ReleaseABI else - @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(USE_CORES) ReleaseABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) ReleaseABI ABI=$(abi) &&) echo endif DebugNoOF: @@ -161,7 +161,7 @@ DebugNoOF: ifndef ABIS_TO_COMPILE_DEBUG @$(MAKE) $(JOBS) DebugABI else - @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(USE_CORES) DebugABI ABI=$(abi) &&) echo + @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) DebugABI ABI=$(abi) &&) echo endif ReleaseABI: $(TARGET) diff --git a/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk b/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk index cea1856fa03..5a0ed9e6fad 100755 --- a/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/config.linux.common.mk @@ -22,10 +22,6 @@ ifeq ($(PLATFORM_ARCH),armv7l) LINUX_ARM=1 endif -ifeq ($(PLATFORM_ARCH),aarch64) - LINUX_ARM=1 -endif - #check if gtk exists and add it ifeq ($(CROSS_COMPILING),1) HAS_SYSTEM_GTK3 = $(shell export PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR);pkg-config gtk+-3.0 --exists; echo $$?) @@ -259,7 +255,6 @@ PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofMediaFoundati ifeq ($(LINUX_ARM),1) PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGlutWindow.cpp - PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp else PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp endif @@ -401,9 +396,6 @@ ifneq ($(LINUX_ARM),1) PLATFORM_PKG_CONFIG_LIBRARIES += gl PLATFORM_PKG_CONFIG_LIBRARIES += glu PLATFORM_PKG_CONFIG_LIBRARIES += glew -## TEST -else - PLATFORM_PKG_CONFIG_LIBRARIES += glew endif diff --git a/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk b/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk index 4fc3a255f82..9c366b5886f 100644 --- a/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk +++ b/libs/openFrameworksCompiled/project/makefileCommon/config.project.mk @@ -389,8 +389,11 @@ ifdef PLATFORM_CC CC ?= $(PLATFORM_CC) endif -CXX := time ${ccache} $(CXX) -CC := time ${ccache} $(CXX) +ifdef ${ccache} +$(info 💿 Using CCACHE -- config.project.mk ) + CXX := ${ccache} $(CXX) + CC := ${ccache} $(CXX) +endif ifdef PROJECT_RESOURCE_COMPILER RESOURCE_COMPILER ?= $(PROJECT_RESOURCE_COMPILER) diff --git a/scripts/ci/linuxrpi/build.sh b/scripts/ci/linuxrpi/build.sh index 33c73abe526..0ff366e1cc0 100755 --- a/scripts/ci/linuxrpi/build.sh +++ b/scripts/ci/linuxrpi/build.sh @@ -1,9 +1,5 @@ #!/bin/bash -<<<<<<< HEAD -set -ev -======= # set -ev ->>>>>>> master OF_ROOT=$( cd "$(dirname "$0")/../../.." ; pwd -P ) export CROSS_COMPILING=1 @@ -37,35 +33,20 @@ export CC="${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-gcc" export AR=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ar export LD=${TOOLCHAIN_ROOT}/bin/${GCC_PREFIX}-ld -<<<<<<< HEAD -echo "**** Building emptyExample ****" -======= echo "##[group]**** Building emptyExample ****" ->>>>>>> master cd $OF_ROOT cp scripts/templates/linux${PLATFORM_ARCH}/Makefile examples/templates/emptyExample/ cp scripts/templates/linux${PLATFORM_ARCH}/config.make examples/templates/emptyExample/ cd examples/templates/emptyExample/ -<<<<<<< HEAD -make Debug -j - -# if [[ "$ALLADDONSEXAMPLE" == 1 ]]; then -echo "**** Building allAddonsExample ****" -======= make Debug -j2 echo "##[endgroup]" # if [[ "$ALLADDONSEXAMPLE" == 1 ]]; then echo "##[group]**** Building allAddonsExample ****" ->>>>>>> master cd $OF_ROOT cp scripts/templates/linux${PLATFORM_ARCH}/Makefile examples/templates/allAddonsExample/ cp scripts/templates/linux${PLATFORM_ARCH}/config.make examples/templates/allAddonsExample/ cd examples/templates/allAddonsExample/ -<<<<<<< HEAD -make Debug -j -======= make Debug -j2 echo "##[endgroup]" ->>>>>>> master # fi \ No newline at end of file diff --git a/scripts/dev/download_libs.sh b/scripts/dev/download_libs.sh index 5605cd3f551..11c6ca8bdbc 100755 --- a/scripts/dev/download_libs.sh +++ b/scripts/dev/download_libs.sh @@ -33,21 +33,15 @@ if [[ ! -d "$SCRIPT_DIR" ]]; then SCRIPT_DIR="$PWD"; fi . "$SCRIPT_DIR/downloader.sh" download(){ - echo '-----' echo "Downloading $1" # downloader ci.openframeworks.cc/libs/$1 $SILENT_ARGS - - COMMAND=" " - REPO="nightly" if [[ $BLEEDING_EDGE = 1 ]] ; then - REPO="bleeding" + echo downloader https://github.com/openframeworks/apothecary/releases/download/bleeding/$1 $SILENT_ARGS + downloader https://github.com/openframeworks/apothecary/releases/download/bleeding/$1 $SILENT_ARGS + else + echo downloader https://github.com/openframeworks/apothecary/releases/download/nightly/$1 $SILENT_ARGS + downloader https://github.com/openframeworks/apothecary/releases/download/nightly/$1 $SILENT_ARGS fi - - for PKG in $1; do - COMMAND+="https://github.com/openframeworks/apothecary/releases/download/$REPO/$PKG " - done - echo $COMMAND; - downloader $COMMAND $SILENT_ARGS } # trap any script errors and exit @@ -229,11 +223,9 @@ else # Linux fi fi -# for PKG in $PKGS; do -# download $PKG -# done -# echo $PKGS -download "${PKGS[@]}" +for PKG in $PKGS; do + download $PKG +done cd ../../ mkdir -p libs From b181abb7f6d2eacd6162df5f2bc5552bf04801b6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 12 May 2024 21:47:52 -0300 Subject: [PATCH 098/143] up --- libs/openFrameworks/utils/ofTimer.h | 5 ++- libs/openFrameworks/utils/ofUtils.cpp | 44 +++------------------------ 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/libs/openFrameworks/utils/ofTimer.h b/libs/openFrameworks/utils/ofTimer.h index d03f824e5a9..8e8db12681c 100644 --- a/libs/openFrameworks/utils/ofTimer.h +++ b/libs/openFrameworks/utils/ofTimer.h @@ -2,8 +2,11 @@ #include "ofUtils.h" + + class ofTimer { public: + /// \brief Constructs the default ofTimer(). ofTimer(); @@ -15,8 +18,8 @@ class ofTimer { /// The timer will begin calculating the events beginning the moment /// the function is called. /// \param nanoseconds The number of nanoseconds between events. - void setPeriodicEvent(std::chrono::nanoseconds t); void setPeriodicEvent(uint64_t nanoseconds); + /// \brief Sleep this thread until the next periodic event. void waitNext(); private: diff --git a/libs/openFrameworks/utils/ofUtils.cpp b/libs/openFrameworks/utils/ofUtils.cpp index 679dab7b639..7be8607ee65 100644 --- a/libs/openFrameworks/utils/ofUtils.cpp +++ b/libs/openFrameworks/utils/ofUtils.cpp @@ -77,35 +77,6 @@ void endutils() { //#endif } -class timeCounterOF { -public: - time_point startTime; - typedef std::chrono::duration> duration; - - timeCounterOF() { - reset(); - } - - void reset() { - startTime = steady_clock::now(); - } - - std::chrono::duration getElapsedTime() { - return steady_clock::now() - startTime; - } - -// std::chrono::nanoseconds getElapsedTime() { -// return duration_cast(steady_clock::now() - startTime); -// } - - float getElapsedTimef() { - duration d = steady_clock::now() - startTime; - return d.count(); - } -} timeCounter; - - - class Clock { public: Clock() { @@ -339,27 +310,22 @@ ofTime ofGetCurrentTime() { //-------------------------------------- uint64_t ofGetElapsedTimeMillis() { - return std::chrono::duration_cast(of::priv::timeCounter.getElapsedTime()).count(); -// return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); + return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); } //-------------------------------------- uint64_t ofGetElapsedTimeMicros() { - return std::chrono::duration_cast(of::priv::timeCounter.getElapsedTime()).count(); -// return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); + return std::chrono::duration_cast(of::priv::getClock().getElapsedTime()).count(); } //-------------------------------------- float ofGetElapsedTimef() { -// std::cout << of::priv::timeCounter.getElapsedTimef() << std::endl; - return of::priv::timeCounter.getElapsedTimef(); -// return std::chrono::duration(of::priv::getClock().getElapsedTime()).count(); + return std::chrono::duration(of::priv::getClock().getElapsedTime()).count(); } //-------------------------------------- void ofResetElapsedTimeCounter() { - of::priv::timeCounter.reset(); -// of::priv::getClock().resetElapsedTimeCounter(); + of::priv::getClock().resetElapsedTimeCounter(); } //-------------------------------------- @@ -1057,7 +1023,6 @@ std::string ofGetVersionPreRelease() { //from the forums http://www.openframeworks.cc/forum/viewtopic.php?t=1413 //-------------------------------------------------- -// FIXME: filesystem void ofSaveScreen(const string & filename) { /*ofImage screen; screen.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR); @@ -1069,7 +1034,6 @@ void ofSaveScreen(const string & filename) { } //-------------------------------------------------- -// FIXME: filesystem void ofSaveViewport(const string & filename) { // because ofSaveScreen doesn't related to viewports /*ofImage screen; From 3f069c2e9b7a4675e8ed86bde63a32170e9c4d00 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 13 May 2024 13:49:51 -0300 Subject: [PATCH 099/143] fps counter back original --- libs/openFrameworks/utils/ofFpsCounter.h | 49 ------------------------ 1 file changed, 49 deletions(-) diff --git a/libs/openFrameworks/utils/ofFpsCounter.h b/libs/openFrameworks/utils/ofFpsCounter.h index 8621e5d461b..066daee41b3 100644 --- a/libs/openFrameworks/utils/ofFpsCounter.h +++ b/libs/openFrameworks/utils/ofFpsCounter.h @@ -4,7 +4,6 @@ #include "ofUtils.h" #include - class ofFpsCounter { public: ofFpsCounter(); @@ -35,51 +34,3 @@ class ofFpsCounter { double filterAlpha; std::queue timestamps; }; - - - - - -#include -using namespace std::chrono; -using namespace std::chrono_literals; - -struct fpsCounterX { -public: - int nAverages = 20; - using space = std::chrono::duration; - time_point lastTick; - steady_clock::duration onesec = 1s; - std::vector intervals; - space interval; - space average; - bool firstTick = true; - int cursor = 0; - - void tick() { - if (firstTick) { - firstTick = false; - lastTick = steady_clock::now(); - return; - } - - interval = steady_clock::now() - lastTick; - lastTick = steady_clock::now(); - if (intervals.size() < nAverages) { - intervals.emplace_back(interval); - } else { - intervals[cursor] = interval; - cursor = (cursor+1)%nAverages; - } - } - - double getFps() { - average = std::reduce(intervals.begin(), intervals.end()); - return (double)intervals.size() * onesec / average; - } - - float get() { - average = std::reduce(intervals.begin(), intervals.end()); - return (float)intervals.size() * onesec / average; - } -}; From 6a235affac334f42d9e569c5b337bf62bcbb9d32 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 13 May 2024 19:58:30 -0300 Subject: [PATCH 100/143] ofxOpenCv --- addons/ofxOpenCv/addon_config.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/ofxOpenCv/addon_config.mk b/addons/ofxOpenCv/addon_config.mk index 09d978eb5d4..e30cd385f63 100644 --- a/addons/ofxOpenCv/addon_config.mk +++ b/addons/ofxOpenCv/addon_config.mk @@ -61,13 +61,14 @@ common: # ADDON_LIBS_EXCLUDE = linux64: - ADDON_PKG_CONFIG_LIBRARIES = opencv4 harfbuzz + # ADDON_PKG_CONFIG_LIBRARIES = opencv harfbuzz # for older Ubuntu + ADDON_PKG_CONFIG_LIBRARIES = opencv4 harfbuzz ADDON_LIBS_EXCLUDE = libs/opencv/% ADDON_INCLUDES_EXCLUDE = libs/opencv ADDON_INCLUDES_EXCLUDE += libs/opencv/% linux: - ADDON_PKG_CONFIG_LIBRARIES = opencv harfbuzz + ADDON_PKG_CONFIG_LIBRARIES = opencv harfbuzz ADDON_LIBS_EXCLUDE = libs/opencv/% ADDON_INCLUDES_EXCLUDE = libs/opencv ADDON_INCLUDES_EXCLUDE += libs/opencv/% From 42c435cabe1f7542e54b1822b2496565722a4d2e Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 13 May 2024 20:03:36 -0300 Subject: [PATCH 101/143] remove A3 test --- apps/d/A3/addons.make | 2 - apps/d/A3/bin/.DS_Store | Bin 6148 -> 0 bytes apps/d/A3/bin/data/.DS_Store | Bin 6148 -> 0 bytes apps/d/A3/bin/data/.gitkeep | 0 apps/d/A3/of.yml | 15 --- apps/d/A3/src/.DS_Store | Bin 6148 -> 0 bytes apps/d/A3/src/main.cpp | 46 --------- apps/d/A3/src/ofApp.cpp | 192 ----------------------------------- apps/d/A3/src/ofApp.h | 104 ------------------- apps/d/A3/src/structs.h | 113 --------------------- 10 files changed, 472 deletions(-) delete mode 100644 apps/d/A3/addons.make delete mode 100644 apps/d/A3/bin/.DS_Store delete mode 100644 apps/d/A3/bin/data/.DS_Store delete mode 100644 apps/d/A3/bin/data/.gitkeep delete mode 100644 apps/d/A3/of.yml delete mode 100644 apps/d/A3/src/.DS_Store delete mode 100644 apps/d/A3/src/main.cpp delete mode 100644 apps/d/A3/src/ofApp.cpp delete mode 100644 apps/d/A3/src/ofApp.h delete mode 100644 apps/d/A3/src/structs.h diff --git a/apps/d/A3/addons.make b/apps/d/A3/addons.make deleted file mode 100644 index 01d5713d190..00000000000 --- a/apps/d/A3/addons.make +++ /dev/null @@ -1,2 +0,0 @@ -ofxMicroUI -ofxTools diff --git a/apps/d/A3/bin/.DS_Store b/apps/d/A3/bin/.DS_Store deleted file mode 100644 index ca338d99c01cd11c5316737fba3c2ee9aa44299f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ5Iwu5S;}VmS|E^?iF%_B{C;SK}&)qC}KGU^zOI}2jBuxZbMJUn-5VUVLy?d1vN%?N@j_B9azQ?ObFgA~jr5o^=_U=G8}b7Lf{=^d6i0`SPyswxi1FfO0Eo zWhIZY`htJRb$!#UH~kv*_1pXY_2p)FbO!Le HzoEbfI(92~ diff --git a/apps/d/A3/bin/data/.DS_Store b/apps/d/A3/bin/data/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0() }; - auto window { ofCreateWindow(settings) }; - - -#define SECOND -#ifdef SECOND - settings.windowName = "second"; - settings.shareContextWith = window; - - settings.setPosition({ 600, 600 }); - settings.setSize(1200, 300); - -// settings.doubleBuffering = true; -// settings.windowMode = OF_FULLSCREEN; -// settings.monitor = 1; -// settings.windowMode = OF_GAME_MODE; -// settings.fullscreenDisplays = { 1, 2, 3 }; - settings.showOnlyInSelectedMonitor = true; - - auto newWindow { ofCreateWindow(settings) }; -// ofAddListener(newWindow->events().draw, mainApp.get(), &ofApp::drawSecondWindow); -#endif - - ofRunApp(window, mainApp); - ofRunMainLoop(); - -} diff --git a/apps/d/A3/src/ofApp.cpp b/apps/d/A3/src/ofApp.cpp deleted file mode 100644 index 1734a9ad84a..00000000000 --- a/apps/d/A3/src/ofApp.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include "ofApp.h" - -ofPolyline p1, p2; -#define NEUEFPS - -bool vs = false; -//int fps = 120/1; -int fps = 333; -//ofTimerFpsX t { fps }; -ofTimerFpsX t; - -GLFWwindow* wn; - -void ofApp::setup(){ - ofRectangle windowRect { 100, 100, 600, 400 }; - -#ifdef NW - ofGLFWWindowSettings settings; - settings.windowName = "second"; - settings.shareContextWith = ofGetCurrentWindow(); - settings.windowMode = OF_FULLSCREEN; -// settings.fullscreenDisplays = { 1, 2, 3 }; - settings.monitor = 1; - settings.showOnlyInSelectedMonitor = true; - auto newWindow { ofCreateWindow(settings) }; - - ofAddListener(newWindow->events().draw, - this, - &ofApp::drawSecondWindow); -#endif - -// GLFWwindow * sharedContext = nullptr; -// GLFWmonitor *monitor = nullptr; -// GLFWmonitor** monitors; -// int numberOfMonitors; -// monitors = glfwGetMonitors(&numberOfMonitors); -// if (numberOfMonitors > 1) { -// monitor = monitors[1]; -// } -// wn = glfwCreateWindow(windowRect.width, windowRect.height, "", monitor, sharedContext); - - ofSetCircleResolution(96); - cout << "GLFW version " << glfwGetVersionString() << endl; -#ifdef NEUEFPS -// ofSetFrameRate(fps); - ofSetFrameRate(0); - vs = false; - ofSetVerticalSync(vs); -#else - ofSetFrameRate(fps); //40 eh especial pq eh 25ms - ofSetVerticalSync(false); -#endif -// glfwWindowHint(GLFW_REFRESH_RATE, fps); - ofSetBackgroundAuto(false); - - cout << "getwindows size " << ofGetMainLoop()->getWindows().size() << endl; - -} - -void ofApp::update() { -#ifdef NEUEFPS -// t.waitNext(); -#endif -} - -void ofApp::draw(){ -// cout << ofGetSeconds() << endl; -// cout << ofGetElapsedTimeMicros() / 1000000 << endl; -// cout << ofGetElapsedTimeMillis() / (float)1000000000 << endl; - - - ofGetMainLoop()->ofBeginWindow(1); - ofClear(255, 0, 0); - ofSetColor(0, 255, 0); - ofDrawRectangle(50, 50, ofGetWindowWidth()-100, ofGetWindowHeight()-100); - ofSetColor(0); - ofDrawBitmapString("second window", 40, 40); - ofGetMainLoop()->ofEndWindow(); - - string s { ofToString(ofGetMouseX()) + " : " + ofToString(ofGetMouseY()) }; -// ofSetWindowTitle(s); -// cout << ofGetWindowHeight() << endl; -// ofScale(2, 2); -// ofSetColor(255, 0, 0); -// p1.draw(); -// ofSetColor(0, 255, 0); -// p2.draw(); - count.tick(); -// ofSetWindowTitle(ofToString(ofGetFrameRate())); - int w = 800; - int h = 600 + sin(ofGetElapsedTimef() * 0.5) * 150; -// ofSetWindowShape(w, h); - int x = 40; - int y = 100 + sin(ofGetElapsedTimef() * 0.4) * 100; -// ofSetWindowPosition(w, h); - - ofRectangle re = ofRectangle(x, y, ofGetWindowWidth(), ofGetWindowHeight()); -// ofSetWindowRect(re); - -// ofBackground(0, 60, 130); - - ofSetColor(0, 0, 255, 3); - ofDrawRectangle(0, 0, ofGetWindowWidth(), ofGetWindowHeight()); - - ofSetColor(255, 0, 0); - ofDrawCircle(200, 200, 200); - ofDrawLine(0, 0, 400, 400); - - ofSetColor(0, 255, 0 ); - float yy = ofGetWindowHeight() * .5; - ofDrawLine(0, yy, 600, yy); - ofSetColor(0, 255, 255 ); - yy = ofGetWindowHeight() * .5 + (fps-count.get())* 100.0; - ofDrawLine(0, yy, 600, yy); - - - - string t = "of " + ofToString(ofGetFrameRate()) + "\n" + - "new " +ofToString(count.get()) + " \n" + - ofToString(fps-count.get()) + "\n" + - ofToString(vs) + "\n" - ; - - ofSetColor(255); - ofDrawBitmapString(t, 200, 30); -// ofSetWindowTitle(t); - - - ofSetColor(0, 255, 0); - ofDrawCircle(ofGetMouseX(), ofGetMouseY(), 30); - -// for (int a=0; agetWindows()[1]->getWindowRect() << endl; - } - if (key == 'v') { - vs ^= 1; - ofSetVerticalSync(vs); - cout << "vs " << vs << endl; - } - if (key == 'r') { - ofSetFrameRate(ofRandom(25, 100)); - } - if (key == 'q') { - setupSecond(); - } - if (key == 'w') { - closeSecond(); - } - if (key == 'f') { - ofToggleFullscreen(); - } - else if (key == 'g') { - cout << int(ofGetWindowMode()) << endl; - } - else if (key == 's') { - cout << "ofGetWindowRect " << ofGetWindowRect() << endl; - cout << "ofGetWindowSize " << ofGetWindowSize() << endl; -#ifdef FORK - cout << "ofGetScreenSize " << ofGetScreenSize() << endl; -#endif -// cout << "ofGetWindowPosition " << ofGetWindowPosition() << endl; - cout << "ofGetWindowPositionX " << ofGetWindowPositionX() << endl; - cout << "ofGetWindowPositionY " << ofGetWindowPositionY() << endl; -// auto windowP = ((ofAppGLFWWindow*)ofGetWindowPtr())->getGLFWWindow(); - glm::vec2 scale; - glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &scale.x, &scale.y); - cout << "glfwGetMonitorContentScale " << scale << endl; - - cout << "getPixelScreenCoordScale" << ((ofAppGLFWWindow*)ofGetWindowPtr())->getPixelScreenCoordScale() << endl; - - - - } -} diff --git a/apps/d/A3/src/ofApp.h b/apps/d/A3/src/ofApp.h deleted file mode 100644 index 896d2bad4cf..00000000000 --- a/apps/d/A3/src/ofApp.h +++ /dev/null @@ -1,104 +0,0 @@ -#pragma once - -#include "ofMain.h" -#include "GLFW/glfw3.h" - -#include "structs.h" - -class ofApp : public ofBaseApp{ -public: - void setup(); - void update(); - void draw(); - void keyPressed(int key); - - ofPolyline poly; - ofPath path; - fpsCounter count; - - - void drawSecondWindow(ofEventArgs & args) { -// cout << "drawSecondWindow" << endl; -// ofSetCircleResolution(4); - float s = sin(ofGetElapsedTimef()*3.0) * 40 + 40; - ofBackground(s); - int space = 200; - for (int b=0; b<=ofGetWindowHeight()/space; b++) { - for (int a=0; a<=ofGetWindowWidth()/space; a++) { - float h = a*9; - ofSetColor(ofColor::fromHsb(h, 255, 255)); - ofPushMatrix(); - ofTranslate(a*space + space*.5, b*space + space*.5); - - ofDrawCircle(0, 0, space*.5); - string t = ofToString(a) + " x " + ofToString(b); - ofSetColor(0); - ofDrawBitmapString(t, 0, 0); - ofPopMatrix(); - } - } -// drawOut(); - } - - - std::vector > allWindows; - std::function drawFunction = NULL; - - vector positionsFromRect(const ofRectangle & rect, int divisions) { - vector pos; - int w = rect.width / divisions; - int h = rect.height / divisions; - for (int a=0; aevents().draw, this, &ofApp::drawWindow); - } - } - } - - - - virtual void drawWindow(ofEventArgs & args) { -// cout << "drawSecondWindow" << endl; -// ofBackground(0, 255, 0); - ofSetColor(0); - ofSetColor(ofColor::fromHsb(ofRandom(0,45), 255, 255)); - ofDrawRectangle(10, 10, 100, 100); - } - - void closeSecond() { - for (auto & a : allWindows) { - a->setWindowShouldClose(); - } - allWindows.clear(); - } - - -}; diff --git a/apps/d/A3/src/structs.h b/apps/d/A3/src/structs.h deleted file mode 100644 index a7b33818375..00000000000 --- a/apps/d/A3/src/structs.h +++ /dev/null @@ -1,113 +0,0 @@ - - -#include -using namespace std::chrono; -using namespace std::chrono_literals; - -struct fpsCounter { -public: - int nAverages = 20; - using space = std::chrono::duration; - time_point lastTick; - steady_clock::duration onesec = 1s; - vector intervals; - space interval; - space average; - bool firstTick = true; - int cursor = 0; - - void tick() { - if (firstTick) { - firstTick = false; - lastTick = steady_clock::now(); - return; - } - - interval = steady_clock::now() - lastTick; - lastTick = steady_clock::now(); - if (intervals.size() < nAverages) { - intervals.emplace_back(interval); - } else { - intervals[cursor] = interval; - cursor = (cursor+1)%nAverages; - } - } - - float get() { -// average = std::reduce(intervals.begin(), intervals.end())/intervals.size(); -// return onesec / average; - average = std::reduce(intervals.begin(), intervals.end()); - return intervals.size() * onesec / average; - } -} ; - - - -#include -#include -#include -#include - -using std::cout; -using std::endl; - -class ofTimerFpsX { -public: - ofTimerFpsX(){ - reset(); - } - ofTimerFpsX(int f) { - reset(); - setFps(f); - } - using space = std::chrono::duration; //micro - time_point wakeTime; - time_point lastWakeTime; - space interval; - space drift; - - void setFps(int fps) { - interval = duration_cast(1s) / fps; - wakeTime = steady_clock::now() + interval; - lastWakeTime = steady_clock::now(); - } - - void reset() { - wakeTime = steady_clock::now(); - lastWakeTime = steady_clock::now(); - } - - void waitNext(){ - bool debug = false; - - if (debug) { - std::cout << "interval:" << duration_cast(wakeTime - lastWakeTime).count() << std::endl; - - auto el = duration_cast(steady_clock::now() - lastWakeTime).count(); - std::cout << "ellapsed:" << el << std::endl; - - auto ws = duration_cast(wakeTime - steady_clock::now()).count(); - std::cout << "will sleep:" << ws << std::endl; - cout << "soma" << (el + ws) << endl; - } - if (wakeTime > steady_clock::now()) { - std::this_thread::sleep_until(wakeTime); - } - drift = steady_clock::now() - wakeTime; - auto driftNs = duration_cast(drift).count(); - - - if (debug) { - std::cout << "drift: " << driftNs << std::endl; - std::cout << "----" << std::endl; - } - - lastWakeTime = wakeTime; - wakeTime += interval; - if (drift < interval) { - wakeTime -= (drift/1000); - } - } -}; - - From b1d1e61a91c4a752a74a5daa99c98c29f45bd795 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 16 May 2024 00:27:45 -0300 Subject: [PATCH 102/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 2528ea89b63..24e7964e172 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -14,6 +14,7 @@ template class ofPixels_; typedef ofPixels_ ofPixels; +[[deprecated ("In This Branch ~ use ofWindowSettings instead")]] typedef ofWindowSettings ofGLFWWindowSettings; class ofAppGLFWWindow : public ofAppBaseWindow { From d36e20ad055196ddcbd9f2552e3cb7c07543680d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 24 May 2024 17:30:06 -0300 Subject: [PATCH 103/143] put back ofMath.h --- libs/openFrameworks/graphics/ofPolyline.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/openFrameworks/graphics/ofPolyline.inl b/libs/openFrameworks/graphics/ofPolyline.inl index c37621f2427..a02ff15d6d2 100644 --- a/libs/openFrameworks/graphics/ofPolyline.inl +++ b/libs/openFrameworks/graphics/ofPolyline.inl @@ -7,6 +7,7 @@ #include "ofVectorMath.h" #include "ofAppRunner.h" #include "ofLog.h" +#include "ofMath.h" //---------------------------------------------------------- template From a62be90a1b7a81a9854ccaef4e53b58b3c9e028c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 19 Jul 2024 13:08:48 -0300 Subject: [PATCH 104/143] fix linux GLXContext --- apps/projectGenerator | 2 +- libs/openFrameworks/app/ofAppGLFWWindow.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/projectGenerator b/apps/projectGenerator index 5cd3d8dca68..aeb71fb93f3 160000 --- a/apps/projectGenerator +++ b/apps/projectGenerator @@ -1 +1 @@ -Subproject commit 5cd3d8dca68aabf72403418cabcef1ad54403070 +Subproject commit aeb71fb93f3c7ee44b9dea33ac1ca6eda589c85a diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 4e8919c4e1c..9a9a7cffc18 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -112,7 +112,7 @@ class ofAppGLFWWindow : public ofAppBaseWindow { #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) -// GLXContext getGLXContext(); + GLXContext getGLXContext(); #endif #if defined(TARGET_LINUX) && defined(TARGET_OPENGLES) From de7d8bd12f3b9a13b46469f40151cfae4a90bc13 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 20 Aug 2024 19:30:04 -0300 Subject: [PATCH 105/143] merge master --- .../gl/ofGLProgrammableRenderer.cpp | 81 ++++++++++++++++++- .../gl/ofGLProgrammableRenderer.h | 10 +++ libs/openFrameworks/gl/ofLight.h | 47 +++++------ libs/openFrameworks/gl/ofMaterial.cpp | 38 +++++++++ libs/openFrameworks/gl/ofMaterial.h | 32 ++++++++ libs/openFrameworks/gl/shaders/pbr.vert | 11 +++ libs/openFrameworks/gl/shaders/phong.frag | 16 +++- libs/openFrameworks/gl/shaders/phong.vert | 14 +++- libs/openFrameworks/utils/ofJson.h | 6 +- 9 files changed, 217 insertions(+), 38 deletions(-) diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp index 6afb2672436..98aaae56e25 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp @@ -946,13 +946,86 @@ glm::vec3 ofGLProgrammableRenderer::getCurrentEyePosition() const { //---------------------------------------------------------- void ofGLProgrammableRenderer::uploadCurrentMatrix() { if (!currentShader) return; + + static GLuint _matrixBuffer; + static GLint _matrixBlockLocation; + static constexpr GLuint _matrixBufferBindingPoint = 0; + auto _program = currentShader->getProgram(); + _matrixBlockLocation = glGetUniformBlockIndex(_program, "matrices"); + + if (!buffer.isAllocated()) { + buffer.allocate(sizeof(matrices), GL_DYNAMIC_DRAW); + + + + glGenBuffers(1, &_matrixBuffer); + glBindBuffer(GL_UNIFORM_BUFFER, _matrixBuffer); + glBufferData(GL_UNIFORM_BUFFER, sizeof(matrices), &matrices, GL_DYNAMIC_DRAW); + glBindBufferBase(GL_UNIFORM_BUFFER, _matrixBufferBindingPoint, _matrixBuffer); + } // uploads the current matrix to the current shader. switch (matrixStack.getCurrentMatrixMode()) { case OF_MATRIX_MODELVIEW: - currentShader->setUniformMatrix4f(MODEL_MATRIX_UNIFORM, matrixStack.getModelMatrix()); - currentShader->setUniformMatrix4f(VIEW_MATRIX_UNIFORM, matrixStack.getViewMatrix()); - currentShader->setUniformMatrix4f(MODELVIEW_MATRIX_UNIFORM, matrixStack.getModelViewMatrix()); - currentShader->setUniformMatrix4f(MODELVIEW_PROJECTION_MATRIX_UNIFORM, matrixStack.getModelViewProjectionMatrix()); +// std::cout << "here " << std::endl; + + + matrices = { + matrixStack.getModelMatrix(), + matrixStack.getViewMatrix(), + matrixStack.getModelViewMatrix(), + matrixStack.getModelViewProjectionMatrix(), + }; + using std::cout; + using std::endl; +// cout << "--------------" << endl; +// cout << "----- 001" << endl; +// cout << matrices.modelMatrix << endl; +// cout << "----- 002" << endl; +// cout << matrixStack.getModelMatrix() << endl; +// buffer.updateData(&matrices); + + + +// glUniformBlockBinding(_program, _matrixBlockLocation, _matrixBufferBindingPoint); + +// currentShader->printActiveUniformBlocks(); + + // buffer.setData(sizeof(matrices), &matrices, GL_DYNAMIC_DRAW); +// currentShader->bindUniformBlock(currentShader->getUniformBlockIndex("matrices"), "matrices"); + + + +// currentShader->bindUniformBlock(buffer.getId(), "matrices"); +// +// buffer.setData(sizeof(matrices), &matrices, GL_DYNAMIC_DRAW); +// buffer.bindBase(GL_UNIFORM_BUFFER, currentShader->getUniformBlockIndex("matrices")); + + + currentShader->setUniformMatrix4f(MODEL_MATRIX_UNIFORM, matrixStack.getModelMatrix()); + currentShader->setUniformMatrix4f(VIEW_MATRIX_UNIFORM, matrixStack.getViewMatrix()); + currentShader->setUniformMatrix4f(MODELVIEW_MATRIX_UNIFORM, matrixStack.getModelViewMatrix()); + currentShader->setUniformMatrix4f(MODELVIEW_PROJECTION_MATRIX_UNIFORM, matrixStack.getModelViewProjectionMatrix()); + + + +// buffer.unbindBase(GL_UNIFORM_BUFFER, currentShader->getUniformBlockIndex("matrices")); + +// glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(lights), lights); +// glBindBuffer(GL_UNIFORM_BUFFER, 0); +// buffer.bindBase(currentShader->getShader(), 1); +// currentShader->bindAttribute(buffer.getId(), "matrices"); +// static const string MODEL_MATRIX_UNIFORM = "modelMatrix"; +// static const string VIEW_MATRIX_UNIFORM = "viewMatrix"; +// static const string MODELVIEW_MATRIX_UNIFORM = "modelViewMatrix"; +// static const string PROJECTION_MATRIX_UNIFORM = "projectionMatrix"; +// static const string MODELVIEW_PROJECTION_MATRIX_UNIFORM = "modelViewProjectionMatrix"; +// static const string TEXTURE_MATRIX_UNIFORM = "textureMatrix"; +// static const string COLOR_UNIFORM = "globalColor"; +// +// static const string USE_TEXTURE_UNIFORM = "usingTexture"; +// static const string USE_COLORS_UNIFORM = "usingColors"; +// static const string BITMAP_STRING_UNIFORM = "bitmapText"; + if (currentMaterial) { currentMaterial->uploadMatrices(*currentShader, *this); } diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.h b/libs/openFrameworks/gl/ofGLProgrammableRenderer.h index 1fbe47c26ca..b0509d9dfed 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.h +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.h @@ -405,4 +405,14 @@ class ofGLProgrammableRenderer: public ofBaseGLRenderer{ GLuint currentFramebufferId; ///< the framebuffer id currently bound to the GL_FRAMEBUFFER target uint64_t beginDefaultShaderFrame; + + + + struct matricesBuffer { + glm::mat4 modelMatrix; + glm::mat4 viewMatrix; + glm::mat4 modelViewMatrix; + glm::mat4 modelViewProjectionMatrix; + } matrices; + ofBufferObject buffer; }; diff --git a/libs/openFrameworks/gl/ofLight.h b/libs/openFrameworks/gl/ofLight.h index cbbb5150313..958f1601a5d 100644 --- a/libs/openFrameworks/gl/ofLight.h +++ b/libs/openFrameworks/gl/ofLight.h @@ -36,7 +36,7 @@ class ofLight : public ofNode { public: ofLight(); - void setup(); + void setup(); void enable(); void disable(); bool getIsEnabled() const; @@ -47,19 +47,19 @@ class ofLight : public ofNode { void setSpotlight( float spotCutOff=45.f, float exponent=0.f ); bool getIsSpotlight() const; void setSpotlightCutOff( float spotCutOff ); - float getSpotlightCutOff() const; + float getSpotlightCutOff() const; void setSpotConcentration( float exponent ); - float getSpotConcentration() const; + float getSpotConcentration() const; void setPointLight(); bool getIsPointLight() const; void setAttenuation( float constant=1.f, float linear=0.f, float quadratic=0.f ); - float getAttenuationConstant() const; - float getAttenuationLinear() const; - float getAttenuationQuadratic() const; - - void setAreaLight(float width, float height); - bool getIsAreaLight() const; + float getAttenuationConstant() const; + float getAttenuationLinear() const; + float getAttenuationQuadratic() const; + + void setAreaLight(float width, float height); + bool getIsAreaLight() const; int getType() const; @@ -81,31 +81,31 @@ class ofLight : public ofNode { bool endShadowDepthPass( GLenum aPassIndex ); ofShadow & getShadow() { return shadow; } - + class Data{ public: Data(); ~Data(); - + ofFloatColor ambientColor; ofFloatColor diffuseColor; ofFloatColor specularColor; - - float attenuation_constant; - float attenuation_linear; - float attenuation_quadratic; - + + float attenuation_constant; + float attenuation_linear; + float attenuation_quadratic; + ofLightType lightType; - + int glIndex; int isEnabled; - float spotCutOff; - float exponent; + float spotCutOff; + float exponent; glm::vec4 position; glm::vec3 direction; - - float width; - float height; + + float width; + float height; glm::vec3 up; glm::vec3 right; /// weak link back to renderer for which this light was created/setup @@ -118,10 +118,11 @@ class ofLight : public ofNode { private: void customDraw(const ofBaseRenderer * renderer) const; std::shared_ptr data; - // update opengl light + // update opengl light // this method overrides ofNode to catch the changes and update glLightv(GL_POSITION) virtual void onPositionChanged(); virtual void onOrientationChanged(); + }; diff --git a/libs/openFrameworks/gl/ofMaterial.cpp b/libs/openFrameworks/gl/ofMaterial.cpp index 83d565808a3..61e6c7cd8a7 100644 --- a/libs/openFrameworks/gl/ofMaterial.cpp +++ b/libs/openFrameworks/gl/ofMaterial.cpp @@ -1135,6 +1135,7 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & shared_ptr light = ofLightsData()[i].lock(); if(!light || !light->isEnabled){ shader.setUniform1f("lights["+idx+"].enabled",0); +// lights[i].enabled = 0; continue; } glm::vec4 lightEyePosition = light->position; @@ -1154,20 +1155,35 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & } if( light->lightType != OF_LIGHT_POINT ) { shader.setUniform3f("lights["+idx+"].direction", light->direction ); +// lights[i].direction = light->direction; } } +// lights[i].enabled = 1; +// lights[i].type = light->lightType; +// lights[i].position = lightEyePosition; + shader.setUniform1f("lights["+idx+"].enabled",1); shader.setUniform1f("lights["+idx+"].type", light->lightType); shader.setUniform4f("lights["+idx+"].position", lightEyePosition); if( !isPBR() ) { +// lights[i].ambient = light->ambientColor; +// lights[i].specular = light->specularColor; + shader.setUniform4f("lights["+idx+"].ambient", light->ambientColor); shader.setUniform4f("lights["+idx+"].specular", light->specularColor); } +// lights[idx].diffuse = light->diffuseColor; shader.setUniform4f("lights["+idx+"].diffuse", light->diffuseColor); if(light->lightType!=OF_LIGHT_DIRECTIONAL){ // TODO: add in light radius if pbr? + +// lights[idx].radius = 0.0f; +// lights[idx].constantAttenuation = light->attenuation_constant; +// lights[idx].linearAttenuation = light->attenuation_linear; +// lights[idx].quadraticAttenuation = light->attenuation_quadratic; + shader.setUniform1f("lights["+idx+"].radius", 0.0f); shader.setUniform1f("lights["+idx+"].constantAttenuation", light->attenuation_constant); shader.setUniform1f("lights["+idx+"].linearAttenuation", light->attenuation_linear); @@ -1182,9 +1198,16 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & glm::vec4 direction4 = renderer.getCurrentViewMatrix() * glm::vec4(direction,1.0); direction = glm::vec3(direction4) / direction4.w; direction = direction - glm::vec3(lightEyePosition); + shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction)); +// lights[idx].spotDirection = glm::normalize(direction); + } //shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction)); +// lights[idx].spotExponent = light->exponent; +// lights[idx].spotCutoff = light->spotCutOff; +// lights[idx].spotCosCutoff = std::cos(glm::radians(light->spotCutOff))); + shader.setUniform1f("lights["+idx+"].spotExponent", light->exponent); shader.setUniform1f("lights["+idx+"].spotCutoff", light->spotCutOff); shader.setUniform1f("lights["+idx+"].spotCosCutoff", std::cos(glm::radians(light->spotCutOff))); @@ -1192,8 +1215,15 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & if( !isPBR() ) { glm::vec3 halfVector(glm::normalize(glm::vec4(0.f, 0.f, 1.f, 0.f) + lightEyePosition)); shader.setUniform3f("lights["+idx+"].halfVector", halfVector); + +// lights[idx].halfVector = light->halfVector; + } }else if(light->lightType==OF_LIGHT_AREA){ + +// lights[idx].width = light->width; +// lights[idx].height = light->height; + shader.setUniform1f("lights["+idx+"].width", light->width); shader.setUniform1f("lights["+idx+"].height", light->height); glm::vec3 direction = light->direction; @@ -1202,6 +1232,9 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & glm::vec4 direction4 = renderer.getCurrentViewMatrix() * glm::vec4(direction, 1.0); direction = glm::vec3(direction4) / direction4.w; direction = direction - glm::vec3(lightEyePosition); + +// lights[idx].spotDirection = glm::normalize(direction); + shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction)); } @@ -1214,6 +1247,11 @@ void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & right = right - glm::vec3(lightEyePosition); up = glm::cross(right, direction); } + + // FIXME: why toGlm in one and not in another? +// lights[idx].right = glm::normalize(toGlm(right)); +// lights[idx].up = glm::normalize(up)); + shader.setUniform3f("lights["+idx+"].right", glm::normalize(toGlm(right))); shader.setUniform3f("lights["+idx+"].up", glm::normalize(up)); } diff --git a/libs/openFrameworks/gl/ofMaterial.h b/libs/openFrameworks/gl/ofMaterial.h index c75c1d4ddf2..48c7bd7fe2e 100644 --- a/libs/openFrameworks/gl/ofMaterial.h +++ b/libs/openFrameworks/gl/ofMaterial.h @@ -388,6 +388,36 @@ class ofMaterial : public ofBaseMaterial { const std::string getDefinesString() const; void setCustomShader(std::shared_ptr aCustomShader); + + + struct PbrLightData { + float enabled; + // 0 = pointlight 1 = directionlight, 2 = spotlight, 3 = area light + float type; + // where are we in world space + glm::vec4 position; + glm::vec4 direction; + // light color, intensity is stored in .w + glm::vec4 diffuse; + float radius;// = 0.0; + // attenuation + float constantAttenuation; + float linearAttenuation; + float quadraticAttenuation; + // // only for spot + float spotCutoff; + float spotCosCutoff; + float spotExponent; + // // only for area + float width; + float height; + glm::vec4 right; + glm::vec4 up; + }; + + PbrLightData lights[100]; + + protected: /// \brief unbind the material, override the default so we can set current shader to nullptr @@ -473,4 +503,6 @@ class ofMaterial : public ofBaseMaterial { mutable const ofShader * currentRenderShader = nullptr; bool bPrintedPBRRenderWarning = false; bool mBHasDepthShader = false; + + }; diff --git a/libs/openFrameworks/gl/shaders/pbr.vert b/libs/openFrameworks/gl/shaders/pbr.vert index aa570a137d3..37dd619e090 100644 --- a/libs/openFrameworks/gl/shaders/pbr.vert +++ b/libs/openFrameworks/gl/shaders/pbr.vert @@ -17,6 +17,17 @@ IN vec4 color; IN vec4 normal; IN vec2 texcoord; +//layout(std140) uniform matrices { +////struct modelVars { +// mat4 modelViewMatrix; +// mat4 modelMatrix; +// mat4 viewMatrix; +// mat4 projectionMatrix; +// mat4 textureMatrix; +// mat4 modelViewProjectionMatrix; +//} ; + + // these are passed in from OF programmable renderer uniform mat4 modelViewMatrix; uniform mat4 modelMatrix; diff --git a/libs/openFrameworks/gl/shaders/phong.frag b/libs/openFrameworks/gl/shaders/phong.frag index 4850c56f2ad..b2b584cf5ba 100644 --- a/libs/openFrameworks/gl/shaders/phong.frag +++ b/libs/openFrameworks/gl/shaders/phong.frag @@ -9,7 +9,6 @@ static const string fragmentShader = R"( #if HAS_COLOR IN vec4 v_color; #endif - uniform mat4 viewMatrix; struct lightData @@ -49,10 +48,19 @@ static const string fragmentShader = R"( uniform vec4 global_ambient; // these are passed in from OF programmable renderer - uniform mat4 modelViewMatrix; + uniform mat4 viewMatrix; + uniform mat4 modelViewMatrix; + uniform mat4 modelViewProjectionMatrix; + + uniform mat4 textureMatrix; uniform mat4 projectionMatrix; - uniform mat4 textureMatrix; - uniform mat4 modelViewProjectionMatrix; +// +//layout(std140) uniform matrices { +// mat4 modelMatrix; +// mat4 viewMatrix; +// mat4 modelViewMatrix; +// mat4 modelViewProjectionMatrix; +//}; #if defined(MAX_LIGHTS) && MAX_LIGHTS uniform lightData lights[MAX_LIGHTS]; diff --git a/libs/openFrameworks/gl/shaders/phong.vert b/libs/openFrameworks/gl/shaders/phong.vert index ca053f3dceb..470c470332a 100644 --- a/libs/openFrameworks/gl/shaders/phong.vert +++ b/libs/openFrameworks/gl/shaders/phong.vert @@ -1,4 +1,5 @@ static const string vertexShader = R"( + OUT vec2 v_texcoord; // phong pass the texCoord if needed OUT vec3 v_transformedNormal; OUT vec3 v_normal; @@ -14,13 +15,22 @@ IN vec4 color; IN vec4 normal; IN vec2 texcoord; + +//layout(std140) uniform matrices { +// mat4 modelMatrix; +// mat4 viewMatrix; +// mat4 modelViewMatrix; +// mat4 modelViewProjectionMatrix; +//}; + // these are passed in from OF programmable renderer -uniform mat4 modelViewMatrix; uniform mat4 modelMatrix; uniform mat4 viewMatrix; +uniform mat4 modelViewMatrix; +uniform mat4 modelViewProjectionMatrix; + uniform mat4 projectionMatrix; uniform mat4 textureMatrix; -uniform mat4 modelViewProjectionMatrix; uniform mat4 normalMatrix; uniform vec2 mat_texcoord_scale; diff --git a/libs/openFrameworks/utils/ofJson.h b/libs/openFrameworks/utils/ofJson.h index 82ef6a94111..776cb5e5a8a 100644 --- a/libs/openFrameworks/utils/ofJson.h +++ b/libs/openFrameworks/utils/ofJson.h @@ -1,10 +1,6 @@ #pragma once -#if !defined(TARGET_MINGW) - #include -#else - #include // MSYS2 : use of system-installed include -#endif +#include // MSYS2 : use of system-installed include #include "ofParameter.h" // for convenience From 3ab5b15f117c257259a7d8886ee4360be5c4cfca Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Aug 2024 13:05:46 -0300 Subject: [PATCH 106/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index be065511ff1..453db53c846 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -58,12 +58,12 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ } ofAppGLFWWindow::~ofAppGLFWWindow() { - cout << "ofAppGLFWWindow::~ofAppGLFWWindow() " << settings.windowName << endl; +// cout << "ofAppGLFWWindow::~ofAppGLFWWindow() " << settings.windowName << endl; close(); } void ofAppGLFWWindow::close() { - cout << "ofAppGLFWWindow::close! " << settings.windowName << endl; +// cout << "ofAppGLFWWindow::close! " << settings.windowName << endl; if (windowP) { glfwSetMouseButtonCallback( windowP, nullptr ); @@ -195,7 +195,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { bool displayOK = false; if (settings.fullscreenDisplays.size()) { for (auto & d : settings.fullscreenDisplays) { - cout << "GLFWWindow fullscreenDisplays " << d << " : " << allMonitors.rects.size() << endl; + cout << "GLFWWindow fullscreenDisplays " << d << " : monitors.size=" << allMonitors.rects.size() << endl; if (d < allMonitors.rects.size()) { // cout << "glfw ok opening " << endl; displayOK = true; From 02fd83e24432136f1e753f28da11a4d65a9c2bef Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 28 Aug 2024 21:53:11 -0300 Subject: [PATCH 107/143] revert glfwwindow --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 342 +------------------- 1 file changed, 3 insertions(+), 339 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index b1c13d768e7..be065511ff1 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -58,12 +58,12 @@ ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ } ofAppGLFWWindow::~ofAppGLFWWindow() { -// cout << "ofAppGLFWWindow::~ofAppGLFWWindow() " << settings.windowName << endl; + cout << "ofAppGLFWWindow::~ofAppGLFWWindow() " << settings.windowName << endl; close(); } void ofAppGLFWWindow::close() { -// cout << "ofAppGLFWWindow::close! " << settings.windowName << endl; + cout << "ofAppGLFWWindow::close! " << settings.windowName << endl; if (windowP) { glfwSetMouseButtonCallback( windowP, nullptr ); @@ -195,7 +195,7 @@ void ofAppGLFWWindow::setup(const ofWindowSettings & _settings) { bool displayOK = false; if (settings.fullscreenDisplays.size()) { for (auto & d : settings.fullscreenDisplays) { - cout << "GLFWWindow fullscreenDisplays " << d << " : monitors.size=" << allMonitors.rects.size() << endl; + cout << "GLFWWindow fullscreenDisplays " << d << " : " << allMonitors.rects.size() << endl; if (d < allMonitors.rects.size()) { // cout << "glfw ok opening " << endl; displayOK = true; @@ -1065,7 +1065,6 @@ void ofAppGLFWWindow::mouse_cb(GLFWwindow * windowP_, int button, int state, int button = GLFW_MOUSE_BUTTON_MIDDLE; } #endif -<<<<<<< HEAD switch (button) { case GLFW_MOUSE_BUTTON_LEFT: @@ -1414,341 +1413,6 @@ void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { // instance->nFramesSinceWindowResized = 0; -======= - - switch (button) { - case GLFW_MOUSE_BUTTON_LEFT: - button = OF_MOUSE_BUTTON_LEFT; - break; - case GLFW_MOUSE_BUTTON_RIGHT: - button = OF_MOUSE_BUTTON_RIGHT; - break; - case GLFW_MOUSE_BUTTON_MIDDLE: - button = OF_MOUSE_BUTTON_MIDDLE; - break; - } - instance->buttonInUse = button; - - ofMouseEventArgs::Type action; - if (state == GLFW_PRESS) { - action = ofMouseEventArgs::Pressed; - instance->buttonPressed = true; - } else { - action = ofMouseEventArgs::Released; - instance->buttonPressed = false; - } - - int modifiers = glfwtToOFModifiers(mods); - - ofMouseEventArgs args(action, instance->events().getMouseX(), instance->events().getMouseY(), button, modifiers); - - instance->events().notifyMouseEvent(args); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::motion_cb(GLFWwindow * windowP_, double x, double y) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y); - - ofMouseEventArgs::Type action; - if (!instance->buttonPressed) { - action = ofMouseEventArgs::Moved; - } else { - action = ofMouseEventArgs::Dragged; - } - - ofMouseEventArgs args(action, - x * instance->pixelScreenCoordScale, - y * instance->pixelScreenCoordScale, - instance->buttonInUse, - instance->events().getModifiers()); - instance->events().notifyMouseEvent(args); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::entry_cb(GLFWwindow * windowP_, int entered) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - ofMouseEventArgs::Type action; - if (entered) { - action = ofMouseEventArgs::Entered; - } else { - action = ofMouseEventArgs::Exited; - } - - ofMouseEventArgs args(action, - instance->events().getMouseX(), - instance->events().getMouseY(), - instance->buttonInUse, - instance->events().getModifiers()); - instance->events().notifyMouseEvent(args); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::scroll_cb(GLFWwindow * windowP_, double x, double y) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y); - - ofMouseEventArgs args(ofMouseEventArgs::Scrolled, - instance->events().getMouseX(), - instance->events().getMouseY(), - instance->buttonInUse, - instance->events().getModifiers()); - args.scrollX = x; - args.scrollY = y; - instance->events().notifyMouseEvent(args); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::drop_cb(GLFWwindow * windowP_, int numFiles, const char ** dropString) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - ofDragInfo drag; - drag.position = { instance->events().getMouseX(), instance->events().getMouseY() }; - drag.files.resize(numFiles); - for (int i = 0; i < (int)drag.files.size(); i++) { - drag.files[i] = dropString[i]; - } - instance->events().notifyDragEvent(drag); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::error_cb(int errorCode, const char * errorDescription) { - ofLogError("ofAppGLFWWindow") << errorCode << ": " << errorDescription; - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::keyboard_cb(GLFWwindow * windowP_, int keycode, int scancode, int action, int mods) { - int key = 0; - uint32_t codepoint = 0; - ofAppGLFWWindow * instance = setCurrent(windowP_); - switch (keycode) { - case GLFW_KEY_ESCAPE: - key = OF_KEY_ESC; - break; - case GLFW_KEY_F1: - key = OF_KEY_F1; - break; - case GLFW_KEY_F2: - key = OF_KEY_F2; - break; - case GLFW_KEY_F3: - key = OF_KEY_F3; - break; - case GLFW_KEY_F4: - key = OF_KEY_F4; - break; - case GLFW_KEY_F5: - key = OF_KEY_F5; - break; - case GLFW_KEY_F6: - key = OF_KEY_F6; - break; - case GLFW_KEY_F7: - key = OF_KEY_F7; - break; - case GLFW_KEY_F8: - key = OF_KEY_F8; - break; - case GLFW_KEY_F9: - key = OF_KEY_F9; - break; - case GLFW_KEY_F10: - key = OF_KEY_F10; - break; - case GLFW_KEY_F11: - key = OF_KEY_F11; - break; - case GLFW_KEY_F12: - key = OF_KEY_F12; - break; - case GLFW_KEY_LEFT: - key = OF_KEY_LEFT; - break; - case GLFW_KEY_RIGHT: - key = OF_KEY_RIGHT; - break; - case GLFW_KEY_UP: - key = OF_KEY_UP; - break; - case GLFW_KEY_DOWN: - key = OF_KEY_DOWN; - break; - case GLFW_KEY_PAGE_UP: - key = OF_KEY_PAGE_UP; - break; - case GLFW_KEY_PAGE_DOWN: - key = OF_KEY_PAGE_DOWN; - break; - case GLFW_KEY_HOME: - key = OF_KEY_HOME; - break; - case GLFW_KEY_END: - key = OF_KEY_END; - break; - case GLFW_KEY_INSERT: - key = OF_KEY_INSERT; - break; - case GLFW_KEY_LEFT_SHIFT: - key = OF_KEY_LEFT_SHIFT; - break; - case GLFW_KEY_LEFT_CONTROL: - key = OF_KEY_LEFT_CONTROL; - break; - case GLFW_KEY_LEFT_ALT: - key = OF_KEY_LEFT_ALT; - break; - case GLFW_KEY_LEFT_SUPER: - key = OF_KEY_LEFT_SUPER; - break; - case GLFW_KEY_RIGHT_SHIFT: - key = OF_KEY_RIGHT_SHIFT; - break; - case GLFW_KEY_RIGHT_CONTROL: - key = OF_KEY_RIGHT_CONTROL; - break; - case GLFW_KEY_RIGHT_ALT: - key = OF_KEY_RIGHT_ALT; - break; - case GLFW_KEY_RIGHT_SUPER: - key = OF_KEY_RIGHT_SUPER; - break; - case GLFW_KEY_BACKSPACE: - key = OF_KEY_BACKSPACE; - break; - case GLFW_KEY_DELETE: - key = OF_KEY_DEL; - break; - case GLFW_KEY_ENTER: - key = OF_KEY_RETURN; - codepoint = '\n'; - break; - case GLFW_KEY_KP_ENTER: - key = OF_KEY_RETURN; - codepoint = '\n'; - break; - case GLFW_KEY_TAB: - key = OF_KEY_TAB; - codepoint = '\t'; - break; - case GLFW_KEY_KP_0: - key = codepoint = '0'; - break; - case GLFW_KEY_KP_1: - key = codepoint = '1'; - break; - case GLFW_KEY_KP_2: - key = codepoint = '2'; - break; - case GLFW_KEY_KP_3: - key = codepoint = '3'; - break; - case GLFW_KEY_KP_4: - key = codepoint = '4'; - break; - case GLFW_KEY_KP_5: - key = codepoint = '5'; - break; - case GLFW_KEY_KP_6: - key = codepoint = '6'; - break; - case GLFW_KEY_KP_7: - key = codepoint = '7'; - break; - case GLFW_KEY_KP_8: - key = codepoint = '8'; - break; - case GLFW_KEY_KP_9: - key = codepoint = '9'; - break; - case GLFW_KEY_KP_DIVIDE: - key = codepoint = '/'; - break; - case GLFW_KEY_KP_MULTIPLY: - key = codepoint = '*'; - break; - case GLFW_KEY_KP_SUBTRACT: - key = codepoint = '-'; - break; - case GLFW_KEY_KP_ADD: - key = codepoint = '+'; - break; - case GLFW_KEY_KP_DECIMAL: - key = codepoint = '.'; - break; - case GLFW_KEY_KP_EQUAL: - key = codepoint = '='; - break; - case GLFW_KEY_SPACE: - key = codepoint = OF_KEY_SPACE; - break; - default: - codepoint = keycodeToUnicode(instance, scancode, mods); - key = codepoint; - break; - } - - int modifiers = glfwtToOFModifiers(mods); - - if (action == GLFW_PRESS) { - ofKeyEventArgs keyE(ofKeyEventArgs::Pressed, key, keycode, scancode, codepoint, modifiers); - instance->events().notifyKeyEvent(keyE); - } else if (action == GLFW_REPEAT) { - ofKeyEventArgs keyE(ofKeyEventArgs::Pressed, key, keycode, scancode, codepoint, modifiers); - keyE.isRepeat = true; - instance->events().notifyKeyEvent(keyE); - } else if (action == GLFW_RELEASE) { - ofKeyEventArgs keyE(ofKeyEventArgs::Released, key, keycode, scancode, codepoint, modifiers); - instance->events().notifyKeyEvent(keyE); - } - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::char_cb(GLFWwindow * windowP_, uint32_t key) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - instance->events().charEvent.notify(key); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::position_cb(GLFWwindow* windowP_, int x, int y){ - ofAppGLFWWindow * instance = setCurrent(windowP_); - - x *= instance->pixelScreenCoordScale; - y *= instance->pixelScreenCoordScale; - instance->events().notifyWindowMoved(x,y); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::refresh_cb(GLFWwindow * windowP_) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - instance->draw(); - } - - //------------------------------------------------------------ - void ofAppGLFWWindow::resize_cb(GLFWwindow * windowP_, int w, int h) { - ofAppGLFWWindow * instance = setCurrent(windowP_); - - // Detect if the window is running in a retina mode - - int framebufferW, framebufferH; // <- physical pixel extents - glfwGetFramebufferSize(windowP_, &framebufferW, &framebufferH); - - int windowW, windowH; // <- screen coordinates, which may be scaled - glfwGetWindowSize(windowP_, &windowW, &windowH); - - // Find scale factor needed to transform from screen coordinates - // to physical pixel coordinates - instance->pixelScreenCoordScale = (float)framebufferW / (float)windowW; - - if (instance->settings.windowMode == OF_WINDOW) { - instance->windowW = framebufferW; - instance->windowH = framebufferH; - } - - instance->currentW = windowW; - instance->currentH = windowH; - instance->events().notifyWindowResized(framebufferW, framebufferH); - instance->nFramesSinceWindowResized = 0; - ->>>>>>> master #if defined(TARGET_OSX) if (!instance->bWindowNeedsShowing) { // FIXME - only after first update From 5393b611b082ab38de2bf47304dfee493aae8524 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Thu, 29 Aug 2024 01:16:03 -0300 Subject: [PATCH 108/143] ofShader setUniformBufferObject --- .../gl/ofGLProgrammableRenderer.cpp | 133 +++++++++--------- .../gl/ofGLProgrammableRenderer.h | 2 + libs/openFrameworks/gl/ofShader.cpp | 10 ++ libs/openFrameworks/gl/ofShader.h | 6 + libs/openFrameworks/gl/shaders/pbr.vert | 29 ++-- libs/openFrameworks/gl/shaders/phong.vert | 4 +- 6 files changed, 103 insertions(+), 81 deletions(-) diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp index 98aaae56e25..b175ec4efc3 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp @@ -947,97 +947,74 @@ glm::vec3 ofGLProgrammableRenderer::getCurrentEyePosition() const { void ofGLProgrammableRenderer::uploadCurrentMatrix() { if (!currentShader) return; - static GLuint _matrixBuffer; - static GLint _matrixBlockLocation; - static constexpr GLuint _matrixBufferBindingPoint = 0; - auto _program = currentShader->getProgram(); - _matrixBlockLocation = glGetUniformBlockIndex(_program, "matrices"); - - if (!buffer.isAllocated()) { - buffer.allocate(sizeof(matrices), GL_DYNAMIC_DRAW); - - - - glGenBuffers(1, &_matrixBuffer); - glBindBuffer(GL_UNIFORM_BUFFER, _matrixBuffer); - glBufferData(GL_UNIFORM_BUFFER, sizeof(matrices), &matrices, GL_DYNAMIC_DRAW); - glBindBufferBase(GL_UNIFORM_BUFFER, _matrixBufferBindingPoint, _matrixBuffer); - } + + using std::cout; + using std::endl; + +// if (!buffer.isAllocated()) +// { +// unsigned int uniformBlockIndex = glGetUniformBlockIndex(currentShader->getProgram(), "matrices"); +// glUniformBlockBinding(currentShader->getProgram(), uniformBlockIndex, 0); +// buffer.bind(GL_UNIFORM_BUFFER); +// buffer.unbind(GL_UNIFORM_BUFFER); +// buffer.allocate(sizeof(matrices), GL_STATIC_DRAW); +// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); +// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); +// } + // uploads the current matrix to the current shader. switch (matrixStack.getCurrentMatrixMode()) { case OF_MATRIX_MODELVIEW: // std::cout << "here " << std::endl; - - matrices = { - matrixStack.getModelMatrix(), - matrixStack.getViewMatrix(), - matrixStack.getModelViewMatrix(), - matrixStack.getModelViewProjectionMatrix(), - }; - using std::cout; - using std::endl; -// cout << "--------------" << endl; -// cout << "----- 001" << endl; -// cout << matrices.modelMatrix << endl; -// cout << "----- 002" << endl; -// cout << matrixStack.getModelMatrix() << endl; -// buffer.updateData(&matrices); - - -// glUniformBlockBinding(_program, _matrixBlockLocation, _matrixBufferBindingPoint); + +// matrices = { +// matrixStack.getModelMatrix(), +// matrixStack.getViewMatrix(), +// matrixStack.getModelViewMatrix(), +// matrixStack.getModelViewProjectionMatrix(), +// matrixStack.getProjectionMatrix(), +// matrixStack.getTextureMatrix(), +// }; -// currentShader->printActiveUniformBlocks(); - // buffer.setData(sizeof(matrices), &matrices, GL_DYNAMIC_DRAW); -// currentShader->bindUniformBlock(currentShader->getUniformBlockIndex("matrices"), "matrices"); - - - -// currentShader->bindUniformBlock(buffer.getId(), "matrices"); -// -// buffer.setData(sizeof(matrices), &matrices, GL_DYNAMIC_DRAW); -// buffer.bindBase(GL_UNIFORM_BUFFER, currentShader->getUniformBlockIndex("matrices")); - currentShader->setUniformMatrix4f(MODEL_MATRIX_UNIFORM, matrixStack.getModelMatrix()); currentShader->setUniformMatrix4f(VIEW_MATRIX_UNIFORM, matrixStack.getViewMatrix()); currentShader->setUniformMatrix4f(MODELVIEW_MATRIX_UNIFORM, matrixStack.getModelViewMatrix()); currentShader->setUniformMatrix4f(MODELVIEW_PROJECTION_MATRIX_UNIFORM, matrixStack.getModelViewProjectionMatrix()); - -// buffer.unbindBase(GL_UNIFORM_BUFFER, currentShader->getUniformBlockIndex("matrices")); - -// glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(lights), lights); -// glBindBuffer(GL_UNIFORM_BUFFER, 0); -// buffer.bindBase(currentShader->getShader(), 1); -// currentShader->bindAttribute(buffer.getId(), "matrices"); -// static const string MODEL_MATRIX_UNIFORM = "modelMatrix"; -// static const string VIEW_MATRIX_UNIFORM = "viewMatrix"; -// static const string MODELVIEW_MATRIX_UNIFORM = "modelViewMatrix"; -// static const string PROJECTION_MATRIX_UNIFORM = "projectionMatrix"; -// static const string MODELVIEW_PROJECTION_MATRIX_UNIFORM = "modelViewProjectionMatrix"; -// static const string TEXTURE_MATRIX_UNIFORM = "textureMatrix"; -// static const string COLOR_UNIFORM = "globalColor"; -// -// static const string USE_TEXTURE_UNIFORM = "usingTexture"; -// static const string USE_COLORS_UNIFORM = "usingColors"; -// static const string BITMAP_STRING_UNIFORM = "bitmapText"; - if (currentMaterial) { currentMaterial->uploadMatrices(*currentShader, *this); } break; case OF_MATRIX_PROJECTION: +// cout << "owww OF_MATRIX_PROJECTION" << endl; currentShader->setUniformMatrix4f(PROJECTION_MATRIX_UNIFORM, matrixStack.getProjectionMatrix()); currentShader->setUniformMatrix4f(MODELVIEW_PROJECTION_MATRIX_UNIFORM, matrixStack.getModelViewProjectionMatrix()); break; case OF_MATRIX_TEXTURE: +// cout << "owww OF_MATRIX_PROJECTION" << endl; currentShader->setUniformMatrix4f(TEXTURE_MATRIX_UNIFORM, matrixStack.getTextureMatrix()); break; } + + +// matrices = { +// matrixStack.getModelMatrix(), +// matrixStack.getViewMatrix(), +// matrixStack.getModelViewMatrix(), +// matrixStack.getModelViewProjectionMatrix(), +// matrixStack.getProjectionMatrix(), +// matrixStack.getTextureMatrix(), +// }; +// +// +// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); +// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); + } //---------------------------------------------------------- @@ -1892,12 +1869,38 @@ void ofGLProgrammableRenderer::unbind(const ofCamera & camera) { //---------------------------------------------------------- void ofGLProgrammableRenderer::uploadMatrices() { if (!currentShader) return; + +// matrices = { +// matrixStack.getModelMatrix(), +// matrixStack.getViewMatrix(), +// matrixStack.getModelViewMatrix(), +// matrixStack.getModelViewProjectionMatrix(), +// matrixStack.getProjectionMatrix(), +// matrixStack.getTextureMatrix(), +// }; +// +// if (!buffer.isAllocated()) { +// unsigned int uniformBlockIndex = glGetUniformBlockIndex(currentShader->getProgram(), "matrices"); +// glUniformBlockBinding(currentShader->getProgram(), uniformBlockIndex, 0); +// buffer.bind(GL_UNIFORM_BUFFER); +// buffer.unbind(GL_UNIFORM_BUFFER); +// buffer.allocate(sizeof(matrices), GL_STATIC_DRAW); +// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); +// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); +// } +// +// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); +// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); + + currentShader->setUniformMatrix4f(MODEL_MATRIX_UNIFORM, matrixStack.getModelMatrix()); currentShader->setUniformMatrix4f(VIEW_MATRIX_UNIFORM, matrixStack.getViewMatrix()); currentShader->setUniformMatrix4f(MODELVIEW_MATRIX_UNIFORM, matrixStack.getModelViewMatrix()); + currentShader->setUniformMatrix4f(MODELVIEW_PROJECTION_MATRIX_UNIFORM, matrixStack.getModelViewProjectionMatrix()); currentShader->setUniformMatrix4f(PROJECTION_MATRIX_UNIFORM, matrixStack.getProjectionMatrix()); currentShader->setUniformMatrix4f(TEXTURE_MATRIX_UNIFORM, matrixStack.getTextureMatrix()); - currentShader->setUniformMatrix4f(MODELVIEW_PROJECTION_MATRIX_UNIFORM, matrixStack.getModelViewProjectionMatrix()); + + if (currentMaterial) { currentMaterial->uploadMatrices(*currentShader, *this); } diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.h b/libs/openFrameworks/gl/ofGLProgrammableRenderer.h index b0509d9dfed..60a81b94ac0 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.h +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.h @@ -413,6 +413,8 @@ class ofGLProgrammableRenderer: public ofBaseGLRenderer{ glm::mat4 viewMatrix; glm::mat4 modelViewMatrix; glm::mat4 modelViewProjectionMatrix; + glm::mat4 projectionMatrix; + glm::mat4 textureMatrix; } matrices; ofBufferObject buffer; }; diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index b4df3358905..8b7c729b1ab 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -726,6 +726,7 @@ bool ofShader::linkProgram() { for (GLint i = 0; i < numUniformBlocks; i++) { glGetActiveUniformBlockName(program, i, uniformMaxLength, &length, uniformBlockName.data()); string name(uniformBlockName.begin(), uniformBlockName.begin() + length); + std::cout << "WOW name " << name << std::endl; uniformBlocksCache[name] = glGetUniformBlockIndex(program, name.c_str()); } } @@ -1018,6 +1019,15 @@ void ofShader::setUniform4i(const string & name, int v1, int v2, int v3, int v4) } } +//-------------------------------------------------------------- +void ofShader::setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize) { + if (!bufferObjectsCache[name].isAllocated()) { + bufferObjectsCache[name].allocate(dataSize, GL_STATIC_DRAW); + } + bufferObjectsCache[name].updateData(dataSize, data); + bufferObjectsCache[name].bindBase(GL_UNIFORM_BUFFER, getUniformBlockIndex(name)); +} + //-------------------------------------------------------------- void ofShader::setUniform1f(const string & name, float v1) const { if (bLoaded) { diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index c1d4eb39000..d0cfcecaafb 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -159,6 +159,10 @@ class ofShader { void setUniform3i(const std::string & name, int v1, int v2, int v3) const; void setUniform4i(const std::string & name, int v1, int v2, int v3, int v4) const; + + // Dmtr testing + void setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize); + void setUniform1f(const std::string & name, float v1) const; void setUniform2f(const std::string & name, float v1, float v2) const; void setUniform3f(const std::string & name, float v1, float v2, float v3) const; @@ -278,6 +282,8 @@ class ofShader { }; std::unordered_map shaders; + + std::unordered_map bufferObjectsCache; std::unordered_map uniformsCache; mutable std::unordered_map attributesBindingsCache; diff --git a/libs/openFrameworks/gl/shaders/pbr.vert b/libs/openFrameworks/gl/shaders/pbr.vert index 37dd619e090..5c7cc8b1355 100644 --- a/libs/openFrameworks/gl/shaders/pbr.vert +++ b/libs/openFrameworks/gl/shaders/pbr.vert @@ -17,24 +17,23 @@ IN vec4 color; IN vec4 normal; IN vec2 texcoord; -//layout(std140) uniform matrices { -////struct modelVars { -// mat4 modelViewMatrix; -// mat4 modelMatrix; -// mat4 viewMatrix; -// mat4 projectionMatrix; -// mat4 textureMatrix; -// mat4 modelViewProjectionMatrix; -//} ; +layout(std140) uniform matrices { + mat4 modelMatrix; + mat4 viewMatrix; + mat4 modelViewMatrix; + mat4 modelViewProjectionMatrix; + mat4 projectionMatrix; + mat4 textureMatrix; +}; // these are passed in from OF programmable renderer -uniform mat4 modelViewMatrix; -uniform mat4 modelMatrix; -uniform mat4 viewMatrix; -uniform mat4 projectionMatrix; -uniform mat4 textureMatrix; -uniform mat4 modelViewProjectionMatrix; +//uniform mat4 modelViewMatrix; +//uniform mat4 modelMatrix; +//uniform mat4 viewMatrix; +//uniform mat4 modelViewProjectionMatrix; +//uniform mat4 projectionMatrix; +//uniform mat4 textureMatrix; uniform vec2 mat_texcoord_scale; diff --git a/libs/openFrameworks/gl/shaders/phong.vert b/libs/openFrameworks/gl/shaders/phong.vert index 470c470332a..83d9bbbf871 100644 --- a/libs/openFrameworks/gl/shaders/phong.vert +++ b/libs/openFrameworks/gl/shaders/phong.vert @@ -21,6 +21,8 @@ IN vec2 texcoord; // mat4 viewMatrix; // mat4 modelViewMatrix; // mat4 modelViewProjectionMatrix; +// mat4 projectionMatrix; +// mat4 textureMatrix; //}; // these are passed in from OF programmable renderer @@ -28,9 +30,9 @@ uniform mat4 modelMatrix; uniform mat4 viewMatrix; uniform mat4 modelViewMatrix; uniform mat4 modelViewProjectionMatrix; - uniform mat4 projectionMatrix; uniform mat4 textureMatrix; + uniform mat4 normalMatrix; uniform vec2 mat_texcoord_scale; From f3609fd324db0f6e44325d5d6cdb4ad05a34dc30 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Fri, 30 Aug 2024 12:36:26 -0300 Subject: [PATCH 109/143] updates --- .../gl/ofGLProgrammableRenderer.cpp | 58 +++++-------------- libs/openFrameworks/gl/ofShader.cpp | 21 +++++-- libs/openFrameworks/gl/ofShader.h | 9 ++- libs/openFrameworks/gl/shaders/pbr.vert | 28 ++++----- libs/openFrameworks/gl/shaders/phong.frag | 17 ++++-- libs/openFrameworks/gl/shaders/phong.vert | 13 +++-- 6 files changed, 69 insertions(+), 77 deletions(-) diff --git a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp index b175ec4efc3..1d40d94db33 100644 --- a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp +++ b/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp @@ -947,38 +947,13 @@ glm::vec3 ofGLProgrammableRenderer::getCurrentEyePosition() const { void ofGLProgrammableRenderer::uploadCurrentMatrix() { if (!currentShader) return; - using std::cout; using std::endl; -// if (!buffer.isAllocated()) -// { -// unsigned int uniformBlockIndex = glGetUniformBlockIndex(currentShader->getProgram(), "matrices"); -// glUniformBlockBinding(currentShader->getProgram(), uniformBlockIndex, 0); -// buffer.bind(GL_UNIFORM_BUFFER); -// buffer.unbind(GL_UNIFORM_BUFFER); -// buffer.allocate(sizeof(matrices), GL_STATIC_DRAW); -// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); -// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); -// } - // uploads the current matrix to the current shader. switch (matrixStack.getCurrentMatrixMode()) { case OF_MATRIX_MODELVIEW: // std::cout << "here " << std::endl; - - - -// matrices = { -// matrixStack.getModelMatrix(), -// matrixStack.getViewMatrix(), -// matrixStack.getModelViewMatrix(), -// matrixStack.getModelViewProjectionMatrix(), -// matrixStack.getProjectionMatrix(), -// matrixStack.getTextureMatrix(), -// }; - - currentShader->setUniformMatrix4f(MODEL_MATRIX_UNIFORM, matrixStack.getModelMatrix()); currentShader->setUniformMatrix4f(VIEW_MATRIX_UNIFORM, matrixStack.getViewMatrix()); @@ -1011,10 +986,7 @@ void ofGLProgrammableRenderer::uploadCurrentMatrix() { // matrixStack.getTextureMatrix(), // }; // -// -// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); -// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); - +// currentShader->setUniformBufferObject("matrices", &matrices, sizeof(matrices)); } //---------------------------------------------------------- @@ -1878,20 +1850,8 @@ void ofGLProgrammableRenderer::uploadMatrices() { // matrixStack.getProjectionMatrix(), // matrixStack.getTextureMatrix(), // }; -// -// if (!buffer.isAllocated()) { -// unsigned int uniformBlockIndex = glGetUniformBlockIndex(currentShader->getProgram(), "matrices"); -// glUniformBlockBinding(currentShader->getProgram(), uniformBlockIndex, 0); -// buffer.bind(GL_UNIFORM_BUFFER); -// buffer.unbind(GL_UNIFORM_BUFFER); -// buffer.allocate(sizeof(matrices), GL_STATIC_DRAW); -// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); -// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); -// } -// -// buffer.setData(sizeof(matrices), &matrices, GL_STATIC_DRAW); -// buffer.bindRange(GL_UNIFORM_BUFFER, 0, 0, 1 * sizeof(matrices) ); - +// currentShader->setUniformBufferObject("matrices", &matrices, sizeof(matrices)); + currentShader->setUniformMatrix4f(MODEL_MATRIX_UNIFORM, matrixStack.getModelMatrix()); currentShader->setUniformMatrix4f(VIEW_MATRIX_UNIFORM, matrixStack.getViewMatrix()); @@ -2377,6 +2337,18 @@ static const string defaultVertexShader = vertex_shader_header + STRINGIFY( uniform mat4 modelViewMatrix; uniform mat4 textureMatrix; uniform mat4 modelViewProjectionMatrix; + + layout(std140) uniform testeDimitrao { + mat4 testando; + }; +// layout(std140) uniform matrices { +// mat4 modelMatrix; +// mat4 viewMatrix; +// mat4 modelViewMatrix; +// mat4 modelViewProjectionMatrix; +// mat4 projectionMatrix; +// mat4 textureMatrix; +// }; IN vec4 position; IN vec2 texcoord; diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 8b7c729b1ab..be63f823c7a 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -726,7 +726,8 @@ bool ofShader::linkProgram() { for (GLint i = 0; i < numUniformBlocks; i++) { glGetActiveUniformBlockName(program, i, uniformMaxLength, &length, uniformBlockName.data()); string name(uniformBlockName.begin(), uniformBlockName.begin() + length); - std::cout << "WOW name " << name << std::endl; +// std::cout << "WOW name " << name << std::endl; + bufferObjectsCache[name] = std::make_unique(); uniformBlocksCache[name] = glGetUniformBlockIndex(program, name.c_str()); } } @@ -1020,12 +1021,20 @@ void ofShader::setUniform4i(const string & name, int v1, int v2, int v3, int v4) } //-------------------------------------------------------------- -void ofShader::setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize) { - if (!bufferObjectsCache[name].isAllocated()) { - bufferObjectsCache[name].allocate(dataSize, GL_STATIC_DRAW); +void ofShader::setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize) const { + if (bufferObjectsCache.find(name) != bufferObjectsCache.end()) { + if (!bufferObjectsCache.at(name)->isAllocated()) { + bufferObjectsCache.at(name)->allocate(dataSize, GL_STATIC_DRAW); + } + bufferObjectsCache.at(name)->updateData(dataSize, data); + bufferObjectsCache.at(name)->bindBase(GL_UNIFORM_BUFFER, getUniformBlockIndex(name)); + } else { +// bufferObjectsCache.at(name) = std::make_unique(); +// for (const auto & b : bufferObjectsCache) { +// std::cout << b.first << std::endl; +// } +// std::cout << "setUniformBufferObject don't exist " << name << std::endl; } - bufferObjectsCache[name].updateData(dataSize, data); - bufferObjectsCache[name].bindBase(GL_UNIFORM_BUFFER, getUniformBlockIndex(name)); } //-------------------------------------------------------------- diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index d0cfcecaafb..bca9c943291 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -161,7 +161,7 @@ class ofShader { // Dmtr testing - void setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize); + void setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize) const; void setUniform1f(const std::string & name, float v1) const; void setUniform2f(const std::string & name, float v1, float v2) const; @@ -283,7 +283,12 @@ class ofShader { std::unordered_map shaders; - std::unordered_map bufferObjectsCache; +// std::unordered_map bufferObjectsCache; +// const std::unordered_map & getBufferObjectsCache() const { +// return bufferObjectsCache; +// } + std::unordered_map> bufferObjectsCache; + std::unordered_map uniformsCache; mutable std::unordered_map attributesBindingsCache; diff --git a/libs/openFrameworks/gl/shaders/pbr.vert b/libs/openFrameworks/gl/shaders/pbr.vert index 5c7cc8b1355..fc464948d0a 100644 --- a/libs/openFrameworks/gl/shaders/pbr.vert +++ b/libs/openFrameworks/gl/shaders/pbr.vert @@ -17,23 +17,23 @@ IN vec4 color; IN vec4 normal; IN vec2 texcoord; -layout(std140) uniform matrices { - mat4 modelMatrix; - mat4 viewMatrix; - mat4 modelViewMatrix; - mat4 modelViewProjectionMatrix; - mat4 projectionMatrix; - mat4 textureMatrix; -}; +//layout(std140) uniform matrices { +// mat4 modelMatrix; +// mat4 viewMatrix; +// mat4 modelViewMatrix; +// mat4 modelViewProjectionMatrix; +// mat4 projectionMatrix; +// mat4 textureMatrix; +//}; // these are passed in from OF programmable renderer -//uniform mat4 modelViewMatrix; -//uniform mat4 modelMatrix; -//uniform mat4 viewMatrix; -//uniform mat4 modelViewProjectionMatrix; -//uniform mat4 projectionMatrix; -//uniform mat4 textureMatrix; +uniform mat4 modelViewMatrix; +uniform mat4 modelMatrix; +uniform mat4 viewMatrix; +uniform mat4 modelViewProjectionMatrix; +uniform mat4 projectionMatrix; +uniform mat4 textureMatrix; uniform vec2 mat_texcoord_scale; diff --git a/libs/openFrameworks/gl/shaders/phong.frag b/libs/openFrameworks/gl/shaders/phong.frag index b2b584cf5ba..6cce911798e 100644 --- a/libs/openFrameworks/gl/shaders/phong.frag +++ b/libs/openFrameworks/gl/shaders/phong.frag @@ -48,6 +48,16 @@ static const string fragmentShader = R"( uniform vec4 global_ambient; // these are passed in from OF programmable renderer + +//layout(std140) uniform matrices { +// mat4 modelMatrix; +// mat4 viewMatrix; +// mat4 modelViewMatrix; +// mat4 modelViewProjectionMatrix; +// mat4 projectionMatrix; +// mat4 textureMatrix; +//}; + uniform mat4 viewMatrix; uniform mat4 modelViewMatrix; uniform mat4 modelViewProjectionMatrix; @@ -55,12 +65,7 @@ static const string fragmentShader = R"( uniform mat4 textureMatrix; uniform mat4 projectionMatrix; // -//layout(std140) uniform matrices { -// mat4 modelMatrix; -// mat4 viewMatrix; -// mat4 modelViewMatrix; -// mat4 modelViewProjectionMatrix; -//}; + #if defined(MAX_LIGHTS) && MAX_LIGHTS uniform lightData lights[MAX_LIGHTS]; diff --git a/libs/openFrameworks/gl/shaders/phong.vert b/libs/openFrameworks/gl/shaders/phong.vert index 83d9bbbf871..03af6223b47 100644 --- a/libs/openFrameworks/gl/shaders/phong.vert +++ b/libs/openFrameworks/gl/shaders/phong.vert @@ -16,6 +16,7 @@ IN vec4 normal; IN vec2 texcoord; + //layout(std140) uniform matrices { // mat4 modelMatrix; // mat4 viewMatrix; @@ -26,12 +27,12 @@ IN vec2 texcoord; //}; // these are passed in from OF programmable renderer -uniform mat4 modelMatrix; -uniform mat4 viewMatrix; -uniform mat4 modelViewMatrix; -uniform mat4 modelViewProjectionMatrix; -uniform mat4 projectionMatrix; -uniform mat4 textureMatrix; +//uniform mat4 modelMatrix; +//uniform mat4 viewMatrix; +//uniform mat4 modelViewMatrix; +//uniform mat4 modelViewProjectionMatrix; +//uniform mat4 projectionMatrix; +//uniform mat4 textureMatrix; uniform mat4 normalMatrix; From 5f0b37dbb70ec8759368634dfdae99e93d487ad3 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 16:36:41 -0300 Subject: [PATCH 110/143] test removing ifdef --- libs/openFrameworks/gl/ofBufferObject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/gl/ofBufferObject.cpp b/libs/openFrameworks/gl/ofBufferObject.cpp index db752728744..978eed98889 100644 --- a/libs/openFrameworks/gl/ofBufferObject.cpp +++ b/libs/openFrameworks/gl/ofBufferObject.cpp @@ -81,7 +81,7 @@ void ofBufferObject::unbind(GLenum target) const{ } } -#if !defined(TARGET_OPENGLES) || defined(TARGET_EMSCRIPTEN) +//#if !defined(TARGET_OPENGLES) || defined(TARGET_EMSCRIPTEN) void ofBufferObject::bindBase(GLenum target,GLuint index) const{ if(data){ glBindBufferBase(target,index,data->id); @@ -108,7 +108,7 @@ void ofBufferObject::bindRange(GLenum target,GLuint index, GLintptr offset, GLsi void ofBufferObject::unbindRange(GLenum target,GLuint index) const{ glBindBufferBase(target,index,0); } -#endif +//#endif GLuint ofBufferObject::getId() const{ if(data) return data->id; From 13875593d4354d1e70efb050f335a6e7b29e5c52 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 16:56:13 -0300 Subject: [PATCH 111/143] less defines --- libs/openFrameworks/gl/ofShader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index bca9c943291..fe71cace090 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -195,14 +195,14 @@ class ofShader { // set attributes that vary per vertex (look up the location before glBegin) GLint getAttributeLocation(const std::string & name) const; -#ifndef TARGET_OPENGLES +//#ifndef TARGET_OPENGLES #ifdef GLEW_ARB_uniform_buffer_object GLint getUniformBlockIndex(const std::string & name) const; GLint getUniformBlockBinding(const std::string & name) const; void bindUniformBlock(GLuint bindind, const std::string & name) const; void printActiveUniformBlocks() const; #endif -#endif +//#endif #ifndef TARGET_OPENGLES void setAttribute1s(GLint location, short v1) const; From 91831e6030e29cfea713104dba953d080cd89b1f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 20:04:07 -0300 Subject: [PATCH 112/143] bindbase opengles --- libs/openFrameworks/gl/ofBufferObject.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/gl/ofBufferObject.h b/libs/openFrameworks/gl/ofBufferObject.h index d7d4fe15280..8130ba762c6 100644 --- a/libs/openFrameworks/gl/ofBufferObject.h +++ b/libs/openFrameworks/gl/ofBufferObject.h @@ -40,7 +40,7 @@ class ofBufferObject { /// binds the passed target to buffer 0 void unbind(GLenum target) const; -#if !defined(TARGET_OPENGLES) || defined(TARGET_EMSCRIPTEN) +//#if !defined(TARGET_OPENGLES) || defined(TARGET_EMSCRIPTEN) /// glBindBufferBase: https://www.opengl.org/sdk/docs/man4/html/glBindBufferBase.xhtml void bindBase(GLenum target,GLuint index) const; @@ -52,7 +52,7 @@ class ofBufferObject { /// binds the given target and index to 0 void unbindRange(GLenum target,GLuint index) const; -#endif +//#endif /// returns the id of the buffer if it's allocated or 0 otherwise GLuint getId() const; From cd71996b3e05807ec6429e4b40cf9fc7cbae9501 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 21:59:44 -0300 Subject: [PATCH 113/143] archs --- .../project/osx/openFrameworksLib.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index f4105425043..8fbe30bb4cd 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -980,6 +980,7 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS)"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/local/lib; @@ -1004,6 +1005,7 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS)"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = ""; From 2bdcc2069e17498b25339a43a8a5b3151f108788 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 22:01:30 -0300 Subject: [PATCH 114/143] archs in macos --- .../project/macos/openFrameworksLib.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj index 1f5553bdc44..ffd322c0c66 100644 --- a/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj @@ -2189,6 +2189,7 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS)"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/local/lib; @@ -2213,6 +2214,7 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS)"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = ""; From 08fa6273cbcfa93cc6898e14c712b3d853946e39 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 22:29:49 -0300 Subject: [PATCH 115/143] more defines commented out --- libs/openFrameworks/gl/ofShader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index be63f823c7a..a3b2023252d 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -1330,8 +1330,8 @@ GLint ofShader::getUniformLocation(const string & name) const { } } -#ifndef TARGET_OPENGLES - #ifdef GLEW_ARB_uniform_buffer_object +//#ifndef TARGET_OPENGLES +// #ifdef GLEW_ARB_uniform_buffer_object //-------------------------------------------------------------- GLint ofShader::getUniformBlockIndex(const string & name) const { if (!bLoaded) return -1; @@ -1412,8 +1412,8 @@ void ofShader::bindUniformBlock(GLuint binding, const string & name) const { } } } - #endif -#endif +// #endif +//#endif //-------------------------------------------------------------- void ofShader::printActiveUniforms() const { From 5b7a775662acc56a20f3fb13b7b93ee11df3fadf Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 22:35:40 -0300 Subject: [PATCH 116/143] up --- libs/openFrameworks/gl/ofShader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index fe71cace090..d0376631d02 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -196,12 +196,12 @@ class ofShader { GLint getAttributeLocation(const std::string & name) const; //#ifndef TARGET_OPENGLES -#ifdef GLEW_ARB_uniform_buffer_object +//#ifdef GLEW_ARB_uniform_buffer_object GLint getUniformBlockIndex(const std::string & name) const; GLint getUniformBlockBinding(const std::string & name) const; void bindUniformBlock(GLuint bindind, const std::string & name) const; void printActiveUniformBlocks() const; -#endif +//#endif //#endif #ifndef TARGET_OPENGLES From 40ba7dc792dc72c8c09e19a345002a2a2055ce78 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 22:42:12 -0300 Subject: [PATCH 117/143] ONLY_ACTIVE_ARCH --- .../project/macos/openFrameworksLib.xcodeproj/project.pbxproj | 2 +- .../project/osx/openFrameworksLib.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj index ffd322c0c66..69a7ef9a2a9 100644 --- a/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/macos/openFrameworksLib.xcodeproj/project.pbxproj @@ -2268,7 +2268,7 @@ MERGEABLE_LIBRARY = YES; MERGED_BINARY_TYPE = automatic; OBJROOT = "$(SRCROOT)/../../lib/macos/build/release"; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index 8fbe30bb4cd..becc9144838 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -1035,7 +1035,7 @@ CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; CONFIGURATION_TEMP_DIR = "$(SRCROOT)/../../lib/macos/build/debug/"; OBJROOT = "$(SRCROOT)/../../lib/macos/build/debug/"; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = ""; }; name = Debug; @@ -1047,7 +1047,7 @@ CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; CONFIGURATION_TEMP_DIR = "$(SRCROOT)/../../lib/macos/build/release/"; OBJROOT = "$(SRCROOT)/../../lib/macos/build/release"; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = ""; }; name = Release; From 5916c38fa47559b94cd730a89b5ea95d27e113d6 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 2 Sep 2024 23:22:28 -0300 Subject: [PATCH 118/143] up --- libs/openFrameworks/gl/ofShader.cpp | 12 ++++++------ .../macos/emptyExample.xcodeproj/project.pbxproj | 1 + .../osx/emptyExample.xcodeproj/project.pbxproj | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index a3b2023252d..80a86688c0b 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -713,7 +713,7 @@ bool ofShader::linkProgram() { } } -#ifndef TARGET_OPENGLES +//#ifndef TARGET_OPENGLES #ifdef GLEW_ARB_uniform_buffer_object if (GLEW_ARB_uniform_buffer_object) { // Pre-cache all active uniforms blocks @@ -732,7 +732,7 @@ bool ofShader::linkProgram() { } } #endif -#endif +//#endif #ifdef TARGET_ANDROID ofAddListener(ofxAndroidEvents().unloadGL, this, &ofShader::unloadGL); @@ -768,11 +768,11 @@ void ofShader::reloadGL() { auto bindings = attributesBindingsCache; shaders.clear(); uniformsCache.clear(); - #ifndef TARGET_OPENGLES + //#ifndef TARGET_OPENGLES #ifdef GLEW_ARB_uniform_buffer_object // Core in OpenGL 3.1 uniformBlocksCache.clear(); #endif - #endif + //#endif attributesBindingsCache.clear(); for (auto & shader : source) { auto source = shader.second.source; @@ -823,11 +823,11 @@ void ofShader::unload() { shaders.clear(); uniformsCache.clear(); -#ifndef TARGET_OPENGLES +//#ifndef TARGET_OPENGLES #ifdef GLEW_ARB_uniform_buffer_object // Core in OpenGL 3.1 uniformBlocksCache.clear(); #endif -#endif +//#endif attributesBindingsCache.clear(); #ifdef TARGET_ANDROID ofRemoveListener(ofxAndroidEvents().reloadGL, this, &ofShader::reloadGL); diff --git a/scripts/templates/macos/emptyExample.xcodeproj/project.pbxproj b/scripts/templates/macos/emptyExample.xcodeproj/project.pbxproj index e966b681bdb..810d5b26ba0 100644 --- a/scripts/templates/macos/emptyExample.xcodeproj/project.pbxproj +++ b/scripts/templates/macos/emptyExample.xcodeproj/project.pbxproj @@ -828,6 +828,7 @@ BF6278052BADE871008864C1 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ONLY_ACTIVE_ARCH = YES; ALWAYS_SEARCH_USER_PATHS = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; diff --git a/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj b/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj index 74d0151bd5f..9ef258a821d 100644 --- a/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj +++ b/scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj @@ -132,6 +132,7 @@ "baseConfigurationReference": "E4EB6923138AFD0F00A09F29", "isa": "XCBuildConfiguration", "buildSettings": { + "ONLY_ACTIVE_ARCH" : "YES", "CODE_SIGN_ENTITLEMENTS": "of.entitlements", "GCC_UNROLL_LOOPS": "YES", "HEADER_SEARCH_PATHS": [ @@ -148,6 +149,7 @@ "baseConfigurationReference": "E4EB6923138AFD0F00A09F29", "isa": "XCBuildConfiguration", "buildSettings": { + "ONLY_ACTIVE_ARCH" : "YES", "HEADER_SEARCH_PATHS": [ "$(OF_CORE_HEADERS)", "src" From efc31da5372cfd9444c4bb2989e03b4e64dec58f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 16:24:38 -0300 Subject: [PATCH 119/143] project --- .../project.pbxproj | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index becc9144838..a150a7595fd 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -831,17 +831,14 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1530; + LastUpgradeCheck = 1540; }; buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "openFrameworksLib" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, - Japanese, - French, - German, + en, ); mainGroup = E4B69B4A0A3A1720003C02F2; productRefGroup = E4B69B4A0A3A1720003C02F2; @@ -872,6 +869,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = "/usr/bin/env bash"; shellScript = "#!/usr/bin/env bash\nif [ ! -d \"${SRCROOT}/../../../freetype/lib/macos/freetype.xcframework\" ]; then\n\techo \"openFrameworks has missing xcFrameworks for osx. Downloading libaries now via scripts/osx/download_libs.sh\"\n ${SRCROOT}/../../../../scripts/osx/download_libs.sh\nelse\n\techo \"xcFrameworks found\"\nfi\n"; + showEnvVarsInLog = 0; }; BFF80A5D2C50B2C300784E74 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -980,7 +978,6 @@ E4B27C1610CBEB8E00536013 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS)"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/local/lib; @@ -1005,7 +1002,6 @@ E4B27C1710CBEB8E00536013 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS)"; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = ""; @@ -1032,11 +1028,14 @@ isa = XCBuildConfiguration; baseConfigurationReference = E432815F138AC0470047C5CB /* Debug.xcconfig */; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; CONFIGURATION_TEMP_DIR = "$(SRCROOT)/../../lib/macos/build/debug/"; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; OBJROOT = "$(SRCROOT)/../../lib/macos/build/debug/"; ONLY_ACTIVE_ARCH = YES; - SDKROOT = ""; + SDKROOT = macosx; }; name = Debug; }; @@ -1044,11 +1043,13 @@ isa = XCBuildConfiguration; baseConfigurationReference = E4328160138AC04A0047C5CB /* Release.xcconfig */; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../../lib/macos/"; CONFIGURATION_TEMP_DIR = "$(SRCROOT)/../../lib/macos/build/release/"; + ENABLE_USER_SCRIPT_SANDBOXING = YES; OBJROOT = "$(SRCROOT)/../../lib/macos/build/release"; ONLY_ACTIVE_ARCH = YES; - SDKROOT = ""; + SDKROOT = macosx; }; name = Release; }; From c05ea0b650773b5aa4d17fa0cbd083e1adddbc57 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 22:00:56 -0300 Subject: [PATCH 120/143] static strcut --- libs/openFrameworks/app/ofAppRunner.cpp | 215 ++++++++++++------------ libs/openFrameworks/app/ofAppRunner.h | 41 ++++- libs/openFrameworks/app/ofMainLoop.cpp | 4 +- libs/openFrameworks/app/ofMainLoop.h | 3 +- 4 files changed, 150 insertions(+), 113 deletions(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 9f92b3bff7d..a664a497774 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -12,6 +12,9 @@ using std::shared_ptr; + + + #if !defined(TARGET_NODISPLAY) #if !defined( TARGET_OF_IOS ) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) #include "ofAppGLFWWindow.h" @@ -43,29 +46,9 @@ using std::shared_ptr; #endif + //-------------------------------------- namespace{ - - shared_ptr & mainLoop(){ - static shared_ptr * mainLoop(new shared_ptr(new ofMainLoop)); - return *mainLoop; - } - - bool & initialized(){ - static bool * initialized = new bool(false); - return *initialized; - } - - bool & exiting(){ - static bool * exiting = new bool(false); - return *exiting; - } - - ofCoreEvents & noopEvents(){ - static auto * noopEvents = new ofCoreEvents(); - return *noopEvents; - } - #if defined(TARGET_LINUX) || defined(TARGET_OSX) #include #include @@ -84,9 +67,12 @@ namespace{ signal(SIGHUP, nullptr); signal(SIGABRT, nullptr); - if(mainLoop()){ - mainLoop()->shouldClose(signum); - } +// if(mainLoop()){ +// mainLoop()->shouldClose(signum); +// } + if(ofCore.mainLoop){ + ofCore.mainLoop->shouldClose(signum); + } } #endif } @@ -105,10 +91,16 @@ void ofCloseFreeImage(); void ofInit(){ + + ofCore.init(); + + + + // std::cout << "ofInit !!!" << std::endl; - if(initialized()) return; - initialized() = true; - exiting() = false; +// if(initialized()) return; +// initialized() = true; +// exiting() = false; // std::cout << "ofInit() " << std::endl; #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) @@ -162,45 +154,53 @@ void ofInit(){ setlocale(LC_ALL,""); ofLogWarning("ofInit") << "MSYS2 has limited support for UTF-8. using "<< std::string( setlocale(LC_ALL,NULL) ); #endif + return; + } //-------------------------------------- +// TODO: const & shared_ptr ofGetMainLoop(){ - return mainLoop(); + return ofCore.mainLoop; } //-------------------------------------- void ofSetMainLoop(const shared_ptr & newMainLoop) { - mainLoop() = newMainLoop; -} - -//-------------------------------------- -int ofRunApp(ofBaseApp * OFSA){ - mainLoop()->run(shared_ptr(OFSA)); - auto ret = ofRunMainLoop(); -#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) - ofExitCallback(); -#endif - return ret; -} - -//-------------------------------------- -int ofRunApp(shared_ptr && app){ - mainLoop()->run(std::move(app)); - auto ret = ofRunMainLoop(); -#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) - ofExitCallback(); -#endif - return ret; -} - -//-------------------------------------- -void ofRunApp(const shared_ptr & window, shared_ptr && app){ - mainLoop()->run(window, std::move(app)); + ofCore.mainLoop = newMainLoop; +} + +//-------------------------------------- +//int ofRunApp(ofBaseApp * OFSA){ +// ofCore.mainLoop->run(shared_ptr(OFSA)); +// auto ret = ofRunMainLoop(); +//#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) +// ofExitCallback(); +//#endif +// return ret; +//} +// +////-------------------------------------- +//int ofRunApp(shared_ptr && app){ +// ofCore.mainLoop->run(std::move(app)); +// auto ret = ofRunMainLoop(); +//#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) +// ofExitCallback(); +//#endif +// return ret; +//} + +////-------------------------------------- +//void ofRunApp(const shared_ptr & window, shared_ptr && app){ +// ofCore.mainLoop->run(window, std::move(app)); +//} + +void ofRunApp( + const shared_ptr & window, const shared_ptr & app){ + ofCore.mainLoop->run(window, app); } int ofRunMainLoop(){ - auto ret = mainLoop()->loop(); + auto ret = ofCore.mainLoop->loop(); return ret; } @@ -221,7 +221,7 @@ void ofSetupOpenGL(int w, int h, ofWindowMode screenMode){ shared_ptr ofCreateWindow(const ofWindowSettings & settings){ ofInit(); - return mainLoop()->createWindow(settings); + return ofCore.mainLoop->createWindow(settings); } //----------------------- gets called when the app exits @@ -229,11 +229,9 @@ shared_ptr ofCreateWindow(const ofWindowSettings & settings){ // at the end of the application void ofExitCallback(){ - if(!initialized()) return; + + ofCore.exit(); - // controlled destruction of the mainLoop before - // any other deinitialization - mainLoop()->exit(); // everything should be destroyed here, except for // static objects @@ -279,39 +277,38 @@ void ofExitCallback(){ // events of::priv::endutils(); - initialized() = false; - exiting() = true; + } //-------------------------------------- // core events instance & arguments ofCoreEvents & ofEvents(){ - auto window = mainLoop()->getCurrentWindow(); + auto window = ofCore.mainLoop->getCurrentWindow(); if(window){ return window->events(); }else{ - if(!exiting()){ + if(!ofCore.exiting){ ofLogError("ofEvents") << "Trying to call ofEvents() before a window has been setup"; ofLogError("ofEvents") << "We'll return a void events instance to avoid crashes but somethings might not work"; ofLogError("ofEvents") << "Set a breakpoint in " << __FILE__ << " line " << __LINE__ << " to check where is the wrong call"; } - return noopEvents(); + return ofCore.noopEvents; } } //-------------------------------------- void ofSetEscapeQuitsApp(bool bQuitOnEsc){ - mainLoop()->setEscapeQuitsLoop(bQuitOnEsc); + ofCore.mainLoop->setEscapeQuitsLoop(bQuitOnEsc); } //-------------------------------------- shared_ptr & ofGetCurrentRenderer(){ - return mainLoop()->getCurrentWindow()->renderer(); + return ofCore.mainLoop->getCurrentWindow()->renderer(); } //-------------------------------------- ofBaseApp * ofGetAppPtr(){ - return mainLoop()->getCurrentApp().get(); + return ofCore.mainLoop->getCurrentApp().get(); } //-------------------------------------- @@ -325,33 +322,33 @@ bool ofIsCurrentThreadTheMainThread() { //-------------------------------------- ofAppBaseWindow * ofGetWindowPtr(){ - return mainLoop()->getCurrentWindow().get(); + return ofCore.mainLoop->getCurrentWindow().get(); } //-------------------------------------- std::shared_ptr ofGetCurrentWindow() { - return mainLoop()->getCurrentWindow(); + return ofCore.mainLoop->getCurrentWindow(); } //-------------------------------------- void ofExit(int status){ - mainLoop()->shouldClose(status); + ofCore.mainLoop->shouldClose(status); } //-------------------------------------- void ofHideCursor(){ - mainLoop()->getCurrentWindow()->hideCursor(); + ofCore.mainLoop->getCurrentWindow()->hideCursor(); } //-------------------------------------- void ofShowCursor(){ - mainLoop()->getCurrentWindow()->showCursor(); + ofCore.mainLoop->getCurrentWindow()->showCursor(); } //-------------------------------------- // FIXME: this is not standard with the other window modes. void ofSetOrientation(ofOrientation orientation, bool vFlip){ - mainLoop()->getCurrentWindow()->setOrientation(orientation); + ofCore.mainLoop->getCurrentWindow()->setOrientation(orientation); // TODO: every window should set orientation on it's renderer if(ofGetCurrentRenderer()){ ofGetCurrentRenderer()->setOrientation(orientation,vFlip); @@ -360,92 +357,92 @@ void ofSetOrientation(ofOrientation orientation, bool vFlip){ //-------------------------------------- ofOrientation ofGetOrientation(){ - return mainLoop()->getCurrentWindow()->getOrientation(); + return ofCore.mainLoop->getCurrentWindow()->getOrientation(); } //-------------------------------------- void ofSetWindowPosition(int x, int y){ - mainLoop()->getCurrentWindow()->setWindowPosition(x,y); + ofCore.mainLoop->getCurrentWindow()->setWindowPosition(x,y); } //-------------------------------------- void ofSetWindowShape(int width, int height){ - mainLoop()->getCurrentWindow()->setWindowShape(width, height); + ofCore.mainLoop->getCurrentWindow()->setWindowShape(width, height); } //-------------------------------------- void ofSetWindowRect(const ofRectangle & rect) { - mainLoop()->getCurrentWindow()->setWindowRect(rect); + ofCore.mainLoop->getCurrentWindow()->setWindowRect(rect); } //-------------------------------------- glm::ivec2 ofGetWindowPosition() { - return mainLoop()->getCurrentWindow()->getWindowPosition(); + return ofCore.mainLoop->getCurrentWindow()->getWindowPosition(); } //-------------------------------------- int ofGetWindowPositionX(){ - return (int)mainLoop()->getCurrentWindow()->getWindowPosition().x; + return (int)ofCore.mainLoop->getCurrentWindow()->getWindowPosition().x; } //-------------------------------------- int ofGetWindowPositionY(){ - return (int)mainLoop()->getCurrentWindow()->getWindowPosition().y; + return (int)ofCore.mainLoop->getCurrentWindow()->getWindowPosition().y; } //-------------------------------------- int ofGetScreenWidth(){ - return mainLoop()->getCurrentWindow()->getScreenSize().x; + return ofCore.mainLoop->getCurrentWindow()->getScreenSize().x; } //-------------------------------------- int ofGetScreenHeight(){ - return mainLoop()->getCurrentWindow()->getScreenSize().y; + return ofCore.mainLoop->getCurrentWindow()->getScreenSize().y; } //-------------------------------------- glm::ivec2 ofGetScreenSize() { - return mainLoop()->getCurrentWindow()->getScreenSize(); + return ofCore.mainLoop->getCurrentWindow()->getScreenSize(); } //-------------------------------------------------- int ofGetWidth(){ - return (int)mainLoop()->getCurrentWindow()->getWidth(); + return (int)ofCore.mainLoop->getCurrentWindow()->getWidth(); } //-------------------------------------------------- int ofGetHeight(){ - return (int)mainLoop()->getCurrentWindow()->getHeight(); + return (int)ofCore.mainLoop->getCurrentWindow()->getHeight(); } //-------------------------------------------------- int ofGetWindowWidth(){ - return (int)mainLoop()->getCurrentWindow()->getWindowSize().x; + return (int)ofCore.mainLoop->getCurrentWindow()->getWindowSize().x; } //-------------------------------------------------- int ofGetWindowHeight(){ - return (int)mainLoop()->getCurrentWindow()->getWindowSize().y; + return (int)ofCore.mainLoop->getCurrentWindow()->getWindowSize().y; } //-------------------------------------------------- std::string ofGetClipboardString(){ - return mainLoop()->getCurrentWindow()->getClipboardString(); + return ofCore.mainLoop->getCurrentWindow()->getClipboardString(); } //-------------------------------------------------- void ofSetClipboardString(const std::string & str){ - mainLoop()->getCurrentWindow()->setClipboardString(str); + ofCore.mainLoop->getCurrentWindow()->setClipboardString(str); } //-------------------------------------------------- bool ofDoesHWOrientation(){ - return mainLoop()->getCurrentWindow()->doesHWOrientation(); + return ofCore.mainLoop->getCurrentWindow()->doesHWOrientation(); } //-------------------------------------------------- glm::ivec2 ofGetWindowSize() { //this can't return glm::vec2(ofGetWidth(), ofGetHeight()) as width and height change based on orientation. - return mainLoop()->getCurrentWindow()->getWindowSize(); + return ofCore.mainLoop->getCurrentWindow()->getWindowSize(); } //-------------------------------------------------- @@ -466,85 +463,85 @@ ofRectangle ofGetWindowRect() { //-------------------------------------- void ofSetWindowTitle(std::string title){ - mainLoop()->getCurrentWindow()->setWindowTitle(title); + ofCore.mainLoop->getCurrentWindow()->setWindowTitle(title); } //---------------------------------------------------------- void ofEnableSetupScreen(){ - mainLoop()->getCurrentWindow()->enableSetupScreen(); + ofCore.mainLoop->getCurrentWindow()->enableSetupScreen(); } //---------------------------------------------------------- void ofDisableSetupScreen(){ - mainLoop()->getCurrentWindow()->disableSetupScreen(); + ofCore.mainLoop->getCurrentWindow()->disableSetupScreen(); } //-------------------------------------- void ofToggleFullscreen(){ - mainLoop()->getCurrentWindow()->toggleFullscreen(); + ofCore.mainLoop->getCurrentWindow()->toggleFullscreen(); } //-------------------------------------- void ofSetFullscreen(bool fullscreen){ - mainLoop()->getCurrentWindow()->setFullscreen(fullscreen); + ofCore.mainLoop->getCurrentWindow()->setFullscreen(fullscreen); } //-------------------------------------- int ofGetWindowMode(){ - return mainLoop()->getCurrentWindow()->getWindowMode(); + return ofCore.mainLoop->getCurrentWindow()->getWindowMode(); } //-------------------------------------- void ofSetVerticalSync(bool bSync){ - mainLoop()->getCurrentWindow()->setVerticalSync(bSync); + ofCore.mainLoop->getCurrentWindow()->setVerticalSync(bSync); } //-------------------------- native window handles #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) Display* ofGetX11Display(){ - return mainLoop()->getCurrentWindow()->getX11Display(); + return ofCore.mainLoop->getCurrentWindow()->getX11Display(); } Window ofGetX11Window(){ - return mainLoop()->getCurrentWindow()->getX11Window(); + return ofCore.mainLoop->getCurrentWindow()->getX11Window(); } #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) GLXContext ofGetGLXContext(){ - return mainLoop()->getCurrentWindow()->getGLXContext(); + return ofCore.mainLoop->getCurrentWindow()->getGLXContext(); } #endif #if defined(TARGET_LINUX) && defined(TARGET_OPENGLES) EGLDisplay ofGetEGLDisplay(){ - return mainLoop()->getCurrentWindow()->getEGLDisplay(); + return ofCore.mainLoop->getCurrentWindow()->getEGLDisplay(); } EGLContext ofGetEGLContext(){ - return mainLoop()->getCurrentWindow()->getEGLContext(); + return ofCore.mainLoop->getCurrentWindow()->getEGLContext(); } EGLSurface ofGetEGLSurface(){ - return mainLoop()->getCurrentWindow()->getEGLSurface(); + return ofCore.mainLoop->getCurrentWindow()->getEGLSurface(); } #endif #if defined(TARGET_OSX) void * ofGetNSGLContext(){ - return mainLoop()->getCurrentWindow()->getNSGLContext(); + return ofCore.mainLoop->getCurrentWindow()->getNSGLContext(); } void * ofGetCocoaWindow(){ - return mainLoop()->getCurrentWindow()->getCocoaWindow(); + return ofCore.mainLoop->getCurrentWindow()->getCocoaWindow(); } #endif #if defined(TARGET_WIN32) HGLRC ofGetWGLContext(){ - return mainLoop()->getCurrentWindow()->getWGLContext(); + return ofCore.mainLoop->getCurrentWindow()->getWGLContext(); } HWND ofGetWin32Window(){ - return mainLoop()->getCurrentWindow()->getWin32Window(); + return ofCore.mainLoop->getCurrentWindow()->getWin32Window(); } #endif diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 24178427192..fd3f83a3ab4 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -39,8 +39,8 @@ void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode) { ofSetupOpenGL(window, w, h, screenMode); } -int ofRunApp(std::shared_ptr && OFSA); -int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated +//int ofRunApp(std::shared_ptr && OFSA); +//int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated void ofRunApp(const std::shared_ptr & window, std::shared_ptr && app); int ofRunMainLoop(); @@ -143,3 +143,40 @@ void * ofGetCocoaWindow(); HGLRC ofGetWGLContext(); HWND ofGetWin32Window(); #endif + + + +static struct ofCoreInternal { +public: + ofCoreInternal() {}; + ~ofCoreInternal() {}; + + // ofAppRunner + bool initialized = false; + bool exiting = false; + ofCoreEvents noopEvents; + std::shared_ptr mainLoop { std::make_shared() }; + + // ofFileUtils + + void exit() { + if(!initialized) return; + + // controlled destruction of the mainLoop before + // any other deinitialization + mainLoop->exit(); + + // TODO: add shutdown functions here. + // vector of pointer to functions + + initialized = false; + exiting = true; + } + + void init() { + if (initialized) return; + initialized = true; + exiting = false; + } + +} ofCore; diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 7a7142ab225..504369b89c0 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -52,7 +52,9 @@ std::shared_ptr ofMainLoop::createWindow(const ofWindowSettings return window; } -void ofMainLoop::run(const std::shared_ptr & window, std::shared_ptr && app){ +void ofMainLoop::run( + const std::shared_ptr & window, + const std::shared_ptr & app) { mainApp = app; // windowsApps[window] = app; if(app){ diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index 47ff34a9ab6..0050c70324d 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -33,7 +33,8 @@ class ofMainLoop { ofAddListener(window->events().keyPressed,this,&ofMainLoop::keyPressed); } - void run(const std::shared_ptr & window, std::shared_ptr && app); + void run(const std::shared_ptr & window, const std::shared_ptr & app); +// std::shared_ptr && app); void run(std::shared_ptr && app); int loop(); void loopOnce(); From aa78bb4357a75c87b9517f0880b1e517450ebe76 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 22:41:08 -0300 Subject: [PATCH 121/143] updates --- examples/templates/emptyExample/src/main.cpp | 4 +- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 7 +- libs/openFrameworks/app/ofAppRunner.cpp | 95 ++++++++----------- libs/openFrameworks/app/ofAppRunner.h | 85 +++++++++-------- .../project/macos/config.macos.default.mk | 2 +- .../project/osx/config.osx.default.mk | 2 +- 6 files changed, 93 insertions(+), 102 deletions(-) diff --git a/examples/templates/emptyExample/src/main.cpp b/examples/templates/emptyExample/src/main.cpp index 4e6518d49dc..1ac3c5eaf00 100644 --- a/examples/templates/emptyExample/src/main.cpp +++ b/examples/templates/emptyExample/src/main.cpp @@ -10,8 +10,8 @@ int main( ){ settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN auto window = ofCreateWindow(settings); - - ofRunApp(window, std::make_shared()); + auto app = std::make_shared(); + ofRunApp(window, app); ofRunMainLoop(); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index be065511ff1..24385c08142 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -870,10 +870,9 @@ static void rotateMouseXY(ofOrientation orientation, int w, int h, double & x, d //------------------------------------------------------------ ofAppGLFWWindow * ofAppGLFWWindow::setCurrent(GLFWwindow * windowP) { - auto instance = static_cast(glfwGetWindowUserPointer(windowP)); - auto mainLoop = ofGetMainLoop(); - if (mainLoop) { - mainLoop->setCurrentWindow(instance); + auto instance { static_cast(glfwGetWindowUserPointer(windowP)) }; + if (ofCore.mainLoop) { + ofCore.mainLoop->setCurrentWindow(instance); } instance->makeCurrent(); return instance; diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index a664a497774..ffb8ff4e335 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -26,7 +26,7 @@ using std::shared_ptr; auto settings = windowPtr->getSettings(); settings.setSize(w,h); settings.windowMode = screenMode; - ofGetMainLoop()->addWindow(windowPtr); + ofCore.mainLoop->addWindow(windowPtr); windowPtr->setup(settings); } #endif @@ -93,8 +93,35 @@ void ofCloseFreeImage(); void ofInit(){ ofCore.init(); - - + ofCore.shutdownFunctions.emplace_back(ofURLFileLoaderShutdown); + ofCore.shutdownFunctions.emplace_back(ofTrueTypeShutdown); + ofCore.shutdownFunctions.emplace_back(ofCloseFreeImage); + + ofCore.shutdownFunctions = { + ofURLFileLoaderShutdown, + ofTrueTypeShutdown, + ofCloseFreeImage, + // not even needed. empty function + of::priv::endutils, +#ifndef TARGET_NO_SOUND + ofSoundShutdown, +#endif + +#if defined(OF_VIDEO_CAPTURE_QUICKTIME) || defined(OF_VIDEO_PLAYER_QUICKTIME) + closeQuicktime, +#endif + +#ifdef TARGET_LINUX + ofGstUtils::quitGstMainLoop, +#endif + }; + + std::cout << "ofInit, shutdown functions size = " << ofCore.shutdownFunctions.size() << std::endl; + + + + + // std::cout << "ofInit !!!" << std::endl; @@ -195,7 +222,8 @@ void ofSetMainLoop(const shared_ptr & newMainLoop) { //} void ofRunApp( - const shared_ptr & window, const shared_ptr & app){ + const shared_ptr & window, + const shared_ptr & app){ ofCore.mainLoop->run(window, app); } @@ -219,71 +247,24 @@ void ofSetupOpenGL(int w, int h, ofWindowMode screenMode){ ofCreateWindow(settings); } + shared_ptr ofCreateWindow(const ofWindowSettings & settings){ ofInit(); return ofCore.mainLoop->createWindow(settings); } -//----------------------- gets called when the app exits -// currently looking at who to turn off -// at the end of the application void ofExitCallback(){ - ofCore.exit(); - - - // everything should be destroyed here, except for - // static objects - - - // finish every library and subsystem - ofURLFileLoaderShutdown(); - - #ifndef TARGET_NO_SOUND - //------------------------ - // try to close engine if needed: - ofSoundShutdown(); - //------------------------ - #endif - - // try to close quicktime, for non-linux systems: - #if defined(OF_VIDEO_CAPTURE_QUICKTIME) || defined(OF_VIDEO_PLAYER_QUICKTIME) - closeQuicktime(); - #endif - - - //------------------------ - // try to close freeImage: - ofCloseFreeImage(); - - - #ifdef WIN32_HIGH_RES_TIMING - timeEndPeriod(1); - #endif - - //------------------------ - // try to close gstreamer - #ifdef TARGET_LINUX - ofGstUtils::quitGstMainLoop(); - #endif - - //------------------------ - // try to close font libraries - ofTrueTypeShutdown(); - - // static deinitialization happens after this finishes - // every object should have ended by now and won't receive any - // events - of::priv::endutils(); - - +#ifdef WIN32_HIGH_RES_TIMING + timeEndPeriod(1); +#endif } //-------------------------------------- // core events instance & arguments ofCoreEvents & ofEvents(){ - auto window = ofCore.mainLoop->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if(window){ return window->events(); }else{ @@ -313,7 +294,7 @@ ofBaseApp * ofGetAppPtr(){ //-------------------------------------- std::thread::id ofGetMainThreadId() { - return ofGetMainLoop()->get_thread_id() ; + return ofCore.mainLoop->get_thread_id() ; } bool ofIsCurrentThreadTheMainThread() { diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index fd3f83a3ab4..f56a1de21d8 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -10,6 +10,51 @@ class ofBaseApp; class ofBaseRenderer; class ofCoreEvents; + + +static struct ofCoreInternal { +public: + ofCoreInternal() {}; + ~ofCoreInternal() {}; + + std::vector > shutdownFunctions; + // ofAppRunner + bool initialized = false; + bool exiting = false; + ofCoreEvents noopEvents; + std::shared_ptr mainLoop { std::make_shared() }; + + // ofFileUtils + + void exit() { + if(!initialized) return; + + // controlled destruction of the mainLoop before + // any other deinitialization + mainLoop->exit(); + + // TODO: add shutdown functions here. + // vector of pointer to functions + for (const auto & func : shutdownFunctions) { + func(); + } + + initialized = false; + exiting = true; + } + + void init() { + if (initialized) return; + initialized = true; + exiting = false; + } + +} ofCore; + + + + + void ofInit(); void ofSetupOpenGL(int w, int h, ofWindowMode screenMode); // sets up the opengl context! std::shared_ptr ofCreateWindow(const ofWindowSettings & settings); // sets up the opengl context! @@ -22,7 +67,7 @@ void ofSetupOpenGL(const std::shared_ptr & windowPtr, int w, int h, ofWi ofWindowSettings settings; settings.setSize(w, h); settings.windowMode = screenMode; - ofGetMainLoop()->addWindow(windowPtr); + ofCore.mainLoop->addWindow(windowPtr); windowPtr->setup(settings); } @@ -41,7 +86,8 @@ void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode) { //int ofRunApp(std::shared_ptr && OFSA); //int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated -void ofRunApp(const std::shared_ptr & window, std::shared_ptr && app); +void ofRunApp(const std::shared_ptr & window, + const std::shared_ptr & app); int ofRunMainLoop(); ofBaseApp * ofGetAppPtr(); @@ -145,38 +191,3 @@ HWND ofGetWin32Window(); #endif - -static struct ofCoreInternal { -public: - ofCoreInternal() {}; - ~ofCoreInternal() {}; - - // ofAppRunner - bool initialized = false; - bool exiting = false; - ofCoreEvents noopEvents; - std::shared_ptr mainLoop { std::make_shared() }; - - // ofFileUtils - - void exit() { - if(!initialized) return; - - // controlled destruction of the mainLoop before - // any other deinitialization - mainLoop->exit(); - - // TODO: add shutdown functions here. - // vector of pointer to functions - - initialized = false; - exiting = true; - } - - void init() { - if (initialized) return; - initialized = true; - exiting = false; - } - -} ofCore; diff --git a/libs/openFrameworksCompiled/project/macos/config.macos.default.mk b/libs/openFrameworksCompiled/project/macos/config.macos.default.mk index 8dcd1ecc165..0dee37f6ffd 100644 --- a/libs/openFrameworksCompiled/project/macos/config.macos.default.mk +++ b/libs/openFrameworksCompiled/project/macos/config.macos.default.mk @@ -82,7 +82,7 @@ ifndef MAC_OS_C_VER endif ifndef MAC_OS_CPP_VER - MAC_OS_CPP_VER = -std=c++23 + MAC_OS_CPP_VER = -std=c++20 endif # Link against libstdc++ to silence tr1/memory errors on latest versions of osx diff --git a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk index 13997ecd630..31c0140f2c3 100644 --- a/libs/openFrameworksCompiled/project/osx/config.osx.default.mk +++ b/libs/openFrameworksCompiled/project/osx/config.osx.default.mk @@ -82,7 +82,7 @@ ifndef MAC_OS_C_VER endif ifndef MAC_OS_CPP_VER - MAC_OS_CPP_VER = -std=c++23 + MAC_OS_CPP_VER = -std=c++20 endif # Link against libstdc++ to silence tr1/memory errors on latest versions of osx From 4bc9a7efec89657040a959cd995100ecfdd521b9 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 22:50:44 -0300 Subject: [PATCH 122/143] updates --- addons/ofxiOS/src/core/ofxiOSGLKView.mm | 8 ++--- libs/openFrameworks/app/ofAppRunner.cpp | 34 ++++--------------- libs/openFrameworks/app/ofAppRunner.h | 7 ++-- libs/openFrameworks/graphics/ofGraphics.cpp | 2 +- .../graphics/ofGraphicsCairo.cpp | 2 +- 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/addons/ofxiOS/src/core/ofxiOSGLKView.mm b/addons/ofxiOS/src/core/ofxiOSGLKView.mm index 04e83cde705..3712e5dcbba 100644 --- a/addons/ofxiOS/src/core/ofxiOSGLKView.mm +++ b/addons/ofxiOS/src/core/ofxiOSGLKView.mm @@ -83,23 +83,23 @@ - (instancetype)initWithFrame:(CGRect)frame andApp:(ofxiOSApp *)appPtr sharegrou } - (void)setup { - if(window.get() == NULL) { + if(window.get() == nullptr) { ofLog(OF_LOG_FATAL_ERROR, "ofxiOSEAGLView setup. Failed setup. window is NULL"); return; } if(app.get() != ofGetAppPtr()) { // check if already running. - ofSetMainLoop(shared_ptr(NULL)); // destroy old main loop. + ofSetMainLoop(shared_ptr(nullptr)); // destroy old main loop. auto mainLoop = std::make_shared(); // make new main loop. ofSetMainLoop(mainLoop); ofiOSWindowSettings windowSettings = window->getSettings(); - window = NULL; + window = nullptr; window = dynamic_pointer_cast(ofCreateWindow(windowSettings)); - ofRunApp(app); + ofRunApp(app, window); } if(window->isProgrammableRenderer() == true) { diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index ffb8ff4e335..095e53a0cf8 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -12,9 +12,6 @@ using std::shared_ptr; - - - #if !defined(TARGET_NODISPLAY) #if !defined( TARGET_OF_IOS ) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) #include "ofAppGLFWWindow.h" @@ -33,7 +30,7 @@ using std::shared_ptr; #endif #ifdef TARGET_LINUX -#include "ofGstUtils.h" + #include "ofGstUtils.h" #endif // adding this for vc2010 compile: error C3861: 'closeQuicktime': identifier not found @@ -67,9 +64,6 @@ namespace{ signal(SIGHUP, nullptr); signal(SIGABRT, nullptr); -// if(mainLoop()){ -// mainLoop()->shouldClose(signum); -// } if(ofCore.mainLoop){ ofCore.mainLoop->shouldClose(signum); } @@ -91,12 +85,7 @@ void ofCloseFreeImage(); void ofInit(){ - ofCore.init(); - ofCore.shutdownFunctions.emplace_back(ofURLFileLoaderShutdown); - ofCore.shutdownFunctions.emplace_back(ofTrueTypeShutdown); - ofCore.shutdownFunctions.emplace_back(ofCloseFreeImage); - ofCore.shutdownFunctions = { ofURLFileLoaderShutdown, ofTrueTypeShutdown, @@ -104,32 +93,21 @@ void ofInit(){ // not even needed. empty function of::priv::endutils, #ifndef TARGET_NO_SOUND - ofSoundShutdown, + ofSoundShutdown, #endif #if defined(OF_VIDEO_CAPTURE_QUICKTIME) || defined(OF_VIDEO_PLAYER_QUICKTIME) - closeQuicktime, + closeQuicktime, #endif #ifdef TARGET_LINUX - ofGstUtils::quitGstMainLoop, + ofGstUtils::quitGstMainLoop, #endif }; - std::cout << "ofInit, shutdown functions size = " << ofCore.shutdownFunctions.size() << std::endl; - - - - +// std::cout << "ofInit, shutdown functions size = " << ofCore.shutdownFunctions.size() << std::endl; +// - - -// std::cout << "ofInit !!!" << std::endl; -// if(initialized()) return; -// initialized() = true; -// exiting() = false; - -// std::cout << "ofInit() " << std::endl; #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) // manage own exit #else diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index f56a1de21d8..de4b89c4b4d 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -10,8 +10,6 @@ class ofBaseApp; class ofBaseRenderer; class ofCoreEvents; - - static struct ofCoreInternal { public: ofCoreInternal() {}; @@ -33,8 +31,7 @@ static struct ofCoreInternal { // any other deinitialization mainLoop->exit(); - // TODO: add shutdown functions here. - // vector of pointer to functions + // all shutdown functions called for (const auto & func : shutdownFunctions) { func(); } @@ -155,7 +152,7 @@ void ofToggleFullscreen(); void ofSetVerticalSync(bool bSync); ofCoreEvents & ofEvents(); -void ofSetCurrentRenderer(std::shared_ptr renderer, bool setDefaults = false); +void ofSetCurrentRenderer(const std::shared_ptr & renderer, bool setDefaults = false); std::shared_ptr & ofGetCurrentRenderer(); void ofSetEscapeQuitsApp(bool bQuitOnEsc); diff --git a/libs/openFrameworks/graphics/ofGraphics.cpp b/libs/openFrameworks/graphics/ofGraphics.cpp index b7e45922cd5..f14827d406a 100644 --- a/libs/openFrameworks/graphics/ofGraphics.cpp +++ b/libs/openFrameworks/graphics/ofGraphics.cpp @@ -13,7 +13,7 @@ using std::vector; static ofVboMesh gradientMesh; -void ofSetCurrentRenderer(shared_ptr renderer, bool setDefaults) { +void ofSetCurrentRenderer(const shared_ptr & renderer, bool setDefaults) { if (setDefaults) { ofStyle style = ofGetCurrentRenderer()->getStyle(); renderer->setupGraphicDefaults(); diff --git a/libs/openFrameworks/graphics/ofGraphicsCairo.cpp b/libs/openFrameworks/graphics/ofGraphicsCairo.cpp index 2f2ca104a09..859f706fe5a 100644 --- a/libs/openFrameworks/graphics/ofGraphicsCairo.cpp +++ b/libs/openFrameworks/graphics/ofGraphicsCairo.cpp @@ -18,7 +18,7 @@ static void ofEndSaveScreen(){ cairoScreenshot.reset(); } if( storedRenderer ){ - ofSetCurrentRenderer(storedRenderer,true); + ofSetCurrentRenderer(storedRenderer, true); storedRenderer.reset(); } From 3c827fbc0677f2b7ce97a9745d511ed074bceecb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 22:58:06 -0300 Subject: [PATCH 123/143] revert some --- addons/ofxiOS/src/core/ofxiOSGLKView.mm | 2 +- libs/openFrameworks/app/ofAppRunner.cpp | 18 +++++++++--------- libs/openFrameworks/app/ofAppRunner.h | 2 +- libs/openFrameworks/app/ofMainLoop.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/ofxiOS/src/core/ofxiOSGLKView.mm b/addons/ofxiOS/src/core/ofxiOSGLKView.mm index 3712e5dcbba..d13ff55ce80 100644 --- a/addons/ofxiOS/src/core/ofxiOSGLKView.mm +++ b/addons/ofxiOS/src/core/ofxiOSGLKView.mm @@ -99,7 +99,7 @@ - (void)setup { window = dynamic_pointer_cast(ofCreateWindow(windowSettings)); - ofRunApp(app, window); + ofRunApp(app); } if(window->isProgrammableRenderer() == true) { diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 095e53a0cf8..bbdd32b6024 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -185,14 +185,14 @@ void ofSetMainLoop(const shared_ptr & newMainLoop) { //} // ////-------------------------------------- -//int ofRunApp(shared_ptr && app){ -// ofCore.mainLoop->run(std::move(app)); -// auto ret = ofRunMainLoop(); -//#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) -// ofExitCallback(); -//#endif -// return ret; -//} +int ofRunApp(const shared_ptr & app){ + ofCore.mainLoop->run(app); + auto ret = ofRunMainLoop(); +#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) + ofExitCallback(); +#endif + return ret; +} ////-------------------------------------- //void ofRunApp(const shared_ptr & window, shared_ptr && app){ @@ -202,6 +202,7 @@ void ofSetMainLoop(const shared_ptr & newMainLoop) { void ofRunApp( const shared_ptr & window, const shared_ptr & app){ + ofInit(); ofCore.mainLoop->run(window, app); } @@ -227,7 +228,6 @@ void ofSetupOpenGL(int w, int h, ofWindowMode screenMode){ shared_ptr ofCreateWindow(const ofWindowSettings & settings){ - ofInit(); return ofCore.mainLoop->createWindow(settings); } diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index de4b89c4b4d..1b1c9dc420f 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -81,7 +81,7 @@ void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode) { ofSetupOpenGL(window, w, h, screenMode); } -//int ofRunApp(std::shared_ptr && OFSA); +int ofRunApp(const std::shared_ptr & OFSA); //int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated void ofRunApp(const std::shared_ptr & window, const std::shared_ptr & app); diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 504369b89c0..5dfaac2b176 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -104,12 +104,12 @@ void ofMainLoop::run( } } -void ofMainLoop::run(std::shared_ptr && app){ +void ofMainLoop::run(const std::shared_ptr & app){ // if(!windowsApps.empty()){ // run(windowsApps.begin()->first, std::move(app)); // } if(!windows.empty()){ - run(windows[0], std::move(app)); + run(windows[0], app); } } From 11c7fd03e057700a613fb235089f36e19b0f8b0c Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 23:01:21 -0300 Subject: [PATCH 124/143] update --- libs/openFrameworks/app/ofMainLoop.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index 0050c70324d..d5cb8a77452 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -35,7 +35,7 @@ class ofMainLoop { void run(const std::shared_ptr & window, const std::shared_ptr & app); // std::shared_ptr && app); - void run(std::shared_ptr && app); + void run(const std::shared_ptr & app); int loop(); void loopOnce(); void pollEvents(); From c220f4b1436003203014c2c860d758e857050681 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 23:13:26 -0300 Subject: [PATCH 125/143] buffer object --- libs/openFrameworks/app/ofMainLoop.cpp | 53 +------------------------- libs/openFrameworks/app/ofMainLoop.h | 6 ++- libs/openFrameworks/gl/ofShader.cpp | 40 ++++++++++++------- 3 files changed, 31 insertions(+), 68 deletions(-) diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 5dfaac2b176..e4db50148f2 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -128,16 +128,8 @@ int ofMainLoop::loop(){ void ofMainLoop::loopOnce(){ if(bShouldClose) return; - -// std::cout << "ofMainLoop::loopOnce()" << std::endl; + auto i = windows.begin(); - -// currentWindow = (*i); -// // here, not looping all windows -// i->get()->makeCurrent(); -// i->get()->update(); -// i->get()->draw(); - for ( ; i != windows.end(); ) { if (i->get()->getWindowShouldClose()) { i = windows.erase(i); @@ -151,35 +143,6 @@ void ofMainLoop::loopOnce(){ } } - - - -// for(auto i = windows.begin(); !windows.empty() && i != windows.end();){ -// if(i->get()->getWindowShouldClose()){ -//// const auto & window = i->first; -// i->get()->close(); -// windows.erase(i++); -// } else { -// currentWindow = i; -// i->makeCurrent(); -// i->update(); -// i->draw(); -// i++; ///< continue to next window -// } -// } -// for(auto i = windowsApps.begin(); !windowsApps.empty() && i != windowsApps.end();){ -// if(i->first->getWindowShouldClose()){ -// const auto & window = i->first; -// window->close(); -// windowsApps.erase(i++); ///< i now points at the window after the one which was just erased -// }else{ -// currentWindow = i->first; -// i->first->makeCurrent(); -// i->first->update(); -// i->first->draw(); -// i++; ///< continue to next window -// } -// } loopEvent.notify(this); } @@ -193,18 +156,10 @@ void ofMainLoop::exit(){ exitEvent.notify(this); for (auto window : windows) { -// for(auto i: windowsApps){ -// std::shared_ptr window = i.first; -// std::shared_ptr app = i.second; -// if(app == nullptr) { -// continue; -// } - if(window == nullptr) { continue; } - ofEventArgs args; ofNotifyEvent(window->events().exit, args, this); @@ -280,12 +235,6 @@ void ofMainLoop::setCurrentWindow(ofAppBaseWindow * window){ break; } } -// for(auto i: windowsApps){ -// if(i.first.get() == window){ -// currentWindow = i.first; -// break; -// } -// } } std::shared_ptr ofMainLoop::getCurrentApp(){ diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index d5cb8a77452..22ed90b0867 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -53,13 +53,16 @@ class ofMainLoop { std::thread::id get_thread_id() { return thread_id; }; // Testing + // FIXME: const & ? std::vector > getWindows() { return windows; } void ofBeginWindow(int n); void ofEndWindow(); - +public: + std::weak_ptr currentWindow; + private: std::thread::id thread_id { std::this_thread::get_id() }; @@ -70,7 +73,6 @@ class ofMainLoop { std::shared_ptr mainApp; bool bShouldClose; - std::weak_ptr currentWindow; int status; bool allowMultiWindow; std::function windowLoop; diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 80a86688c0b..74370ec6df3 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -715,7 +715,7 @@ bool ofShader::linkProgram() { //#ifndef TARGET_OPENGLES #ifdef GLEW_ARB_uniform_buffer_object - if (GLEW_ARB_uniform_buffer_object) { +// if (GLEW_ARB_uniform_buffer_object) { // Pre-cache all active uniforms blocks GLint numUniformBlocks = 0; glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &numUniformBlocks); @@ -730,7 +730,7 @@ bool ofShader::linkProgram() { bufferObjectsCache[name] = std::make_unique(); uniformBlocksCache[name] = glGetUniformBlockIndex(program, name.c_str()); } - } +// } #endif //#endif @@ -1336,39 +1336,46 @@ GLint ofShader::getUniformLocation(const string & name) const { GLint ofShader::getUniformBlockIndex(const string & name) const { if (!bLoaded) return -1; - if (GLEW_ARB_uniform_buffer_object) { +// if (GLEW_ARB_uniform_buffer_object) { +#ifdef GLEW_ARB_uniform_buffer_object auto it = uniformBlocksCache.find(name); if (it == uniformBlocksCache.end()) { return -1; } else { return it->second; } - } else { +#else + // } else { ofLogError("ofShader::getUniformBlockIndex") << "Sorry, it looks like you can't run 'ARB_uniform_buffer_object'"; return -1; - } +// } +#endif } //-------------------------------------------------------------- GLint ofShader::getUniformBlockBinding(const string & name) const { if (!bLoaded) return -1; - if (GLEW_ARB_uniform_buffer_object) { +#ifdef GLEW_ARB_uniform_buffer_object +// if (GLEW_ARB_uniform_buffer_object) { GLint index = getUniformBlockIndex(name); if (index == -1) return -1; GLint blockBinding; glGetActiveUniformBlockiv(program, index, GL_UNIFORM_BLOCK_BINDING, &blockBinding); return blockBinding; - } else { +#else +//} else { ofLogError("ofShader::getUniformBlockBinding") << "Sorry, it looks like you can't run 'ARB_uniform_buffer_object'"; return -1; - } +// } +#endif } //-------------------------------------------------------------- void ofShader::printActiveUniformBlocks() const { - if (GLEW_ARB_uniform_buffer_object) { +#ifdef GLEW_ARB_uniform_buffer_object +// if (GLEW_ARB_uniform_buffer_object) { GLint numUniformBlocks = 0; glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &numUniformBlocks); ofLogNotice("ofShader") << numUniformBlocks << " uniform blocks"; @@ -1395,22 +1402,27 @@ void ofShader::printActiveUniformBlocks() const { line.str(""); } delete[] uniformBlockName; - } else { +#else +//} else { ofLogError("ofShader::printActiveUniformBlocks") << "Sorry, it looks like you can't run 'ARB_uniform_buffer_object'"; - } +#endif +//} } void ofShader::bindUniformBlock(GLuint binding, const string & name) const { if (bLoaded) { - if (GLEW_ARB_uniform_buffer_object) { +#ifdef GLEW_ARB_uniform_buffer_object +// if (GLEW_ARB_uniform_buffer_object) { GLint index = getUniformBlockIndex(name); if (index != -1) { glUniformBlockBinding(program, index, binding); } - } else { +#else +// } else { ofLogError("ofShader::bindUniformBlock") << "Sorry, it looks like you can't run 'ARB_uniform_buffer_object'"; } - } +// } +#endif } // #endif //#endif From 67a5d4fb95ad9065e9224b4ea1ad860d71b938fe Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 4 Sep 2024 23:17:26 -0300 Subject: [PATCH 126/143] fix --- libs/openFrameworks/gl/ofShader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 74370ec6df3..2d40780db0d 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -1410,7 +1410,9 @@ void ofShader::printActiveUniformBlocks() const { } void ofShader::bindUniformBlock(GLuint binding, const string & name) const { - if (bLoaded) { + if (!bLoaded) return; + + #ifdef GLEW_ARB_uniform_buffer_object // if (GLEW_ARB_uniform_buffer_object) { GLint index = getUniformBlockIndex(name); @@ -1420,9 +1422,9 @@ void ofShader::bindUniformBlock(GLuint binding, const string & name) const { #else // } else { ofLogError("ofShader::bindUniformBlock") << "Sorry, it looks like you can't run 'ARB_uniform_buffer_object'"; - } // } #endif + } // #endif //#endif From 0188a84e000cbb103423c60e44ae89fa37cf5d84 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 09:40:56 -0300 Subject: [PATCH 127/143] tests --- libs/openFrameworks/app/ofAppRunner.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 1b1c9dc420f..9124c7195f6 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -20,6 +20,7 @@ static struct ofCoreInternal { bool initialized = false; bool exiting = false; ofCoreEvents noopEvents; + // ofMainLoop mainLoop; std::shared_ptr mainLoop { std::make_shared() }; // ofFileUtils @@ -29,7 +30,8 @@ static struct ofCoreInternal { // controlled destruction of the mainLoop before // any other deinitialization - mainLoop->exit(); + // mainLoop->exit(); +// mainLoop.exit(); // all shutdown functions called for (const auto & func : shutdownFunctions) { @@ -64,7 +66,7 @@ void ofSetupOpenGL(const std::shared_ptr & windowPtr, int w, int h, ofWi ofWindowSettings settings; settings.setSize(w, h); settings.windowMode = screenMode; - ofCore.mainLoop->addWindow(windowPtr); +// ofCore.mainLoop.addWindow(windowPtr); windowPtr->setup(settings); } From 0c377e6ef6a3f0b9142688652b0f2cd9d504a5eb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 11:23:13 -0300 Subject: [PATCH 128/143] ofGetMainLoop substitution --- libs/openFrameworks/events/ofEvents.cpp | 24 ++++++++++++------------ libs/openFrameworks/utils/ofUtils.cpp | 21 +++++++++------------ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index ae664232d88..9c90ebb959c 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -7,7 +7,7 @@ static ofEventArgs voidEventArgs; //-------------------------------------- void ofSetFrameRate(int targetRate) { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { window->events().setFrameRate(targetRate); } else { @@ -17,7 +17,7 @@ void ofSetFrameRate(int targetRate) { //-------------------------------------- float ofGetFrameRate() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getFrameRate(); } else { @@ -26,7 +26,7 @@ float ofGetFrameRate() { } bool ofGetTargetFrameRateEnabled() { - if (auto window = ofGetMainLoop()->getCurrentWindow()) { + if (auto window = ofCore.mainLoop->getCurrentWindow()) { return window->events().getTargetFrameRateEnabled(); } return false; @@ -34,7 +34,7 @@ bool ofGetTargetFrameRateEnabled() { //-------------------------------------- float ofGetTargetFrameRate() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getTargetFrameRate(); } else { @@ -44,7 +44,7 @@ float ofGetTargetFrameRate() { //-------------------------------------- double ofGetLastFrameTime() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getLastFrameTime(); } else { @@ -54,7 +54,7 @@ double ofGetLastFrameTime() { //-------------------------------------- uint64_t ofGetFrameNum() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getFrameNum(); } else { @@ -64,7 +64,7 @@ uint64_t ofGetFrameNum() { //-------------------------------------- bool ofGetMousePressed(int button) { //by default any button - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getMousePressed(button); } else { @@ -74,7 +74,7 @@ bool ofGetMousePressed(int button) { //by default any button //-------------------------------------- bool ofGetKeyPressed(int key) { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getKeyPressed(key); } else { @@ -84,7 +84,7 @@ bool ofGetKeyPressed(int key) { //-------------------------------------- int ofGetMouseX() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getMouseX(); } else { @@ -94,7 +94,7 @@ int ofGetMouseX() { //-------------------------------------- int ofGetMouseY() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getMouseY(); } else { @@ -104,7 +104,7 @@ int ofGetMouseY() { //-------------------------------------- int ofGetPreviousMouseX() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getPreviousMouseX(); } else { @@ -114,7 +114,7 @@ int ofGetPreviousMouseX() { //-------------------------------------- int ofGetPreviousMouseY() { - auto window = ofGetMainLoop()->getCurrentWindow(); + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getPreviousMouseY(); } else { diff --git a/libs/openFrameworks/utils/ofUtils.cpp b/libs/openFrameworks/utils/ofUtils.cpp index 54c7122aa77..0f0f65995b0 100644 --- a/libs/openFrameworks/utils/ofUtils.cpp +++ b/libs/openFrameworks/utils/ofUtils.cpp @@ -247,8 +247,8 @@ uint64_t ofGetFixedStepForFps(double fps) { } ofTimeMode ofGetTimeMode() { - if (auto mainLoop = ofGetMainLoop()) { - if (auto window = mainLoop->getCurrentWindow()) { + if (ofCore.mainLoop) { + if (auto window = ofCore.mainLoop->getCurrentWindow()) { return window->events().getTimeMode(); } } @@ -257,12 +257,11 @@ ofTimeMode ofGetTimeMode() { //-------------------------------------- void ofSetTimeModeSystem() { - auto mainLoop = ofGetMainLoop(); - if (!mainLoop) { + if (!ofCore.mainLoop) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = mainLoop->getCurrentWindow(); + auto window = ofCore.mainLoop->getCurrentWindow(); if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; @@ -273,28 +272,26 @@ void ofSetTimeModeSystem() { //-------------------------------------- void ofSetTimeModeFixedRate(uint64_t stepNanos) { - auto mainLoop = ofGetMainLoop(); - if (!mainLoop) { + if (!ofCore.mainLoop) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = mainLoop->getCurrentWindow(); + auto window = ofCore.mainLoop->getCurrentWindow(); if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; } window->events().setTimeModeFixedRate(stepNanos); - of::priv::getClock().setTimeModeFixedRate(stepNanos, *mainLoop); + of::priv::getClock().setTimeModeFixedRate(stepNanos, *ofCore.mainLoop); } //-------------------------------------- void ofSetTimeModeFiltered(float alpha) { - auto mainLoop = ofGetMainLoop(); - if (!mainLoop) { + if (!ofCore.mainLoop) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = mainLoop->getCurrentWindow(); + auto window = ofCore.mainLoop->getCurrentWindow(); if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; From eab9a6208a44a32b40f6f24352daa770c85e4bc1 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 11:29:11 -0300 Subject: [PATCH 129/143] before changes --- libs/openFrameworks/app/ofAppRunner.cpp | 1 - libs/openFrameworks/app/ofAppRunner.h | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index bbdd32b6024..0f2b51609ea 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -164,7 +164,6 @@ void ofInit(){ } //-------------------------------------- -// TODO: const & shared_ptr ofGetMainLoop(){ return ofCore.mainLoop; } diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 9124c7195f6..6b26baf0dd3 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -48,6 +48,13 @@ static struct ofCoreInternal { exiting = false; } + std::shared_ptr getCurrentWindow(){ + if (mainLoop) { + return mainLoop->currentWindow.lock(); + } + return nullptr; + } + } ofCore; From acbd0350323f8159128b467519557ae724fd1449 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 11:30:03 -0300 Subject: [PATCH 130/143] more straightness --- libs/openFrameworks/app/ofAppRunner.cpp | 84 ++++++++++++------------- libs/openFrameworks/events/ofEvents.cpp | 24 +++---- libs/openFrameworks/utils/ofUtils.cpp | 8 +-- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 0f2b51609ea..1081b7d3507 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -241,7 +241,7 @@ void ofExitCallback(){ //-------------------------------------- // core events instance & arguments ofCoreEvents & ofEvents(){ - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if(window){ return window->events(); }else{ @@ -261,7 +261,7 @@ void ofSetEscapeQuitsApp(bool bQuitOnEsc){ //-------------------------------------- shared_ptr & ofGetCurrentRenderer(){ - return ofCore.mainLoop->getCurrentWindow()->renderer(); + return ofCore.getCurrentWindow()->renderer(); } //-------------------------------------- @@ -280,12 +280,12 @@ bool ofIsCurrentThreadTheMainThread() { //-------------------------------------- ofAppBaseWindow * ofGetWindowPtr(){ - return ofCore.mainLoop->getCurrentWindow().get(); + return ofCore.getCurrentWindow().get(); } //-------------------------------------- std::shared_ptr ofGetCurrentWindow() { - return ofCore.mainLoop->getCurrentWindow(); + return ofCore.getCurrentWindow(); } //-------------------------------------- @@ -295,18 +295,18 @@ void ofExit(int status){ //-------------------------------------- void ofHideCursor(){ - ofCore.mainLoop->getCurrentWindow()->hideCursor(); + ofCore.getCurrentWindow()->hideCursor(); } //-------------------------------------- void ofShowCursor(){ - ofCore.mainLoop->getCurrentWindow()->showCursor(); + ofCore.getCurrentWindow()->showCursor(); } //-------------------------------------- // FIXME: this is not standard with the other window modes. void ofSetOrientation(ofOrientation orientation, bool vFlip){ - ofCore.mainLoop->getCurrentWindow()->setOrientation(orientation); + ofCore.getCurrentWindow()->setOrientation(orientation); // TODO: every window should set orientation on it's renderer if(ofGetCurrentRenderer()){ ofGetCurrentRenderer()->setOrientation(orientation,vFlip); @@ -315,92 +315,92 @@ void ofSetOrientation(ofOrientation orientation, bool vFlip){ //-------------------------------------- ofOrientation ofGetOrientation(){ - return ofCore.mainLoop->getCurrentWindow()->getOrientation(); + return ofCore.getCurrentWindow()->getOrientation(); } //-------------------------------------- void ofSetWindowPosition(int x, int y){ - ofCore.mainLoop->getCurrentWindow()->setWindowPosition(x,y); + ofCore.getCurrentWindow()->setWindowPosition(x,y); } //-------------------------------------- void ofSetWindowShape(int width, int height){ - ofCore.mainLoop->getCurrentWindow()->setWindowShape(width, height); + ofCore.getCurrentWindow()->setWindowShape(width, height); } //-------------------------------------- void ofSetWindowRect(const ofRectangle & rect) { - ofCore.mainLoop->getCurrentWindow()->setWindowRect(rect); + ofCore.getCurrentWindow()->setWindowRect(rect); } //-------------------------------------- glm::ivec2 ofGetWindowPosition() { - return ofCore.mainLoop->getCurrentWindow()->getWindowPosition(); + return ofCore.getCurrentWindow()->getWindowPosition(); } //-------------------------------------- int ofGetWindowPositionX(){ - return (int)ofCore.mainLoop->getCurrentWindow()->getWindowPosition().x; + return (int)ofCore.getCurrentWindow()->getWindowPosition().x; } //-------------------------------------- int ofGetWindowPositionY(){ - return (int)ofCore.mainLoop->getCurrentWindow()->getWindowPosition().y; + return (int)ofCore.getCurrentWindow()->getWindowPosition().y; } //-------------------------------------- int ofGetScreenWidth(){ - return ofCore.mainLoop->getCurrentWindow()->getScreenSize().x; + return ofCore.getCurrentWindow()->getScreenSize().x; } //-------------------------------------- int ofGetScreenHeight(){ - return ofCore.mainLoop->getCurrentWindow()->getScreenSize().y; + return ofCore.getCurrentWindow()->getScreenSize().y; } //-------------------------------------- glm::ivec2 ofGetScreenSize() { - return ofCore.mainLoop->getCurrentWindow()->getScreenSize(); + return ofCore.getCurrentWindow()->getScreenSize(); } //-------------------------------------------------- int ofGetWidth(){ - return (int)ofCore.mainLoop->getCurrentWindow()->getWidth(); + return (int)ofCore.getCurrentWindow()->getWidth(); } //-------------------------------------------------- int ofGetHeight(){ - return (int)ofCore.mainLoop->getCurrentWindow()->getHeight(); + return (int)ofCore.getCurrentWindow()->getHeight(); } //-------------------------------------------------- int ofGetWindowWidth(){ - return (int)ofCore.mainLoop->getCurrentWindow()->getWindowSize().x; + return (int)ofCore.getCurrentWindow()->getWindowSize().x; } //-------------------------------------------------- int ofGetWindowHeight(){ - return (int)ofCore.mainLoop->getCurrentWindow()->getWindowSize().y; + return (int)ofCore.getCurrentWindow()->getWindowSize().y; } //-------------------------------------------------- std::string ofGetClipboardString(){ - return ofCore.mainLoop->getCurrentWindow()->getClipboardString(); + return ofCore.getCurrentWindow()->getClipboardString(); } //-------------------------------------------------- void ofSetClipboardString(const std::string & str){ - ofCore.mainLoop->getCurrentWindow()->setClipboardString(str); + ofCore.getCurrentWindow()->setClipboardString(str); } //-------------------------------------------------- bool ofDoesHWOrientation(){ - return ofCore.mainLoop->getCurrentWindow()->doesHWOrientation(); + return ofCore.getCurrentWindow()->doesHWOrientation(); } //-------------------------------------------------- glm::ivec2 ofGetWindowSize() { //this can't return glm::vec2(ofGetWidth(), ofGetHeight()) as width and height change based on orientation. - return ofCore.mainLoop->getCurrentWindow()->getWindowSize(); + return ofCore.getCurrentWindow()->getWindowSize(); } //-------------------------------------------------- @@ -421,85 +421,85 @@ ofRectangle ofGetWindowRect() { //-------------------------------------- void ofSetWindowTitle(std::string title){ - ofCore.mainLoop->getCurrentWindow()->setWindowTitle(title); + ofCore.getCurrentWindow()->setWindowTitle(title); } //---------------------------------------------------------- void ofEnableSetupScreen(){ - ofCore.mainLoop->getCurrentWindow()->enableSetupScreen(); + ofCore.getCurrentWindow()->enableSetupScreen(); } //---------------------------------------------------------- void ofDisableSetupScreen(){ - ofCore.mainLoop->getCurrentWindow()->disableSetupScreen(); + ofCore.getCurrentWindow()->disableSetupScreen(); } //-------------------------------------- void ofToggleFullscreen(){ - ofCore.mainLoop->getCurrentWindow()->toggleFullscreen(); + ofCore.getCurrentWindow()->toggleFullscreen(); } //-------------------------------------- void ofSetFullscreen(bool fullscreen){ - ofCore.mainLoop->getCurrentWindow()->setFullscreen(fullscreen); + ofCore.getCurrentWindow()->setFullscreen(fullscreen); } //-------------------------------------- int ofGetWindowMode(){ - return ofCore.mainLoop->getCurrentWindow()->getWindowMode(); + return ofCore.getCurrentWindow()->getWindowMode(); } //-------------------------------------- void ofSetVerticalSync(bool bSync){ - ofCore.mainLoop->getCurrentWindow()->setVerticalSync(bSync); + ofCore.getCurrentWindow()->setVerticalSync(bSync); } //-------------------------- native window handles #if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) Display* ofGetX11Display(){ - return ofCore.mainLoop->getCurrentWindow()->getX11Display(); + return ofCore.getCurrentWindow()->getX11Display(); } Window ofGetX11Window(){ - return ofCore.mainLoop->getCurrentWindow()->getX11Window(); + return ofCore.getCurrentWindow()->getX11Window(); } #endif #if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES) GLXContext ofGetGLXContext(){ - return ofCore.mainLoop->getCurrentWindow()->getGLXContext(); + return ofCore.getCurrentWindow()->getGLXContext(); } #endif #if defined(TARGET_LINUX) && defined(TARGET_OPENGLES) EGLDisplay ofGetEGLDisplay(){ - return ofCore.mainLoop->getCurrentWindow()->getEGLDisplay(); + return ofCore.getCurrentWindow()->getEGLDisplay(); } EGLContext ofGetEGLContext(){ - return ofCore.mainLoop->getCurrentWindow()->getEGLContext(); + return ofCore.getCurrentWindow()->getEGLContext(); } EGLSurface ofGetEGLSurface(){ - return ofCore.mainLoop->getCurrentWindow()->getEGLSurface(); + return ofCore.getCurrentWindow()->getEGLSurface(); } #endif #if defined(TARGET_OSX) void * ofGetNSGLContext(){ - return ofCore.mainLoop->getCurrentWindow()->getNSGLContext(); + return ofCore.getCurrentWindow()->getNSGLContext(); } void * ofGetCocoaWindow(){ - return ofCore.mainLoop->getCurrentWindow()->getCocoaWindow(); + return ofCore.getCurrentWindow()->getCocoaWindow(); } #endif #if defined(TARGET_WIN32) HGLRC ofGetWGLContext(){ - return ofCore.mainLoop->getCurrentWindow()->getWGLContext(); + return ofCore.getCurrentWindow()->getWGLContext(); } HWND ofGetWin32Window(){ - return ofCore.mainLoop->getCurrentWindow()->getWin32Window(); + return ofCore.getCurrentWindow()->getWin32Window(); } #endif diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index 9c90ebb959c..d57d547ed23 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -7,7 +7,7 @@ static ofEventArgs voidEventArgs; //-------------------------------------- void ofSetFrameRate(int targetRate) { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { window->events().setFrameRate(targetRate); } else { @@ -17,7 +17,7 @@ void ofSetFrameRate(int targetRate) { //-------------------------------------- float ofGetFrameRate() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getFrameRate(); } else { @@ -26,7 +26,7 @@ float ofGetFrameRate() { } bool ofGetTargetFrameRateEnabled() { - if (auto window = ofCore.mainLoop->getCurrentWindow()) { + if (auto window = ofCore.getCurrentWindow()) { return window->events().getTargetFrameRateEnabled(); } return false; @@ -34,7 +34,7 @@ bool ofGetTargetFrameRateEnabled() { //-------------------------------------- float ofGetTargetFrameRate() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getTargetFrameRate(); } else { @@ -44,7 +44,7 @@ float ofGetTargetFrameRate() { //-------------------------------------- double ofGetLastFrameTime() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getLastFrameTime(); } else { @@ -54,7 +54,7 @@ double ofGetLastFrameTime() { //-------------------------------------- uint64_t ofGetFrameNum() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getFrameNum(); } else { @@ -64,7 +64,7 @@ uint64_t ofGetFrameNum() { //-------------------------------------- bool ofGetMousePressed(int button) { //by default any button - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getMousePressed(button); } else { @@ -74,7 +74,7 @@ bool ofGetMousePressed(int button) { //by default any button //-------------------------------------- bool ofGetKeyPressed(int key) { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getKeyPressed(key); } else { @@ -84,7 +84,7 @@ bool ofGetKeyPressed(int key) { //-------------------------------------- int ofGetMouseX() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getMouseX(); } else { @@ -94,7 +94,7 @@ int ofGetMouseX() { //-------------------------------------- int ofGetMouseY() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getMouseY(); } else { @@ -104,7 +104,7 @@ int ofGetMouseY() { //-------------------------------------- int ofGetPreviousMouseX() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getPreviousMouseX(); } else { @@ -114,7 +114,7 @@ int ofGetPreviousMouseX() { //-------------------------------------- int ofGetPreviousMouseY() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofCore.getCurrentWindow() }; if (window) { return window->events().getPreviousMouseY(); } else { diff --git a/libs/openFrameworks/utils/ofUtils.cpp b/libs/openFrameworks/utils/ofUtils.cpp index 0f0f65995b0..680d163ef79 100644 --- a/libs/openFrameworks/utils/ofUtils.cpp +++ b/libs/openFrameworks/utils/ofUtils.cpp @@ -248,7 +248,7 @@ uint64_t ofGetFixedStepForFps(double fps) { ofTimeMode ofGetTimeMode() { if (ofCore.mainLoop) { - if (auto window = ofCore.mainLoop->getCurrentWindow()) { + if (auto window = ofCore.getCurrentWindow()) { return window->events().getTimeMode(); } } @@ -261,7 +261,7 @@ void ofSetTimeModeSystem() { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = ofCore.mainLoop->getCurrentWindow(); + auto window = ofCore.getCurrentWindow(); if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; @@ -276,7 +276,7 @@ void ofSetTimeModeFixedRate(uint64_t stepNanos) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = ofCore.mainLoop->getCurrentWindow(); + auto window = ofCore.getCurrentWindow(); if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; @@ -291,7 +291,7 @@ void ofSetTimeModeFiltered(float alpha) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = ofCore.mainLoop->getCurrentWindow(); + auto window = ofCore.getCurrentWindow(); if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; From 6854cf2735bea68c7fa8490654f3e06d7722f002 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 15:00:55 -0300 Subject: [PATCH 131/143] altcore tests --- libs/openFrameworks/3d/ofNode.h | 2 ++ libs/openFrameworks/app/ofAppBaseWindow.h | 2 ++ libs/openFrameworks/app/ofAppRunner.h | 7 +++++++ libs/openFrameworks/events/ofEvents.cpp | 16 ++++++++++++++++ libs/openFrameworks/events/ofEvents.h | 7 ++++--- libs/openFrameworks/gl/ofTexture.cpp | 8 +++++--- libs/openFrameworks/utils/ofURLFileLoader.cpp | 3 +++ libs/openFrameworks/utils/ofUtils.cpp | 8 ++++---- 8 files changed, 43 insertions(+), 10 deletions(-) diff --git a/libs/openFrameworks/3d/ofNode.h b/libs/openFrameworks/3d/ofNode.h index fe9ad7ca0d4..8cad3d30bbb 100644 --- a/libs/openFrameworks/3d/ofNode.h +++ b/libs/openFrameworks/3d/ofNode.h @@ -9,6 +9,8 @@ #include #include +// FIXME: unordered_set +#include class ofBaseRenderer; diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 6166e507cbe..926a34273c5 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -114,4 +114,6 @@ class ofAppBaseWindow { //private: ofOrientation orientation = OF_ORIENTATION_DEFAULT; ofWindowMode windowMode = OF_WINDOW; + + std::string name { "virgem" }; }; diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 6b26baf0dd3..86f3490b335 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -10,11 +10,16 @@ class ofBaseApp; class ofBaseRenderer; class ofCoreEvents; +using std::cout; +using std::endl; + static struct ofCoreInternal { public: ofCoreInternal() {}; ~ofCoreInternal() {}; + std::string name = "virgem"; + std::vector > shutdownFunctions; // ofAppRunner bool initialized = false; @@ -43,6 +48,7 @@ static struct ofCoreInternal { } void init() { + name = "inicializado"; if (initialized) return; initialized = true; exiting = false; @@ -52,6 +58,7 @@ static struct ofCoreInternal { if (mainLoop) { return mainLoop->currentWindow.lock(); } + cout << "getCurrentWindow ofCore nullptr name=" << name << endl; return nullptr; } diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index d57d547ed23..c970f8e9359 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -76,8 +76,11 @@ bool ofGetMousePressed(int button) { //by default any button bool ofGetKeyPressed(int key) { auto window { ofCore.getCurrentWindow() }; if (window) { + std::cout << "ofGetKeyPressed in window: " << window->name << std::endl; return window->events().getKeyPressed(key); } else { + std::cout << "ofGetKeyPressed null window, ofCore name=" << ofCore.name << ", " << &ofCore << std::endl; + return false; } } @@ -337,6 +340,12 @@ bool ofCoreEvents::notifyKeyReleased(int key, int keycode, int scancode, uint32_ //------------------------------------------ bool ofCoreEvents::notifyKeyEvent(ofKeyEventArgs & e) { + + using std::cout; + using std::endl; + + cout << "ofCoreEvents::notifyKeyEvent " << e.key << endl; + bool attended = false; modifiers = e.modifiers; switch (e.type) { @@ -365,7 +374,10 @@ bool ofCoreEvents::notifyKeyEvent(ofKeyEventArgs & e) { attended = ofNotifyEvent(keyPressed, keyEventArgs); } + // FIXME: mover este e o erase pra dentro do else pressedKeys.insert(e.key); + cout << "pressedKeys size" << pressedKeys.size() << endl; + if (!attended) { return ofNotifyEvent(keyPressed, e); } else { @@ -397,12 +409,16 @@ bool ofCoreEvents::notifyKeyEvent(ofKeyEventArgs & e) { } pressedKeys.erase(e.key); + cout << "pressedKeys size" << pressedKeys.size() << endl; + if (!attended) { return ofNotifyEvent(keyReleased, e); } else { return attended; } } + + return false; } diff --git a/libs/openFrameworks/events/ofEvents.h b/libs/openFrameworks/events/ofEvents.h index d40d8417dc1..27e1f710689 100644 --- a/libs/openFrameworks/events/ofEvents.h +++ b/libs/openFrameworks/events/ofEvents.h @@ -9,7 +9,8 @@ #define GLM_ENABLE_EXPERIMENTAL #include -#include +//#include +#include //-------------------------- mouse/key query bool ofGetMousePressed(int button = -1); //by default any button @@ -418,8 +419,8 @@ class ofCoreEvents { int currentMouseX, currentMouseY; int previousMouseX, previousMouseY; bool bPreMouseNotSet; - std::set pressedMouseButtons; - std::set pressedKeys; + std::unordered_set pressedMouseButtons; + std::unordered_set pressedKeys; int modifiers = 0; enum TimeMode { diff --git a/libs/openFrameworks/gl/ofTexture.cpp b/libs/openFrameworks/gl/ofTexture.cpp index 851da0103cb..8f99048e282 100644 --- a/libs/openFrameworks/gl/ofTexture.cpp +++ b/libs/openFrameworks/gl/ofTexture.cpp @@ -7,6 +7,8 @@ #include "ofMesh.h" #include "ofRectangle.h" #include +// FIXME: unordered_set +#include #ifdef TARGET_ANDROID #include "ofAppAndroidWindow.h" @@ -19,7 +21,7 @@ static bool bUsingArbTex = true; static bool bUsingNormalizedTexCoords = false; static bool bUseCustomMinMagFilters = false; -using std::set; +//using std::set; //--------------------------------- void ofEnableTextureEdgeHack(){ @@ -164,8 +166,8 @@ static void release(GLuint id){ } #ifdef TARGET_ANDROID -static set & allTextures(){ - static set * allTextures = new set; +static std::set & allTextures(){ + static std::set * allTextures = new std::set; return *allTextures; } diff --git a/libs/openFrameworks/utils/ofURLFileLoader.cpp b/libs/openFrameworks/utils/ofURLFileLoader.cpp index 32f9b62daba..f18decd007a 100644 --- a/libs/openFrameworks/utils/ofURLFileLoader.cpp +++ b/libs/openFrameworks/utils/ofURLFileLoader.cpp @@ -3,6 +3,8 @@ #include "ofUtils.h" #include "ofFileUtils.h" #include "ofLog.h" +// FIXME: unordered_set +#include using std::map; using std::set; @@ -64,6 +66,7 @@ class ofURLFileLoaderImpl : public ofThread, public ofBaseURLFileLoader { ofThreadChannel requests; ofThreadChannel responses; ofThreadChannel cancelRequestQueue; + // FIXME: unordered_set set cancelledRequests; }; diff --git a/libs/openFrameworks/utils/ofUtils.cpp b/libs/openFrameworks/utils/ofUtils.cpp index 680d163ef79..bc31def7f73 100644 --- a/libs/openFrameworks/utils/ofUtils.cpp +++ b/libs/openFrameworks/utils/ofUtils.cpp @@ -248,7 +248,7 @@ uint64_t ofGetFixedStepForFps(double fps) { ofTimeMode ofGetTimeMode() { if (ofCore.mainLoop) { - if (auto window = ofCore.getCurrentWindow()) { + if (auto window { ofCore.getCurrentWindow() }) { return window->events().getTimeMode(); } } @@ -261,7 +261,7 @@ void ofSetTimeModeSystem() { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = ofCore.getCurrentWindow(); + auto window { ofCore.getCurrentWindow() }; if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; @@ -276,7 +276,7 @@ void ofSetTimeModeFixedRate(uint64_t stepNanos) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = ofCore.getCurrentWindow(); + auto window { ofCore.getCurrentWindow() }; if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; @@ -291,7 +291,7 @@ void ofSetTimeModeFiltered(float alpha) { ofLogError("ofSetSystemTimeMode") << "ofMainLoop is not initialized yet, can't set time mode"; return; } - auto window = ofCore.getCurrentWindow(); + auto window { ofCore.getCurrentWindow() }; if (!window) { ofLogError("ofSetSystemTimeMode") << "No window setup yet can't set time mode"; return; From cb8b843296d24ae1e5c3396a09607a13d4d95ac0 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 18:41:39 -0300 Subject: [PATCH 132/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.h | 3 ++- libs/openFrameworks/app/ofAppRunner.h | 11 ++++++++-- libs/openFrameworks/events/ofEvents.cpp | 25 +++++++++++++---------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 9a9a7cffc18..48475b007a3 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -156,7 +156,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { XIC xic; #endif - std::unique_ptr coreEvents; + ofCoreEvents coreEvents; +// std::unique_ptr coreEvents; std::shared_ptr currentRenderer; ofWindowMode targetWindowMode; diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 86f3490b335..db94f7a80c3 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -54,9 +54,16 @@ static struct ofCoreInternal { exiting = false; } - std::shared_ptr getCurrentWindow(){ +//std::shared_ptr ofGetCurrentWindow() { + +// std::shared_ptr ofMainLoop::getCurrentWindow(){ +// return currentWindow.lock(); +// } + + std::shared_ptr getCurrentWindow(){ if (mainLoop) { - return mainLoop->currentWindow.lock(); + return mainLoop->getCurrentWindow(); +// return mainLoop->currentWindow.lock(); } cout << "getCurrentWindow ofCore nullptr name=" << name << endl; return nullptr; diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index c970f8e9359..124b26f6f78 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -74,12 +74,14 @@ bool ofGetMousePressed(int button) { //by default any button //-------------------------------------- bool ofGetKeyPressed(int key) { - auto window { ofCore.getCurrentWindow() }; + auto window = ofGetCurrentWindow(); +// auto window = ofCore.getCurrentWindow(); + if (window) { - std::cout << "ofGetKeyPressed in window: " << window->name << std::endl; +// std::cout << "ofGetKeyPressed in window: " << window->name << std::endl; return window->events().getKeyPressed(key); } else { - std::cout << "ofGetKeyPressed null window, ofCore name=" << ofCore.name << ", " << &ofCore << std::endl; + std::cout << "ofGetKeyPressed null window, ofCore name=" << ofCore.name << ", ofCore pointer=" << &ofCore << std::endl; return false; } @@ -344,8 +346,6 @@ bool ofCoreEvents::notifyKeyEvent(ofKeyEventArgs & e) { using std::cout; using std::endl; - cout << "ofCoreEvents::notifyKeyEvent " << e.key << endl; - bool attended = false; modifiers = e.modifiers; switch (e.type) { @@ -374,9 +374,12 @@ bool ofCoreEvents::notifyKeyEvent(ofKeyEventArgs & e) { attended = ofNotifyEvent(keyPressed, keyEventArgs); } - // FIXME: mover este e o erase pra dentro do else - pressedKeys.insert(e.key); - cout << "pressedKeys size" << pressedKeys.size() << endl; + + // OK - FIXME: mover este e o erase pra dentro do else + else { + pressedKeys.insert(e.key); + } + if (!attended) { return ofNotifyEvent(keyPressed, e); @@ -407,9 +410,9 @@ bool ofCoreEvents::notifyKeyEvent(ofKeyEventArgs & e) { keyEventArgs.key = OF_KEY_SUPER; attended = ofNotifyEvent(keyReleased, keyEventArgs); } - - pressedKeys.erase(e.key); - cout << "pressedKeys size" << pressedKeys.size() << endl; + else { + pressedKeys.erase(e.key); + } if (!attended) { return ofNotifyEvent(keyReleased, e); From 89153990e78a076d10a5d458a06fb30104da689b Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 18:49:37 -0300 Subject: [PATCH 133/143] up --- libs/openFrameworks/app/ofAppGLFWWindow.h | 4 ++-- libs/openFrameworks/app/ofAppRunner.h | 2 +- libs/openFrameworks/events/ofEvents.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 48475b007a3..9c3d5200ad2 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -156,8 +156,8 @@ class ofAppGLFWWindow : public ofAppBaseWindow { XIC xic; #endif - ofCoreEvents coreEvents; -// std::unique_ptr coreEvents; +// ofCoreEvents coreEvents; + std::unique_ptr coreEvents; std::shared_ptr currentRenderer; ofWindowMode targetWindowMode; diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index db94f7a80c3..d656f8d2d67 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -25,7 +25,7 @@ static struct ofCoreInternal { bool initialized = false; bool exiting = false; ofCoreEvents noopEvents; - // ofMainLoop mainLoop; +// ofMainLoop mainLoop; std::shared_ptr mainLoop { std::make_shared() }; // ofFileUtils diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index 124b26f6f78..c6f701f6f18 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -89,7 +89,7 @@ bool ofGetKeyPressed(int key) { //-------------------------------------- int ofGetMouseX() { - auto window { ofCore.getCurrentWindow() }; + auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getMouseX(); } else { From b4ae604c620f20e4eabec956382c410fc4013df5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 19:03:17 -0300 Subject: [PATCH 134/143] ofsa ios --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 +- libs/openFrameworks/app/ofAppRunner.cpp | 18 +++++++++--------- libs/openFrameworks/app/ofAppRunner.h | 17 ++++++----------- libs/openFrameworks/events/ofEvents.cpp | 9 ++++++--- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 24385c08142..e25bf458ee0 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -41,7 +41,7 @@ using std::cout; using std::endl; //------------------------------------------------------- -ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(new ofCoreEvents){ +ofAppGLFWWindow::ofAppGLFWWindow() : coreEvents(std::make_unique()){ bEnableSetupScreen = true; buttonInUse = 0; buttonPressed = false; diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 1081b7d3507..0a923fd0c28 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -174,14 +174,14 @@ void ofSetMainLoop(const shared_ptr & newMainLoop) { } //-------------------------------------- -//int ofRunApp(ofBaseApp * OFSA){ -// ofCore.mainLoop->run(shared_ptr(OFSA)); -// auto ret = ofRunMainLoop(); -//#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) -// ofExitCallback(); -//#endif -// return ret; -//} +int ofRunApp(ofBaseApp * OFSA){ + ofCore.mainLoop->run(shared_ptr(OFSA)); + auto ret = ofRunMainLoop(); +#if !defined(TARGET_ANDROID) && !defined(TARGET_OF_IOS) + ofExitCallback(); +#endif + return ret; +} // ////-------------------------------------- int ofRunApp(const shared_ptr & app){ @@ -280,7 +280,7 @@ bool ofIsCurrentThreadTheMainThread() { //-------------------------------------- ofAppBaseWindow * ofGetWindowPtr(){ - return ofCore.getCurrentWindow().get(); + return ofGetCurrentWindow().get(); } //-------------------------------------- diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index d656f8d2d67..bea35a47246 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -54,16 +54,10 @@ static struct ofCoreInternal { exiting = false; } -//std::shared_ptr ofGetCurrentWindow() { - -// std::shared_ptr ofMainLoop::getCurrentWindow(){ -// return currentWindow.lock(); -// } - - std::shared_ptr getCurrentWindow(){ - if (mainLoop) { - return mainLoop->getCurrentWindow(); -// return mainLoop->currentWindow.lock(); + std::shared_ptr getCurrentWindow(){ +// if (mainLoop) //mainLoop is always present. is it? + { + return mainLoop->currentWindow.lock(); } cout << "getCurrentWindow ofCore nullptr name=" << name << endl; return nullptr; @@ -105,7 +99,8 @@ void ofSetupOpenGL(Window * windowPtr, int w, int h, ofWindowMode screenMode) { } int ofRunApp(const std::shared_ptr & OFSA); -//int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated + +int ofRunApp(ofBaseApp * OFSA = nullptr); // will be deprecated void ofRunApp(const std::shared_ptr & window, const std::shared_ptr & app); int ofRunMainLoop(); diff --git a/libs/openFrameworks/events/ofEvents.cpp b/libs/openFrameworks/events/ofEvents.cpp index c6f701f6f18..a180a4bfe6d 100644 --- a/libs/openFrameworks/events/ofEvents.cpp +++ b/libs/openFrameworks/events/ofEvents.cpp @@ -74,7 +74,7 @@ bool ofGetMousePressed(int button) { //by default any button //-------------------------------------- bool ofGetKeyPressed(int key) { - auto window = ofGetCurrentWindow(); + auto window { ofGetCurrentWindow() }; // auto window = ofCore.getCurrentWindow(); if (window) { @@ -89,7 +89,9 @@ bool ofGetKeyPressed(int key) { //-------------------------------------- int ofGetMouseX() { - auto window { ofCore.mainLoop->getCurrentWindow() }; + auto window { ofGetCurrentWindow() }; + +// auto window { ofCore.mainLoop->getCurrentWindow() }; if (window) { return window->events().getMouseX(); } else { @@ -99,7 +101,8 @@ int ofGetMouseX() { //-------------------------------------- int ofGetMouseY() { - auto window { ofCore.getCurrentWindow() }; +// auto window { ofCore.getCurrentWindow() }; + auto window { ofGetCurrentWindow() }; if (window) { return window->events().getMouseY(); } else { From 795dcfcbe663953563b6f57519f170807545a124 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 19:32:34 -0300 Subject: [PATCH 135/143] std::set for linux --- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 117 +----------------- libs/openFrameworks/app/ofMainLoop.cpp | 4 - libs/openFrameworks/app/ofMainLoop.h | 4 - .../sound/ofOpenALSoundPlayer.cpp | 1 + 4 files changed, 2 insertions(+), 124 deletions(-) diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index e25bf458ee0..b7fe56df086 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -656,12 +656,12 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { [cocoaWindow setStyleMask:NSWindowStyleMaskBorderless]; [cocoaWindow setHasShadow:NO]; } else { + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; // to recover correctly from a green button fullscreen if (([cocoaWindow styleMask] & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) { [cocoaWindow toggleFullScreen:nil]; } - [NSApp setPresentationOptions:NSApplicationPresentationDefault]; [cocoaWindow setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable]; [cocoaWindow setHasShadow:YES]; } @@ -708,122 +708,7 @@ void ofAppGLFWWindow::setFullscreen(bool fullscreen) { #elif defined(TARGET_LINUX) -// #include -// -// Window nativeWin = glfwGetX11Window(windowP); -// Display * display = glfwGetX11Display(); -// if (targetWindowMode == OF_FULLSCREEN) { -// -// // FIXME: Remove legacy code here -// -// int monitorCount; -// GLFWmonitor ** monitors = glfwGetMonitors(&monitorCount); -// if (settings.multiMonitorFullScreen && monitorCount > 1) { -// // find the monitors at the edges of the virtual desktop -// int minx = numeric_limits::max(); -// int miny = numeric_limits::max(); -// int maxx = numeric_limits::min(); -// int maxy = numeric_limits::min(); -// int x, y, w, h; -// int monitorLeft = 0, monitorRight = 0, monitorTop = 0, monitorBottom = 0; -// for (int i = 0; i < monitorCount; i++) { -// glfwGetMonitorPos(monitors[i], &x, &y); -// auto videoMode = glfwGetVideoMode(monitors[i]); -// w = videoMode->width; -// h = videoMode->height; -// if (x < minx) { -// monitorLeft = i; -// minx = x; -// } -// if (y < miny) { -// monitorTop = i; -// miny = y; -// } -// if (x + w > maxx) { -// monitorRight = i; -// maxx = x + w; -// } -// if (y + h > maxy) { -// monitorBottom = i; -// maxy = y + h; -// } -// } -// -// // send fullscreen_monitors event with the edges monitors -// Atom m_net_fullscreen_monitors = XInternAtom(display, "_NET_WM_FULLSCREEN_MONITORS", false); -// -// XEvent xev; -// -// xev.xclient.type = ClientMessage; -// xev.xclient.serial = 0; -// xev.xclient.send_event = True; -// xev.xclient.window = nativeWin; -// xev.xclient.message_type = m_net_fullscreen_monitors; -// xev.xclient.format = 32; -// -// xev.xclient.data.l[0] = monitorTop; -// xev.xclient.data.l[1] = monitorBottom; -// xev.xclient.data.l[2] = monitorLeft; -// xev.xclient.data.l[3] = monitorRight; -// xev.xclient.data.l[4] = 1; -// XSendEvent(display, RootWindow(display, DefaultScreen(display)), -// False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); -// -// // FIXME: review -// windowRect.width = maxx - minx; -// windowRect.height = maxy - minx; -//// currentW = maxx - minx; -//// currentH = maxy - minx; -// } else { -// auto monitor = glfwGetWindowMonitor(windowP); -// if (monitor) { -// auto videoMode = glfwGetVideoMode(monitor); -// if (videoMode) { -// windowRect.width = videoMode->width; -// windowRect.height = videoMode->height; -//// currentW = videoMode->width; -//// currentH = videoMode->height; -// } -// } -// } -// } -// -// // send fullscreen event -// Atom m_net_state = XInternAtom(display, "_NET_WM_STATE", false); -// Atom m_net_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", false); -// -// XEvent xev; -// -// xev.xclient.type = ClientMessage; -// xev.xclient.serial = 0; -// xev.xclient.send_event = True; -// xev.xclient.window = nativeWin; -// xev.xclient.message_type = m_net_state; -// xev.xclient.format = 32; -// -// if (fullscreen) -// xev.xclient.data.l[0] = 1; -// else -// xev.xclient.data.l[0] = 0; -// -// xev.xclient.data.l[1] = m_net_fullscreen; -// xev.xclient.data.l[2] = 0; -// xev.xclient.data.l[3] = 0; -// xev.xclient.data.l[4] = 0; -// XSendEvent(display, RootWindow(display, DefaultScreen(display)), -// False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); -// -// // tell the window manager to bypass composition for this window in fullscreen for speed -// // it'll probably help solving vsync issues -// Atom m_bypass_compositor = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); -// unsigned long value = fullscreen ? 1 : 0; -// XChangeProperty(display, nativeWin, m_bypass_compositor, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&value, 1); -// -// -(display); -// -// // setWindowShape(windowW, windowH); setFSTarget(targetWindowMode); - #endif settings.windowMode = targetWindowMode; diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index e4db50148f2..545cda8f067 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -105,9 +105,6 @@ void ofMainLoop::run( } void ofMainLoop::run(const std::shared_ptr & app){ -// if(!windowsApps.empty()){ -// run(windowsApps.begin()->first, std::move(app)); -// } if(!windows.empty()){ run(windows[0], app); } @@ -115,7 +112,6 @@ void ofMainLoop::run(const std::shared_ptr & app){ int ofMainLoop::loop(){ if(!windowLoop){ -// while(!bShouldClose && !windowsApps.empty()){ while(!bShouldClose && !windows.empty()){ loopOnce(); pollEvents(); diff --git a/libs/openFrameworks/app/ofMainLoop.h b/libs/openFrameworks/app/ofMainLoop.h index 22ed90b0867..f47c5bf7b10 100644 --- a/libs/openFrameworks/app/ofMainLoop.h +++ b/libs/openFrameworks/app/ofMainLoop.h @@ -52,8 +52,6 @@ class ofMainLoop { std::thread::id get_thread_id() { return thread_id; }; - // Testing - // FIXME: const & ? std::vector > getWindows() { return windows; } void ofBeginWindow(int n); @@ -67,8 +65,6 @@ class ofMainLoop { std::thread::id thread_id { std::this_thread::get_id() }; void keyPressed(ofKeyEventArgs & key); -// std::unordered_map, std::shared_ptr > windowsApps; - std::vector > windows; std::shared_ptr mainApp; diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 02c11d3c0d8..5ca0b4c7a27 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -7,6 +7,7 @@ #include #include "ofLog.h" #include "ofEvents.h" +#include "" #if defined (TARGET_OF_IOS) || defined (TARGET_OSX) #include From d4319103fe1d506dfd24b881ba7d6429b90b7ebb Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 19:36:02 -0300 Subject: [PATCH 136/143] emscripten --- libs/openFrameworks/gl/ofShader.cpp | 4 ++-- libs/openFrameworks/gl/ofShader.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 2d40780db0d..d3410484a02 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -112,9 +112,9 @@ ofShader::ofShader(const ofShader & mom) , shaders(mom.shaders) , uniformsCache(mom.uniformsCache) , attributesBindingsCache(mom.attributesBindingsCache) -#ifndef TARGET_OPENGLES +//#ifndef TARGET_OPENGLES , uniformBlocksCache(mom.uniformBlocksCache) -#endif +//#endif { if (mom.bLoaded) { retainProgram(program); diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index d0376631d02..0bbec885641 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -292,9 +292,9 @@ class ofShader { std::unordered_map uniformsCache; mutable std::unordered_map attributesBindingsCache; -#ifndef TARGET_OPENGLES +//#ifndef TARGET_OPENGLES std::unordered_map uniformBlocksCache; -#endif +//#endif bool setupShaderFromSource(Source && source); ofShader::Source sourceFromFile(GLenum type, const of::filesystem::path& filename); From 224dd4c0ef3b627626210623573f01bae62dff52 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 20:38:08 -0300 Subject: [PATCH 137/143] fix set linux --- libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 5ca0b4c7a27..333c2b2f52f 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -7,7 +7,7 @@ #include #include "ofLog.h" #include "ofEvents.h" -#include "" +#include #if defined (TARGET_OF_IOS) || defined (TARGET_OSX) #include From f4688d3b1615297ee4dcad9745b673b0145579f5 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Mon, 9 Sep 2024 20:40:22 -0300 Subject: [PATCH 138/143] emscripten fix --- addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp index 3518998e13a..a44706b459b 100644 --- a/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp +++ b/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp @@ -483,25 +483,25 @@ void ofxAppEmscriptenWindow::setWindowShape(int w, int h){ } //------------------------------------------------------------ -glm::vec2 ofxAppEmscriptenWindow::getWindowPosition(){ - return glm::vec2(0,0); +glm::ivec2 ofxAppEmscriptenWindow::getWindowPosition(){ + return { 0, 0 }; } //------------------------------------------------------------ -glm::vec2 ofxAppEmscriptenWindow::getWindowSize(){ +glm::ivec2 ofxAppEmscriptenWindow::getWindowSize(){ if(mCurrentWindowMode == OF_GAME_MODE) { double twidth, theight; emscripten_get_element_css_size("canvas", &twidth, &theight); - return glm::vec2((int)twidth,(int)theight); + return { (int)twidth, (int)theight }; } int width; int height; emscripten_get_canvas_element_size("canvas", &width, &height); - return glm::vec2(width,height); + return { width, height }; } //------------------------------------------------------------ -glm::vec2 ofxAppEmscriptenWindow::getScreenSize(){ +glm::ivec2 ofxAppEmscriptenWindow::getScreenSize(){ return getWindowSize(); } From 3ab651fd471e688c643f4e92586913c5faf2bd6f Mon Sep 17 00:00:00 2001 From: Dimitre Date: Tue, 10 Sep 2024 19:59:17 -0300 Subject: [PATCH 139/143] ow, still issue with keys --- libs/openFrameworks/app/ofAppRunner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 0a923fd0c28..a2b3030064b 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -285,7 +285,8 @@ ofAppBaseWindow * ofGetWindowPtr(){ //-------------------------------------- std::shared_ptr ofGetCurrentWindow() { - return ofCore.getCurrentWindow(); +// return ofCore.getCurrentWindow(); + return ofCore.mainLoop->getCurrentWindow(); } //-------------------------------------- From 2160a7f8908cc6f5e9029c5a4223995ab37ede40 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Sun, 16 Feb 2025 00:07:54 -0300 Subject: [PATCH 140/143] fix ofCore --- libs/openFrameworks/app/ofAppRunner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index c0bda7ef239..ebe8a7c4f48 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -199,7 +199,7 @@ int ofRunApp(const shared_ptr & app){ //} void ofRunApp( - const shared_ptr & window, + const shared_ptr & window, const shared_ptr & app){ ofInit(); ofCore.mainLoop->run(window, app); @@ -442,7 +442,7 @@ void ofToggleFullscreen(){ //-------------------------------------- void ofSetWindowMousePassThrough(bool allowPassThrough){ - mainLoop()->getCurrentWindow()->setWindowMousePassthrough(allowPassThrough); + ofCore.getCurrentWindow()->setWindowMousePassthrough(allowPassThrough); } //-------------------------------------- From 159c09f9ce35a334fda75715d8ce91e098b13c87 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 19 Feb 2025 12:08:46 -0300 Subject: [PATCH 141/143] altcore --- examples/templates/emptyExample/src/ofApp.cpp | 6 ++++-- libs/openFrameworks/app/ofAppRunner.cpp | 2 ++ libs/openFrameworks/app/ofAppRunner.h | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/templates/emptyExample/src/ofApp.cpp b/examples/templates/emptyExample/src/ofApp.cpp index 710d6eacc68..74a2e36d813 100644 --- a/examples/templates/emptyExample/src/ofApp.cpp +++ b/examples/templates/emptyExample/src/ofApp.cpp @@ -2,7 +2,6 @@ //-------------------------------------------------------------- void ofApp::setup(){ - } //-------------------------------------------------------------- @@ -12,6 +11,9 @@ void ofApp::update(){ //-------------------------------------------------------------- void ofApp::draw(){ + ofSetFrameRate(30); + + ofDrawBitmapString(ofToString(ofGetFrameRate()), 20, 20); } @@ -68,4 +70,4 @@ void ofApp::gotMessage(ofMessage msg){ //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ -} \ No newline at end of file +} diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index ebe8a7c4f48..1a1563b6aeb 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -10,6 +10,8 @@ #include "ofEvents.h" // of::priv #include "ofUtils.h" // initUtils +ofCoreInternal ofCore; + using std::shared_ptr; #if !defined(TARGET_NODISPLAY) diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index be30bf58a47..460abfa3fe4 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -63,10 +63,9 @@ static struct ofCoreInternal { return nullptr; } -} ofCore; - - +}; +extern ofCoreInternal ofCore; void ofInit(); From a0767d74c5c6a059608b1b610cc3e49f9cfd739d Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 19 Feb 2025 12:28:04 -0300 Subject: [PATCH 142/143] update test --- libs/openFrameworks/app/ofAppRunner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 460abfa3fe4..55ffe5ad8dd 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -13,7 +13,7 @@ class ofCoreEvents; using std::cout; using std::endl; -static struct ofCoreInternal { +struct ofCoreInternal { public: ofCoreInternal() {}; ~ofCoreInternal() {}; From 213cd4afbf5fb115b472333a9aad2a16bf9f0a61 Mon Sep 17 00:00:00 2001 From: Dimitre Date: Wed, 19 Feb 2025 12:34:14 -0300 Subject: [PATCH 143/143] openal --- libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp index 63953bc1e47..218527bc72b 100644 --- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp +++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp @@ -10,6 +10,8 @@ #include "ofEvents.h" #include "ofUtils.h" +#include + #if defined (TARGET_OF_IOS) || defined (TARGET_OSX) #include #include