From 261af064d764e4138bfb0aead93196d7ffc5c4b6 Mon Sep 17 00:00:00 2001 From: Theodore Watson Date: Thu, 14 Nov 2019 09:08:20 -0800 Subject: [PATCH] supports the Rpi 4 with EGL and GLFW. Closes #6436 (#6438) * supports the Rpi 4 with EGL and GLFW. Closes #6436 * better defines for rpi. changed make file to reflect. * updated config.linuxarmv7l.raspberry2.mk to reflect changes to armv6l changes * detect new Raspbian releases and disable legacy system in make file * adding glfw to multistrap.conf --- libs/openFrameworks/app/ofAppBaseWindow.h | 4 +- libs/openFrameworks/app/ofAppEGLWindow.cpp | 26 +++---- libs/openFrameworks/app/ofAppEGLWindow.h | 10 +-- libs/openFrameworks/app/ofAppGLFWWindow.cpp | 2 +- libs/openFrameworks/app/ofAppGLFWWindow.h | 6 +- libs/openFrameworks/app/ofAppRunner.cpp | 4 +- libs/openFrameworks/app/ofAppRunner.h | 2 +- libs/openFrameworks/app/ofMainLoop.cpp | 4 ++ libs/openFrameworks/gl/ofGLUtils.cpp | 2 +- libs/openFrameworks/ofMain.h | 2 +- libs/openFrameworks/utils/ofSystemUtils.cpp | 2 +- libs/openFrameworks/utils/ofTimer.cpp | 2 +- libs/openFrameworks/utils/ofUtils.cpp | 2 +- .../linuxarmv6l/config.linuxarmv6l.default.mk | 59 +++++++++++++++- .../config.linuxarmv7l.raspberry2.mk | 69 +++++++++++++++++-- scripts/ci/linuxarmv6l/multistrap.conf | 2 +- scripts/linux/debian/install_dependencies.sh | 4 +- 17 files changed, 159 insertions(+), 43 deletions(-) mode change 100755 => 100644 scripts/linux/debian/install_dependencies.sh diff --git a/libs/openFrameworks/app/ofAppBaseWindow.h b/libs/openFrameworks/app/ofAppBaseWindow.h index 235d7bc7f89..cee6648029c 100644 --- a/libs/openFrameworks/app/ofAppBaseWindow.h +++ b/libs/openFrameworks/app/ofAppBaseWindow.h @@ -12,7 +12,7 @@ struct __GLXcontextRec; typedef __GLXcontextRec * GLXContext; #endif -#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI) +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) typedef unsigned long Window; struct _XDisplay; typedef struct _XDisplay Display; @@ -77,7 +77,7 @@ class ofAppBaseWindow{ virtual void * getWindowContext(){return nullptr;}; -#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI) +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) virtual Display* getX11Display(){return nullptr;} virtual Window getX11Window() {return 0;} #endif diff --git a/libs/openFrameworks/app/ofAppEGLWindow.cpp b/libs/openFrameworks/app/ofAppEGLWindow.cpp index 6c103e937c8..b589256170a 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.cpp +++ b/libs/openFrameworks/app/ofAppEGLWindow.cpp @@ -287,7 +287,7 @@ EGLContext ofAppEGLWindow::getEglContext() const { return eglContext; } -#ifndef TARGET_RASPBERRY_PI +#ifndef TARGET_RASPBERRY_PI_LEGACY //------------------------------------------------------------ Display* ofAppEGLWindow::getX11Display(){ return x11Display; @@ -315,14 +315,14 @@ EGLint ofAppEGLWindow::getEglVersionMinor() const { //------------------------------------------------------------ void ofAppEGLWindow::initNative() { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY initRPiNative(); #endif } //------------------------------------------------------------ void ofAppEGLWindow::exitNative() { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY exitRPiNative(); #endif } @@ -337,7 +337,7 @@ EGLNativeWindowType ofAppEGLWindow::getNativeWindow() { if(isUsingX11) { return (EGLNativeWindowType)x11Window; } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY return (EGLNativeWindowType)&dispman_native_window; #else ofLogNotice("ofAppEGLWindow") << "getNativeWindow(): no native window type for this system, perhaps try X11?"; @@ -356,7 +356,7 @@ EGLNativeDisplayType ofAppEGLWindow::getNativeDisplay() { if(isUsingX11) { return (EGLNativeDisplayType)x11Display; } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY return (EGLNativeDisplayType)NULL; #else ofLogNotice("ofAppEGLWindow") << "getNativeDisplay(): no native window type for this system, perhaps try X11?"; @@ -429,7 +429,7 @@ void ofAppEGLWindow::setup(const ofAppEGLWindowSettings & _settings) { //////////////// // TODO remove the following ifdef once x11 is accelerated on RPI -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY if(isUsingX11) { isUsingX11 = false; ofLogWarning("ofAppEGLWindow") << "init(): X11 not availble on RPI yet, using a native window instead"; @@ -758,7 +758,7 @@ bool ofAppEGLWindow::destroyWindow() { XDestroyWindow(x11Display,x11Window); // or XCloseWindow? XFree(x11Screen); } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY dispman_update = vc_dispmanx_update_start(0); if (dispman_element != DISPMANX_NO_HANDLE) { vc_dispmanx_element_remove(dispman_update, dispman_element); @@ -942,7 +942,7 @@ void ofAppEGLWindow::setWindowRect(const ofRectangle& requestedWindowRect) { currentWindowRect = newRect; } } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY VC_RECT_T dst_rect; dst_rect.x = (int32_t)newRect.x; @@ -996,7 +996,7 @@ bool ofAppEGLWindow::createWindow(const ofRectangle& requestedWindowRect) { if(isUsingX11) { return createX11NativeWindow(requestedWindowRect); } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY return createRPiNativeWindow(requestedWindowRect); #else ofLogError("ofAppEGLWindow") << "createEGLWindow(): no native window type for this system, perhaps try X11?"; @@ -1097,7 +1097,7 @@ glm::vec2 ofAppEGLWindow::getScreenSize(){ } } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY int success = graphics_get_display_size(settings.screenNum, &screenWidth, &screenHeight); if(success < 0) { ofLogError("ofAppEGLWindow") << "getScreenSize(): tried to get display size but failed"; @@ -1165,7 +1165,7 @@ void ofAppEGLWindow::setWindowPosition(int x, int y){ nonFullscreenWindowRect = currentWindowRect; } } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY // keep it in bounds auto screenSize = getScreenSize(); @@ -1226,7 +1226,7 @@ void ofAppEGLWindow::setWindowShape(int w, int h){ nonFullscreenWindowRect = currentWindowRect; } } else { -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY setWindowRect(ofRectangle(currentWindowRect.x,currentWindowRect.y,w,h)); nonFullscreenWindowRect = currentWindowRect; #else @@ -1836,7 +1836,7 @@ void ofAppEGLWindow::readNativeInputEvents(){ } } -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY //------------------------------------------------------------ void ofAppEGLWindow::initRPiNative() { bcm_host_init(); diff --git a/libs/openFrameworks/app/ofAppEGLWindow.h b/libs/openFrameworks/app/ofAppEGLWindow.h index 245062496b0..a5a6b5671cd 100644 --- a/libs/openFrameworks/app/ofAppEGLWindow.h +++ b/libs/openFrameworks/app/ofAppEGLWindow.h @@ -18,9 +18,6 @@ enum ofAppEGLWindowType { OF_APP_WINDOW_X11 }; -typedef std::map ofEGLAttributeList; -typedef std::map::iterator ofEGLAttributeListIterator; - typedef struct _XIM * XIM; typedef struct _XIC * XIC; typedef unsigned long Window; @@ -34,6 +31,9 @@ typedef void *EGLConfig; typedef void *EGLSurface; typedef void *EGLContext; +typedef std::map ofEGLAttributeList; +typedef std::map::iterator ofEGLAttributeListIterator; + struct ofAppEGLWindowSettings: public ofGLESWindowSettings { public: ofAppEGLWindowType eglWindowPreference; ///< what window type is preferred? @@ -119,7 +119,7 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { EGLSurface getEglSurface() const; EGLContext getEglContext() const; -#ifndef TARGET_RASPBERRY_PI +#ifndef TARGET_RASPBERRY_PI_LEGACY Display* getX11Display(); Window getX11Window(); #endif @@ -225,7 +225,7 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread { EGLNativeWindowType getNativeWindow(); EGLNativeDisplayType getNativeDisplay(); -#ifdef TARGET_RASPBERRY_PI +#ifdef TARGET_RASPBERRY_PI_LEGACY void initRPiNative(); void exitRPiNative(); diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.cpp b/libs/openFrameworks/app/ofAppGLFWWindow.cpp index 6f0db8d2948..642da27b21d 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.cpp +++ b/libs/openFrameworks/app/ofAppGLFWWindow.cpp @@ -1651,7 +1651,7 @@ void ofAppGLFWWindow::makeCurrent(){ glfwMakeContextCurrent(windowP); } -#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI) +#if defined(TARGET_LINUX) Display* ofAppGLFWWindow::getX11Display(){ return glfwGetX11Display(); } diff --git a/libs/openFrameworks/app/ofAppGLFWWindow.h b/libs/openFrameworks/app/ofAppGLFWWindow.h index 50fd677eca2..b9a9f4381cc 100644 --- a/libs/openFrameworks/app/ofAppGLFWWindow.h +++ b/libs/openFrameworks/app/ofAppGLFWWindow.h @@ -4,7 +4,7 @@ #include "ofAppBaseWindow.h" #include "ofRectangle.h" -#ifdef TARGET_LINUX +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) typedef struct _XIM * XIM; typedef struct _XIC * XIC; #endif @@ -146,7 +146,7 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", void setStencilBits(int stencil)); OF_DEPRECATED_MSG("use ofGLFWWindowSettings to create the window instead", 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) +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) Display* getX11Display(); Window getX11Window(); XIC getX11XIC(); @@ -188,7 +188,7 @@ class ofAppGLFWWindow : public ofAppBaseGLWindow { void close(); -#ifdef TARGET_LINUX +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) void setWindowIcon(const std::string & path); void setWindowIcon(const ofPixels & iconPixels); XIM xim; diff --git a/libs/openFrameworks/app/ofAppRunner.cpp b/libs/openFrameworks/app/ofAppRunner.cpp index 010cb38472f..e3f7802c0d9 100644 --- a/libs/openFrameworks/app/ofAppRunner.cpp +++ b/libs/openFrameworks/app/ofAppRunner.cpp @@ -23,7 +23,7 @@ using namespace std; -#if !defined( TARGET_OF_IOS ) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI) +#if !defined( TARGET_OF_IOS ) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI_LEGACY) #include "ofAppGLFWWindow.h" //special case so we preserve supplied settngs //TODO: remove me when we remove the ofAppGLFWWindow setters. @@ -471,7 +471,7 @@ void ofSetVerticalSync(bool bSync){ } //-------------------------- native window handles -#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI) +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) Display* ofGetX11Display(){ return mainLoop()->getCurrentWindow()->getX11Display(); } diff --git a/libs/openFrameworks/app/ofAppRunner.h b/libs/openFrameworks/app/ofAppRunner.h index 021e12f7ec2..742f7997b50 100644 --- a/libs/openFrameworks/app/ofAppRunner.h +++ b/libs/openFrameworks/app/ofAppRunner.h @@ -112,7 +112,7 @@ std::shared_ptr & ofGetCurrentRenderer(); void ofSetEscapeQuitsApp(bool bQuitOnEsc); //-------------------------- native window handles -#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI) +#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY) typedef unsigned long Window; struct _XDisplay; typedef struct _XDisplay Display; diff --git a/libs/openFrameworks/app/ofMainLoop.cpp b/libs/openFrameworks/app/ofMainLoop.cpp index 5131db1d838..bb787ff9a2d 100644 --- a/libs/openFrameworks/app/ofMainLoop.cpp +++ b/libs/openFrameworks/app/ofMainLoop.cpp @@ -21,6 +21,8 @@ #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) @@ -51,6 +53,8 @@ shared_ptr ofMainLoop::createWindow(const ofWindowSettings & se shared_ptr window = std::make_shared(); #elif defined(TARGET_ANDROID) shared_ptr window = std::make_shared(); + #elif (defined(TARGET_RASPBERRY_PI) && defined(TARGET_GLFW_WINDOW)) + shared_ptr window = std::make_shared(); #elif defined(TARGET_RASPBERRY_PI) shared_ptr window = std::make_shared(); #elif defined(TARGET_EMSCRIPTEN) diff --git a/libs/openFrameworks/gl/ofGLUtils.cpp b/libs/openFrameworks/gl/ofGLUtils.cpp index 30fb9705257..df2a574ccc6 100644 --- a/libs/openFrameworks/gl/ofGLUtils.cpp +++ b/libs/openFrameworks/gl/ofGLUtils.cpp @@ -575,7 +575,7 @@ int ofGetGLInternalFormatFromPixelFormat(ofPixelFormat pixelFormat){ return GL_RGB; #endif case OF_PIXELS_RGB565: - #if defined(TARGET_ANDROID) || defined(TARGET_RASPBERRY_PI) + #if defined(TARGET_ANDROID) || defined(TARGET_RASPBERRY_PI_LEGACY) return GL_RGB565_OES; #elif defined(GL_RGB565) return GL_RGB565; diff --git a/libs/openFrameworks/ofMain.h b/libs/openFrameworks/ofMain.h index c9f5909ade3..dd0db80a979 100644 --- a/libs/openFrameworks/ofMain.h +++ b/libs/openFrameworks/ofMain.h @@ -80,7 +80,7 @@ #include "ofAppBaseWindow.h" #include "ofWindowSettings.h" #include "ofMainLoop.h" -#if !defined( TARGET_OF_IOS ) & !defined(TARGET_ANDROID) & !defined(TARGET_EMSCRIPTEN) & !defined(TARGET_RASPBERRY_PI) +#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" diff --git a/libs/openFrameworks/utils/ofSystemUtils.cpp b/libs/openFrameworks/utils/ofSystemUtils.cpp index 4b5e07e4342..aae91e3ff56 100644 --- a/libs/openFrameworks/utils/ofSystemUtils.cpp +++ b/libs/openFrameworks/utils/ofSystemUtils.cpp @@ -203,7 +203,7 @@ gboolean text_dialog_gtk(gpointer userdata){ static void initGTK(){ static bool initialized = false; if(!initialized){ - #if !defined(TARGET_RASPBERRY_PI) + #if !defined(TARGET_RASPBERRY_PI_LEGACY) XInitThreads(); #endif int argc=0; char **argv = nullptr; diff --git a/libs/openFrameworks/utils/ofTimer.cpp b/libs/openFrameworks/utils/ofTimer.cpp index f1dd327a8cf..82a2778b806 100644 --- a/libs/openFrameworks/utils/ofTimer.cpp +++ b/libs/openFrameworks/utils/ofTimer.cpp @@ -28,7 +28,7 @@ void ofTimer::setPeriodicEvent(uint64_t nanoseconds){ } void ofTimer::waitNext(){ -#if (defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI)) +#if (defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)) timespec remainder = {0,0}; timespec wakeTime = nextWakeTime.getAsTimespec(); clock_nanosleep(CLOCK_MONOTONIC,TIMER_ABSTIME,&wakeTime,&remainder); diff --git a/libs/openFrameworks/utils/ofUtils.cpp b/libs/openFrameworks/utils/ofUtils.cpp index 96ad2100234..e48625519e5 100644 --- a/libs/openFrameworks/utils/ofUtils.cpp +++ b/libs/openFrameworks/utils/ofUtils.cpp @@ -162,7 +162,7 @@ namespace priv{ ofTime t; t.mode = mode; if(mode == ofTime::System){ - #if (defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI)) || defined(TARGET_EMSCRIPTEN) + #if (defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)) || defined(TARGET_EMSCRIPTEN) struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); t.seconds = now.tv_sec; diff --git a/libs/openFrameworksCompiled/project/linuxarmv6l/config.linuxarmv6l.default.mk b/libs/openFrameworksCompiled/project/linuxarmv6l/config.linuxarmv6l.default.mk index 61ccb33b890..71ffce291a7 100644 --- a/libs/openFrameworksCompiled/project/linuxarmv6l/config.linuxarmv6l.default.mk +++ b/libs/openFrameworksCompiled/project/linuxarmv6l/config.linuxarmv6l.default.mk @@ -43,9 +43,42 @@ include $(OF_SHARED_MAKEFILES_PATH)/config.linux.common.mk # Note: Leave a leading space when adding list items with the += operator ################################################################################ +# We detect Raspbian versions Stretch and newer above and enable legacy automatically for older versions +# If detection fails comment USE_PI_LEGACY = 1 to use the newer system +USE_PI_LEGACY = 1 + +VER_ID = 0 + +#if we have this file lets see if we are Stretch or Newer +ifneq (,$(wildcard $(RPI_ROOT)/etc/os-release)) + #grab the Debian version ( 9 = Stretch, 10 = Buster ) + VER_ID = $(shell grep -oP '(?<=^VERSION_ID=).+' $(RPI_ROOT)/etc/os-release | tr -d '"') +endif + +#check if we are newer than 8 and use the new system +ifeq ($(shell expr $(VER_ID) \>= 9), 1) + USE_PI_LEGACY = 0 +endif + +$(info VER ID IS $(VER_ID)) + # defines used inside openFrameworks libs. PLATFORM_DEFINES += TARGET_RASPBERRY_PI +ifeq ($(USE_PI_LEGACY), 1) + PLATFORM_DEFINES += TARGET_RASPBERRY_PI_LEGACY + $(info using legacy build) +else + # comment this for older EGL windowing. Has no effect if USE_PI_LEGACY is enabled + # GLFW seems to provide a more robust window on newer Raspbian releases + USE_GLFW_WINDOW = 1 + $(info using newer build and GLFW window) +endif + +ifdef USE_GLFW_WINDOW + PLATFORM_DEFINES += TARGET_GLFW_WINDOW +endif + # TODO many of these are not relevant to openFrameworks (were just pasted from hello_pi examples) # from raspberry pi examples PLATFORM_DEFINES += STANDALONE @@ -119,8 +152,20 @@ PLATFORM_CFLAGS += -pipe # Note: Leave a leading space when adding list items with the += operator ################################################################################ +#rpi4 +ifdef USE_GLFW_WINDOW + PLATFORM_PKG_CONFIG_LIBRARIES += gl + PLATFORM_PKG_CONFIG_LIBRARIES += glu + PLATFORM_PKG_CONFIG_LIBRARIES += glew + PLATFORM_LIBRARIES += glfw +endif + # raspberry pi specific -ifneq (,$(wildcard $(RPI_ROOT)/opt/vc/lib/libGLESv2.so)) +ifeq ($(USE_PI_LEGACY), 0) + PLATFORM_LIBRARIES += GLESv2 + PLATFORM_LIBRARIES += GLESv1_CM + PLATFORM_LIBRARIES += EGL +else ifneq (,$(wildcard $(RPI_ROOT)/opt/vc/lib/libGLESv2.so)) PLATFORM_LIBRARIES += GLESv2 PLATFORM_LIBRARIES += GLESv1_CM PLATFORM_LIBRARIES += EGL @@ -128,6 +173,7 @@ else PLATFORM_LIBRARIES += brcmGLESv2 PLATFORM_LIBRARIES += brcmEGL endif + PLATFORM_LIBRARIES += openmaxil PLATFORM_LIBRARIES += bcm_host PLATFORM_LIBRARIES += vcos @@ -137,9 +183,11 @@ PLATFORM_LIBRARIES += rt PLATFORM_LIBRARIES += X11 PLATFORM_LIBRARIES += dl - PLATFORM_LDFLAGS += -pthread +ifeq ($(USE_PI_LEGACY), 0) + PLATFORM_LDFLAGS += -latomic +endif ################################################################################ # PLATFORM HEADER SEARCH PATHS @@ -186,7 +234,12 @@ PLATFORM_LIBRARY_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/lib # Note: Leave a leading space when adding list items with the += operator ################################################################################ -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGLFWWindow.cpp +#rpi4 +ifndef USE_GLFW_WINDOW + PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGLFWWindow.cpp +else + PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp +endif PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofFmodSoundPlayer.cpp ifeq ($(CROSS_COMPILING),1) diff --git a/libs/openFrameworksCompiled/project/linuxarmv7l/config.linuxarmv7l.raspberry2.mk b/libs/openFrameworksCompiled/project/linuxarmv7l/config.linuxarmv7l.raspberry2.mk index 5bb34f348f1..d6ed3561f37 100644 --- a/libs/openFrameworksCompiled/project/linuxarmv7l/config.linuxarmv7l.raspberry2.mk +++ b/libs/openFrameworksCompiled/project/linuxarmv7l/config.linuxarmv7l.raspberry2.mk @@ -43,9 +43,43 @@ include $(OF_SHARED_MAKEFILES_PATH)/config.linux.common.mk # Note: Leave a leading space when adding list items with the += operator ################################################################################ +# We detect Raspbian versions Stretch and newer above and enable legacy automatically for older versions +# If detection fails comment USE_PI_LEGACY = 1 to use the newer system +USE_PI_LEGACY = 1 + +VER_ID = 0 + +#if we have this file lets see if we are Stretch or Newer +ifneq (,$(wildcard $(RPI_ROOT)/etc/os-release)) + #grab the Debian version ( 9 = Stretch, 10 = Buster ) + VER_ID = $(shell grep -oP '(?<=^VERSION_ID=).+' $(RPI_ROOT)/etc/os-release | tr -d '"') +endif + +#check if we are newer than 8 and use the new system +ifeq ($(shell expr $(VER_ID) \>= 9), 1) + USE_PI_LEGACY = 0 +endif + +$(info VER ID IS $(VER_ID)) + # defines used inside openFrameworks libs. PLATFORM_DEFINES += TARGET_RASPBERRY_PI +ifeq ($(USE_PI_LEGACY), 1) + PLATFORM_DEFINES += TARGET_RASPBERRY_PI_LEGACY + $(info using legacy build) +else + # comment this for older EGL windowing. Has no effect if USE_PI_LEGACY is enabled + # GLFW seems to provide a more robust window on newer Raspbian releases + USE_GLFW_WINDOW = 1 + $(info using newer build and GLFW window) +endif + +ifdef USE_GLFW_WINDOW + PLATFORM_DEFINES += TARGET_GLFW_WINDOW +endif + + # TODO many of these are not relevant to openFrameworks (were just pasted from hello_pi examples) # from raspberry pi examples PLATFORM_DEFINES += STANDALONE @@ -119,10 +153,28 @@ PLATFORM_CFLAGS += -pipe # Note: Leave a leading space when adding list items with the += operator ################################################################################ +#rpi4 +ifdef USE_GLFW_WINDOW + PLATFORM_PKG_CONFIG_LIBRARIES += gl + PLATFORM_PKG_CONFIG_LIBRARIES += glu + PLATFORM_PKG_CONFIG_LIBRARIES += glew + PLATFORM_LIBRARIES += glfw +endif + # raspberry pi specific -PLATFORM_LIBRARIES += GLESv2 -PLATFORM_LIBRARIES += GLESv1_CM -PLATFORM_LIBRARIES += EGL +ifeq ($(USE_PI_LEGACY), 0) + PLATFORM_LIBRARIES += GLESv2 + PLATFORM_LIBRARIES += GLESv1_CM + PLATFORM_LIBRARIES += EGL +else ifneq (,$(wildcard $(RPI_ROOT)/opt/vc/lib/libGLESv2.so)) + PLATFORM_LIBRARIES += GLESv2 + PLATFORM_LIBRARIES += GLESv1_CM + PLATFORM_LIBRARIES += EGL +else + PLATFORM_LIBRARIES += brcmGLESv2 + PLATFORM_LIBRARIES += brcmEGL +endif + PLATFORM_LIBRARIES += openmaxil PLATFORM_LIBRARIES += bcm_host PLATFORM_LIBRARIES += vcos @@ -136,6 +188,9 @@ PLATFORM_LIBRARIES += dl PLATFORM_LDFLAGS += -pthread +ifeq ($(USE_PI_LEGACY), 0) + PLATFORM_LDFLAGS += -latomic +endif ################################################################################ # PLATFORM HEADER SEARCH PATHS @@ -183,8 +238,12 @@ PLATFORM_LIBRARY_SEARCH_PATHS += $(RPI_ROOT)/opt/vc/lib # Note: Leave a leading space when adding list items with the += operator ################################################################################ -#PLATFORM_PKG_CONFIG_LIBRARIES += gstreamer-egl-$(GST_VERSION) -PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGLFWWindow.cpp +#rpi4 +ifndef USE_GLFW_WINDOW + PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppGLFWWindow.cpp +else + PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/app/ofAppEGLWindow.cpp +endif PLATFORM_CORE_EXCLUSIONS += $(OF_LIBS_PATH)/openFrameworks/sound/ofFmodSoundPlayer.cpp ifeq ($(CROSS_COMPILING),1) diff --git a/scripts/ci/linuxarmv6l/multistrap.conf b/scripts/ci/linuxarmv6l/multistrap.conf index 1dbd56bf507..077b43284fd 100644 --- a/scripts/ci/linuxarmv6l/multistrap.conf +++ b/scripts/ci/linuxarmv6l/multistrap.conf @@ -22,7 +22,7 @@ components=main contrib non-free rpi suite=stretch [OpenFrameworks] -packages=libasound2-dev libxmu-dev libxxf86vm-dev g++ 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 libgles1-mesa-dev libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-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 +packages=libasound2-dev libxmu-dev libxxf86vm-dev g++ 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 libgles1-mesa-dev libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-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 source=http://archive.raspbian.org/raspbian keyring=raspbian-archive-keyring components=main contrib non-free rpi diff --git a/scripts/linux/debian/install_dependencies.sh b/scripts/linux/debian/install_dependencies.sh old mode 100755 new mode 100644 index 0879b779ac3..fe0eac8879b --- a/scripts/linux/debian/install_dependencies.sh +++ b/scripts/linux/debian/install_dependencies.sh @@ -37,7 +37,7 @@ fi echo "installing OF dependencies" -apt-get install freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ 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 libgtk${GTK_VERSION}-dev libopencv-dev libegl1-mesa-dev libgles1-mesa-dev libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev +apt-get install freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ 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 libgtk${GTK_VERSION}-dev libopencv-dev libegl1-mesa-dev libgles1 libgles2-mesa-dev libassimp-dev librtaudio-dev libboost-filesystem-dev libglfw3-dev liburiparser-dev libcurl4-openssl-dev libpugixml-dev libpoco-dev exit_code=$? if [ $exit_code != 0 ]; then echo "error installing dependencies, there could be an error with your internet connection" @@ -81,4 +81,4 @@ else echo "Updating ofxOpenCV to use openCV4" sed -i -E 's/ADDON_PKG_CONFIG_LIBRARIES =(.*)opencv\s/ADDON_PKG_CONFIG_LIBRARIES =\1opencv4 /g' "$addons_dir/ofxOpenCv/addon_config.mk" sed -i -E 's/ADDON_PKG_CONFIG_LIBRARIES =(.*)opencv$/ADDON_PKG_CONFIG_LIBRARIES =\1opencv4/g' "$addons_dir/ofxOpenCv/addon_config.mk" -fi \ No newline at end of file +fi